From 8751b15385374b8c203d91d49267047810fa04ef Mon Sep 17 00:00:00 2001 From: Spen Date: Wed, 26 Jun 2013 15:35:35 +0800 Subject: [PATCH] archive app add Module Authorization & Category Authorization --- .../archive_file_categorys_controller.rb | 48 +++++++++++++++++-- .../back_end/archive_file_categorys_helper.rb | 15 ++++++ .../_archive_file_category.html.erb | 9 ++-- vendor/built_in_modules/archive/init.rb | 11 +++-- 4 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 vendor/built_in_modules/archive/app/helpers/panel/archive/back_end/archive_file_categorys_helper.rb diff --git a/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_file_categorys_controller.rb b/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_file_categorys_controller.rb index 3d1156a6..d96eaa0d 100644 --- a/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_file_categorys_controller.rb +++ b/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_file_categorys_controller.rb @@ -1,14 +1,18 @@ -class Panel::Archive::BackEnd::ArchiveFileCategorysController < OrbitBackendController - before_filter :for_app_manager,:except => [:index] - include OrbitControllerLib::DivisionForDisable +class Panel::Archive::BackEnd::ArchiveFileCategorysController < OrbitBackendController + include OrbitControllerLib::DivisionForDisable + before_filter :for_app_manager,:except => [:index,:get_categorys_json,:get_archive_files_json] + + before_filter :force_order_for_visitor,:only=>[:index,:get_categorys_json,:get_archive_files_json] + before_filter :force_order_for_user,:except => [:index,:get_categorys_json,:get_archive_files_json] + before_filter :for_app_sub_manager,:except => [:index,:get_categorys_json,:get_archive_files_json] def index @archive_file_categorys = get_categories_for_index("ArchiveFileCategory") # @archive_file_categorys = ArchiveFileCategory.all @archive_file_category = ArchiveFileCategory.new(:display => 'List') - @url = panel_archive_back_end_archive_file_categorys_path + @url = panel_archive_back_end_archive_file_categorys_path respond_to do |format| format.html # index.html.erb @@ -16,6 +20,42 @@ class Panel::Archive::BackEnd::ArchiveFileCategorysController < OrbitBackendCont end end + def get_categorys_json + categorys = ArchiveFileCategory.all + data = Array.new + + categorys.each do |c| + data << { + category: c.title, + link: "#{url_for( :action => "index", + :controller => "panel/archive/front_end/archive_files", + :format => :rss, + :only_path => false, + :inner=>true, + :category_id => c )}" + } + end + + render :json => JSON.pretty_generate(data) + end + + def get_archive_files_json + archive_file = ArchiveFileCategory.find(params[:archive_file_category_id]).archive_files + p archive_file + data = Array.new + + archive_file.each do |b| + + data << { + title: b.title, + link: "http://#{request.host_with_port}#{panel_archive_front_end_archive_file_path(b, :category_id => b.archive_file_category.id)}", + tag: b.sorted_tags.to_a, + } + end + + render :json => JSON.pretty_generate(data) + end + # GET /archive_files/1 # GET /archive_files/1.xml def show diff --git a/vendor/built_in_modules/archive/app/helpers/panel/archive/back_end/archive_file_categorys_helper.rb b/vendor/built_in_modules/archive/app/helpers/panel/archive/back_end/archive_file_categorys_helper.rb new file mode 100644 index 00000000..d5185ff9 --- /dev/null +++ b/vendor/built_in_modules/archive/app/helpers/panel/archive/back_end/archive_file_categorys_helper.rb @@ -0,0 +1,15 @@ +module Panel::Archive::BackEnd::ArchiveFileCategorysHelper +include ActionView::Helpers::UrlHelper + + + def show_anc_cate_permission_link(archive_file_category) + type = 'submit' + oa = archive_file_category.get_object_auth_by_title(type) + if oa.nil? + archive_file_category.object_auths.new(title: type ).save + oa = archive_file_category.get_object_auth_by_title(type) + end + link_to t(:category_auth),admin_object_auth_ob_auth_path(oa) + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_file_categorys/_archive_file_category.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_file_categorys/_archive_file_category.html.erb index 48d26f6c..6bb831a2 100644 --- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_file_categorys/_archive_file_category.html.erb +++ b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_file_categorys/_archive_file_category.html.erb @@ -1,13 +1,16 @@ - <%= archive_file_category.key %>
diff --git a/vendor/built_in_modules/archive/init.rb b/vendor/built_in_modules/archive/init.rb index b2c6ab86..22d806cb 100644 --- a/vendor/built_in_modules/archive/init.rb +++ b/vendor/built_in_modules/archive/init.rb @@ -50,7 +50,7 @@ module Archive head_label_i18n 'archive.archive',:icon_class=>"icons-archive" available_for [:admin,:guest,:manager,:sub_manager] active_for_controllers ({:private=>['archive_file_categorys','archive_files'],:public=>['panel/archive/back_end/tags']}) - # active_for_object_auth ['BulletinCategory'] + active_for_object_auth ['ArchiveFileCategory'] head_link_path "panel_archive_back_end_archive_files_path" @@ -64,7 +64,7 @@ module Archive :link_path=>"new_panel_archive_back_end_archive_file_path" , :priority=>2, :active_for_action=>{:archive_files=>:new}, - :available_for => [:admin] + :available_for => [:sub_manager] context_link 'categories', :link_path=>"panel_archive_back_end_archive_file_categorys_path" , @@ -76,7 +76,12 @@ module Archive :link_path=>"admin_tags_path(:module_app_id => ModuleApp.first(conditions: {title: 'Archive'}))" , :priority=>4, # :active_for_action=>{:bulletin_categorys=>:index}, - :available_for => [:admin] + :available_for => [:manager] + + context_link 'module_authorization', + :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'Archive'}))", + :priority=>6, + :active_for_app_auth => 'Archive' end end