Merge branch 'ntu' of https://github.com/Rulingcom/orbit into ntu
* 'ntu' of https://github.com/Rulingcom/orbit: fix NTU album module_app data fix object auth. show error message if user try to do object auth in a wrong way.
This commit is contained in:
commit
506770bf33
|
@ -4,7 +4,6 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||||
|
|
||||||
|
|
||||||
def setting
|
def setting
|
||||||
|
|
||||||
@sys_users = User.all(conditions: {admin: false}).includes(:avatar).not_guest_user
|
@sys_users = User.all(conditions: {admin: false}).includes(:avatar).not_guest_user
|
||||||
@ob_auth = ObjectAuth.find params[:object_auth_id]
|
@ob_auth = ObjectAuth.find params[:object_auth_id]
|
||||||
@options_from_collection_for_select_ob_auth = @ob_auth.siblings.collect{|oa| [oa.auth_obj.pp_object,oa.id] }
|
@options_from_collection_for_select_ob_auth = @ob_auth.siblings.collect{|oa| [oa.auth_obj.pp_object,oa.id] }
|
||||||
|
@ -60,6 +59,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||||
|
|
||||||
def force_order
|
def force_order
|
||||||
authenticate_user!
|
authenticate_user!
|
||||||
|
setup_vars
|
||||||
check_if_user_can_do_object_auth
|
check_if_user_can_do_object_auth
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -76,15 +76,25 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_vars
|
def setup_vars
|
||||||
if request.env['HTTP_REFERER'].split('/')[4] == "object_auths"
|
http_referer = request.env['HTTP_REFERER'] || ''
|
||||||
|
if http_referer.split('/')[4] == "object_auths"
|
||||||
@app_key = params[:app_key]
|
@app_key = params[:app_key]
|
||||||
else
|
else
|
||||||
@app_key = request.env['HTTP_REFERER'].split('/')[4]
|
@app_key = http_referer.split('/')[4]
|
||||||
end
|
end
|
||||||
|
|
||||||
#@app_key = request.fullpath.split('/')[1] if(@app_key == "back_end")
|
#@app_key = request.fullpath.split('/')[1] if(@app_key == "back_end")
|
||||||
@app_key.gsub!(/[?].*/,'')
|
if @app_key
|
||||||
@module_app = ModuleApp.first(conditions: {:key => @app_key} )
|
@app_key.gsub!(/[?].*/,'')
|
||||||
|
@module_app = ModuleApp.first(conditions: {:key => @app_key} )
|
||||||
|
if @module_app.nil?
|
||||||
|
raise ObjectAuthError, 'Auth procress failed, module_app not exist '
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise ObjectAuthError, 'Auth procress failed, pls redo your sop'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,8 @@ class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
|
|
||||||
include ParserFrontEnd, ParserBackEnd, ApplicationHelper
|
include ParserFrontEnd, ParserBackEnd, ApplicationHelper
|
||||||
|
include OrbitApp::ErrorHandlers::ObjectAuthErrorHandler
|
||||||
|
rescue_from ObjectAuthError, :with => :render_object_auth_error
|
||||||
|
|
||||||
layout :layout_by_resource
|
layout :layout_by_resource
|
||||||
|
|
||||||
|
@ -10,6 +12,8 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
helper_attr :site_valid_locales
|
helper_attr :site_valid_locales
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def set_current_user
|
def set_current_user
|
||||||
User.current = current_or_guest_user
|
User.current = current_or_guest_user
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
class ObjectAuthError < StandardError
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,11 @@
|
||||||
|
module Admin::PagePartsHelper
|
||||||
|
|
||||||
|
def support_link
|
||||||
|
url_method = @module_app.get_default_widget[:url_method]
|
||||||
|
unless url_method.nil?
|
||||||
|
res = "Link:"
|
||||||
|
res << select_tag( "page_part[widget_field_is_link][]", options_for_select([["NotLink",false],["Link1",url_method]]))
|
||||||
|
res.html_safe
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,14 @@
|
||||||
|
module DefaultWidgetsHelper
|
||||||
|
def get_row_data(row_data,field)
|
||||||
|
field_is_link = (field[0][1]== 'false' ? false : true )
|
||||||
|
field_setting = {:class=>field[0][1],:method=>field[0][0]}
|
||||||
|
if field_is_link
|
||||||
|
field_link = field[0][1].to_s + '_path'
|
||||||
|
binding.pry
|
||||||
|
link = link_to(row_data.send(field_setting[:method]),field_link.send(row_data))
|
||||||
|
content_tag(:span,link,:class=>field_setting[:class])
|
||||||
|
else
|
||||||
|
content_tag(:span,row_data.send(field_setting[:method]),:class=>field_setting[:class])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,16 @@
|
||||||
|
module OrbitApp
|
||||||
|
module ErrorHandlers
|
||||||
|
module ObjectAuthErrorHandler
|
||||||
|
|
||||||
|
|
||||||
|
def render_object_auth_error(exception = nil)
|
||||||
|
default_message = 'This is a render_object_auth_error'
|
||||||
|
meaasge = ''
|
||||||
|
if exception
|
||||||
|
meaasge = default_message + exception.message
|
||||||
|
end
|
||||||
|
render :text=>meaasge
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -328,4 +328,14 @@ namespace :migrate do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
task :clean_object_auth => :environment do
|
||||||
|
ObjectAuth.destroy_all
|
||||||
|
end
|
||||||
|
|
||||||
|
task :correct_gallery_widget => :environment do
|
||||||
|
@module_app = ModuleApp.where(:key=>'gallery').first
|
||||||
|
@module_app.widgets=["widget1"]
|
||||||
|
@module_app.save
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue