added access levels to this module

This commit is contained in:
Harry Bomrah 2014-07-31 17:12:13 +08:00
parent bc7b77f5c8
commit 9fc4bffff3
3 changed files with 18 additions and 13 deletions

View File

@ -23,8 +23,7 @@ class Admin::AnnouncementsController < OrbitAdminController
end end
def new def new
@tags =@module_app.tags @tags = @module_app.tags
@categories = @module_app.categories.enabled
@statuses = [] @statuses = []
@bulletin = Bulletin.new @bulletin = Bulletin.new
@bulletin.email_sentdate = Time.now @bulletin.email_sentdate = Time.now
@ -46,10 +45,14 @@ class Admin::AnnouncementsController < OrbitAdminController
end end
def edit def edit
@tags =@module_app.tags if can_edit_or_delete?(@bulletin)
@categories = @module_app.categories.enabled @tags = @module_app.tags
@statuses = [] @categories = @module_app.categories.enabled
@bulletin.email_sentdate = Time.now if @bulletin.email_sent == false @statuses = []
@bulletin.email_sentdate = Time.now if @bulletin.email_sent == false
else
render_401
end
end end
def update def update

View File

@ -19,9 +19,11 @@
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title %></a> <a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title %></a>
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills"> <ul class="nav nav-pills">
<li><a href="/admin/announcements/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
<li><a href="#" class="detail-row" onclick="$('#<%= "#{b.id.to_s}-detail" %>').slideToggle(300); return false;"><%= t(:detail) %></a></li> <li><a href="#" class="detail-row" onclick="$('#<%= "#{b.id.to_s}-detail" %>').slideToggle(300); return false;"><%= t(:detail) %></a></li>
<li><a href="#" class="delete text-error" rel="/admin/announcements/<%=b.id.to_s%>"><%= t(:delete_) %></a></li> <% if can_edit_or_delete?(b) %>
<li><a href="/admin/announcements/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
<li><a href="#" class="delete text-error" rel="/admin/announcements/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
<% end %>
</ul> </ul>
</div> </div>
</td> </td>

View File

@ -14,7 +14,7 @@ module Announcement
side_bar do side_bar do
head_label_i18n 'announcement.announcement', icon_class: "icons-megaphone" head_label_i18n 'announcement.announcement', icon_class: "icons-megaphone"
available_for [:admin,:manager,:sub_manager] available_for "users"
active_for_controllers (['admin/announcements']) active_for_controllers (['admin/announcements'])
head_link_path "admin_announcements_path" head_link_path "admin_announcements_path"
@ -22,26 +22,26 @@ module Announcement
:link_path=>"admin_announcements_path" , :link_path=>"admin_announcements_path" ,
:priority=>1, :priority=>1,
:active_for_action=>{'admin/announcements'=>'index'}, :active_for_action=>{'admin/announcements'=>'index'},
:available_for => [:all] :available_for => 'users'
context_link 'new_', context_link 'new_',
:link_path=>"new_admin_announcement_path" , :link_path=>"new_admin_announcement_path" ,
:priority=>2, :priority=>2,
:active_for_action=>{'admin/announcements'=>'new'}, :active_for_action=>{'admin/announcements'=>'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" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'announcement').id}", :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'announcement').id}",
:priority=>3, :priority=>3,
:active_for_action=>{'admin/announcements'=>'categories'}, :active_for_action=>{'admin/announcements'=>'categories'},
:active_for_category => 'Announcement', :active_for_category => 'Announcement',
: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=>'announcement').id}", :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'announcement').id}",
:priority=>4, :priority=>4,
:active_for_action=>{'admin/announcements'=>'tags'}, :active_for_action=>{'admin/announcements'=>'tags'},
:active_for_tag => 'Announcement', :active_for_tag => 'Announcement',
:available_for => [:manager] :available_for => 'managers'
end end
end end