Add user permissions for flagging and for giving user feedback

This commit is contained in:
Albert Yi
2018-12-11 16:41:20 -08:00
parent c34df49f0f
commit 4706cae114
10 changed files with 96 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
class UserFeedbacksController < ApplicationController
before_action :gold_only, :only => [:new, :edit, :create, :update, :destroy]
before_action :check_no_feedback, only: [:new, :edit, :create, :update, :destroy]
respond_to :html, :xml, :json
def new
@@ -53,6 +54,12 @@ class UserFeedbacksController < ApplicationController
raise User::PrivilegeError unless user_feedback.editable_by?(CurrentUser.user)
end
def check_no_feedback
if CurrentUser.no_feedback?
raise User::PrivilegeError
end
end
def user_feedback_params(context)
permitted_params = %i[body category]
permitted_params += %i[user_id user_name] if context == :create