Add authorization

This commit is contained in:
manson 2014-07-31 20:43:16 +08:00
parent 1d151fb59a
commit 8421368e77
3 changed files with 16 additions and 10 deletions

View File

@ -31,9 +31,13 @@ class Admin::WebResourcesController < OrbitAdminController
end end
def edit def edit
@tags =@module_app.tags if can_edit_or_delete?(@link)
@categories = @module_app.categories.enabled @tags =@module_app.tags
@statuses = [] @categories = @module_app.categories.enabled
@statuses = []
else
render_401
end
end end
def update def update

View File

@ -15,8 +15,10 @@
<a href="<%= link.url %>" target="_blank"><%= link.title %></a> <a href="<%= link.url %>" target="_blank"><%= link.title %></a>
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills"> <ul class="nav nav-pills">
<li><a href="/admin/web_resources/<%=link.id.to_s%>/edit"><%= t(:edit) %></a></li> <% if can_edit_or_delete?(link) %>
<li><a href="#" class="delete text-error" rel="/admin/web_resources/<%=link.id.to_s%>"><%= t(:delete_) %></a></li> <li><a href="/admin/web_resources/<%=link.id.to_s%>/edit"><%= t(:edit) %></a></li>
<li><a href="#" class="delete text-error" rel="/admin/web_resources/<%=link.id.to_s%>"><%= t(:delete_) %></a></li>
<% end %>
</ul> </ul>
</div> </div>
</td> </td>

View File

@ -13,7 +13,7 @@ module WebResource
data_count 1..10 data_count 1..10
side_bar do side_bar do
head_label_i18n 'web_resource',:icon_class=>"icons-link" head_label_i18n 'web_resource',:icon_class=>"icons-link"
available_for [:admin,:manager,:sub_manager] available_for "users"
active_for_controllers (['admin/web_resources']) active_for_controllers (['admin/web_resources'])
head_link_path "admin_web_resources_path" head_link_path "admin_web_resources_path"
@ -21,13 +21,13 @@ module WebResource
:link_path=>"admin_web_resources_path" , :link_path=>"admin_web_resources_path" ,
:priority=>1, :priority=>1,
:active_for_action=>{'admin/web_resources'=>'index'}, :active_for_action=>{'admin/web_resources'=>'index'},
:available_for => [:all] :available_for => 'users'
context_link 'new_', context_link 'new_',
:link_path=>"new_admin_web_resource_path" , :link_path=>"new_admin_web_resource_path" ,
:priority=>2, :priority=>2,
:active_for_action=>{'admin/web_resources'=>'new'}, :active_for_action=>{'admin/web_resources'=>'new'},
:available_for => [:sub_manager] :available_for => 'sub_managers'
context_link 'categories', context_link 'categories',
:link_path=>"admin_module_app_categories_path" , :link_path=>"admin_module_app_categories_path" ,
@ -35,14 +35,14 @@ module WebResource
:priority=>3, :priority=>3,
:active_for_action=>{'admin/web_resources.'=>'categories'}, :active_for_action=>{'admin/web_resources.'=>'categories'},
:active_for_category => 'WebResource', :active_for_category => 'WebResource',
:available_for => [:manager] :available_for => 'managers'
context_link 'tags', context_link 'tags',
:link_path=>"admin_module_app_tags_path" , :link_path=>"admin_module_app_tags_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'web_resource').id}", :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'web_resource').id}",
:priority=>4, :priority=>4,
:active_for_action=>{'admin/web_resources'=>'tags'}, :active_for_action=>{'admin/web_resources'=>'tags'},
:active_for_tag => 'WebResource', :active_for_tag => 'WebResource',
:available_for => [:manager] :available_for => 'managers'
end end
end end
end end