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
def edit
if can_edit_or_delete?(@link)
@tags =@module_app.tags
@categories = @module_app.categories.enabled
@statuses = []
else
render_401
end
end
def update

View File

@ -15,8 +15,10 @@
<a href="<%= link.url %>" target="_blank"><%= link.title %></a>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(link) %>
<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>
</div>
</td>

View File

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