save progress. added user feedback view and stuff
This commit is contained in:
42
app/controllers/user_exercise_feedbacks_controller.rb
Normal file
42
app/controllers/user_exercise_feedbacks_controller.rb
Normal file
@@ -0,0 +1,42 @@
|
||||
class UserExerciseFeedbackController < ApplicationController
|
||||
include CommonBehavior
|
||||
|
||||
def authorize!
|
||||
authorize(@uef)
|
||||
end
|
||||
private :authorize!
|
||||
|
||||
def create
|
||||
@tag = Tag.new(tag_params)
|
||||
authorize!
|
||||
create_and_respond(object: @tag)
|
||||
end
|
||||
|
||||
def destroy
|
||||
destroy_and_respond(object: @tag)
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def uef_params
|
||||
params[:tag].permit(:feedback_text, :difficulty)
|
||||
end
|
||||
private :uef_params
|
||||
|
||||
def new
|
||||
@uef = UserExerciseFeedback.new
|
||||
authorize!
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def update
|
||||
update_and_respond(object: @UserExerciseFeedback, params: uef_params)
|
||||
end
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
end
|
34
app/policies/user_exercise_feedback_policy.rb
Normal file
34
app/policies/user_exercise_feedback_policy.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
class TagPolicy < AdminOrAuthorPolicy
|
||||
def author?
|
||||
@user == @record.author
|
||||
end
|
||||
private :author?
|
||||
|
||||
def batch_update?
|
||||
admin?
|
||||
end
|
||||
|
||||
def show?
|
||||
@user.internal_user?
|
||||
end
|
||||
|
||||
[:clone?, :destroy?, :edit?, :update?].each do |action|
|
||||
define_method(action) { admin? || author?}
|
||||
end
|
||||
|
||||
[:reload?].each do |action|
|
||||
define_method(action) { everyone }
|
||||
end
|
||||
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
if @user.admin?
|
||||
@scope.all
|
||||
elsif @user.internal_user?
|
||||
@scope.where('user_id = ? OR public = TRUE', @user.id)
|
||||
else
|
||||
@scope.none
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
8
app/views/user_exercise_feedbacks/_form.html.slim
Normal file
8
app/views/user_exercise_feedbacks/_form.html.slim
Normal file
@@ -0,0 +1,8 @@
|
||||
= form_for(@uef) do |f|
|
||||
= render('shared/form_errors', object: @uef)
|
||||
.form-group
|
||||
= f.label(:feedback_text)
|
||||
= f.text_field(:feedback_text, class: 'form-control', required: true)
|
||||
= f.label(:difficulty)
|
||||
= f.text_field(:difficulty, class: 'form-control', required: true)
|
||||
.actions = render('shared/submit_button', f: f, object: @uef)
|
3
app/views/user_exercise_feedbacks/new.html.slim
Normal file
3
app/views/user_exercise_feedbacks/new.html.slim
Normal file
@@ -0,0 +1,3 @@
|
||||
h1 = t('shared.new_model', model: UserExerciseFeedback.model_name.human)
|
||||
|
||||
= render('form')
|
Reference in New Issue
Block a user