2012-10-30 09:10:59 +00:00
|
|
|
class OrbitBackendController < ApplicationController
|
2013-07-02 08:46:44 +00:00
|
|
|
include OrbitCategory::Categorizing
|
2012-12-03 10:52:36 +00:00
|
|
|
include OrbitCoreLib::AppBackendUtility
|
|
|
|
include OrbitCoreLib::PermissionUtility
|
2013-04-26 03:18:57 +00:00
|
|
|
include OrbitTag::Tagging
|
2012-03-16 03:09:44 +00:00
|
|
|
include AdminHelper
|
2012-08-23 08:05:14 +00:00
|
|
|
include ApplicationHelper
|
2013-06-04 02:53:31 +00:00
|
|
|
|
2013-07-02 08:46:44 +00:00
|
|
|
helper :default_index
|
|
|
|
|
|
|
|
layout "back_end"
|
2013-06-04 02:53:31 +00:00
|
|
|
|
2012-02-15 10:20:44 +00:00
|
|
|
def setup_vars
|
2012-11-20 07:47:07 +00:00
|
|
|
@app_title ||= controller_path.split('/')[1].singularize
|
2012-10-30 09:10:59 +00:00
|
|
|
@module_app ||= ModuleApp.first(conditions: {:key => @app_title} )
|
2013-01-03 02:58:52 +00:00
|
|
|
raise ModuleAppError, 'Can not find ModuleApp' if @module_app.nil?
|
2012-02-15 10:20:44 +00:00
|
|
|
end
|
2012-04-29 15:39:28 +00:00
|
|
|
|
2013-07-02 08:46:44 +00:00
|
|
|
def get_statuses
|
|
|
|
status = []
|
|
|
|
status << 'is_top'
|
|
|
|
status << 'is_hot'
|
|
|
|
status << 'is_hidden' unless is_guest?
|
2013-07-16 03:41:22 +00:00
|
|
|
if @module_app.is_approvable && is_manager?
|
|
|
|
status << 'is_pending'
|
|
|
|
status << 'is_checked'
|
|
|
|
status << 'is_rejected'
|
|
|
|
end
|
2013-07-02 08:46:44 +00:00
|
|
|
status
|
|
|
|
end
|
|
|
|
|
2012-02-15 10:20:44 +00:00
|
|
|
private
|
2012-08-23 08:05:14 +00:00
|
|
|
|
|
|
|
def force_order_for_visitor
|
2013-04-23 10:48:18 +00:00
|
|
|
check_backend_openness
|
2012-10-30 09:10:59 +00:00
|
|
|
setup_vars
|
|
|
|
set_current_user
|
2012-08-23 08:05:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def force_order_for_user
|
|
|
|
setup_vars
|
2013-06-04 02:53:31 +00:00
|
|
|
set_current_user
|
2012-03-20 06:17:28 +00:00
|
|
|
authenticate_user!
|
|
|
|
check_user_can_use
|
|
|
|
end
|
|
|
|
|
2013-06-04 02:53:31 +00:00
|
|
|
def check_user_can_use
|
2012-02-15 10:20:44 +00:00
|
|
|
unless check_permission
|
2012-04-26 08:45:46 +00:00
|
|
|
#redirect_to polymorphic_path(['panel',@app_title,'back_end','public'])
|
2012-05-13 15:48:34 +00:00
|
|
|
redirect_to root_url
|
2012-02-15 10:20:44 +00:00
|
|
|
end
|
|
|
|
end
|
2013-06-04 02:53:31 +00:00
|
|
|
end
|