archive app add Module Authorization & Category Authorization

This commit is contained in:
Spen 2013-06-26 15:35:35 +08:00
parent 6a40a9555a
commit 8751b15385
4 changed files with 73 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -1,13 +1,16 @@
<tr id="<%= dom_id archive_file_category %>" class="with_action">
<td>
<%= archive_file_category.key %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('archive_file_category.edit'), edit_panel_archive_back_end_archive_file_category_path(archive_file_category), :remote => true %></li>
<% if is_admin?%>
<li><%= link_to t(:edit), edit_panel_archive_back_end_archive_file_category_path(archive_file_category), :remote => true %></li>
<li><%= link_to show_toggle_archive_btn(archive_file_category) , panel_archive_back_end_archive_file_category_path(archive_file_category), :confirm => t(:sure?), :method => :delete, :remote => true,:class=> "archive_toggle" %></li>
<!-- <li><%#= link_to t('archive_file_category.delete'), panel_archive_back_end_archive_file_category_path(archive_file_category), :confirm => t('sure?'), :method => :delete, :remote => true %></li> -->
<% end %>
<%if is_manager? || is_admin? %>
<li><%= show_anc_cate_permission_link(archive_file_category) %></li>
<% end %>
</ul>
</div>
</td>

View File

@ -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