Add authorization

This commit is contained in:
manson 2014-07-31 20:42:42 +08:00
parent 5608c79d42
commit 38758160fe
3 changed files with 10 additions and 4 deletions

View File

@ -9,8 +9,12 @@ class Admin::PageContentsController < OrbitAdminController
end end
def new def new
if can_edit_or_delete?(nil)
@page = Page.find(params[:page_id]) @page = Page.find(params[:page_id])
@page_content = PageContext.new @page_content = PageContext.new
else
render_401
end
end end
def create def create

View File

@ -13,7 +13,9 @@
<a href="/<%= I18n.locale %><%= page.url %>" target="_blank"><%= page.name %></a> <a href="/<%= I18n.locale %><%= page.url %>" target="_blank"><%= page.name %></a>
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills"> <ul class="nav nav-pills">
<% if can_edit_or_delete?(page) %>
<li><a href="/admin/page_contents/new?page_id=<%= page.id.to_s %>"><%= t(:edit) %></a></li> <li><a href="/admin/page_contents/new?page_id=<%= page.id.to_s %>"><%= t(:edit) %></a></li>
<% end %>
</ul> </ul>
</div> </div>
</td> </td>

View File

@ -9,7 +9,7 @@ module PageContent
side_bar do side_bar do
head_label_i18n 'page_content.page', icon_class: "icons-newspaper" head_label_i18n 'page_content.page', icon_class: "icons-newspaper"
available_for [:admin,:manager,:sub_manager] available_for "users"
active_for_controllers (['admin/page_contents']) active_for_controllers (['admin/page_contents'])
head_link_path "admin_page_contents_path" head_link_path "admin_page_contents_path"
end end