trabajo-afectivo/app/controllers/knowledge_base/base_controller.rb

42 lines
896 B
Ruby
Raw Normal View History

2019-06-04 03:40:48 +00:00
# Copyright (C) 2012-2017 Zammad Foundation, http://zammad-foundation.org/
class KnowledgeBase::BaseController < ApplicationController
prepend_before_action :authentication_check
2019-06-04 03:40:48 +00:00
before_action :ensure_editor_or_reader
before_action :ensure_editor, only: %i[create update destroy]
def show
model_show_render(klass, params_for_permission)
end
def create
model_create_render(klass, params_for_permission)
end
def update
model_update_render(klass, params_for_permission)
end
def destroy
model_destroy_render(klass, params_for_permission)
end
private
def klass
@klass ||= controller_path.classify.constantize
end
def params_for_permission
params.permit klass.agent_allowed_params
end
def ensure_editor
permission_check 'knowledge_base.editor'
2019-06-04 03:40:48 +00:00
end
def ensure_editor_or_reader
permission_check 'knowledge_base.*'
end
end