2019-06-04 03:40:48 +00:00
|
|
|
# Copyright (C) 2012-2017 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
|
|
|
class KnowledgeBase::BaseController < ApplicationController
|
2019-12-02 13:17:57 +00:00
|
|
|
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
|
2019-09-24 15:44:32 +00:00
|
|
|
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
|