Integrate App & Object Auth to announcement with i18n variables. Also changed Role and SubRole i18n var. Checked with Allen

This commit is contained in:
Matthew K. Fu JuYuan 2012-04-27 18:38:21 +08:00 committed by Christophe Vilayphiou
parent 382932036d
commit a46a8898d7
15 changed files with 86 additions and 39 deletions

View File

@ -2,7 +2,7 @@ class Admin::ModuleAppsController < ApplicationController
before_filter :user_has_manager_privilege?, :only => [ :assign_manager, :remove_manager ] before_filter :user_has_manager_privilege?, :only => [ :assign_manager, :remove_manager ]
before_filter :user_has_sub_manager_privilege?, :only => [ :assign_sub_manager, :remove_sub_manager ] before_filter :user_has_sub_manager_privilege?, :only => [ :assign_sub_manager, :remove_sub_manager ]
layout "admin" layout "new_admin"
def index def index
@module_apps = ModuleApp.all.entries @module_apps = ModuleApp.all.entries

View File

@ -1,6 +1,6 @@
class Admin::ObjectAuthsController < ApplicationController class Admin::ObjectAuthsController < ApplicationController
include OrbitCoreLib::PermissionUnility include OrbitCoreLib::PermissionUnility
layout "admin" layout "new_admin"
before_filter :force_order before_filter :force_order
# before_filter :is_admin? ,:only => :index # before_filter :is_admin? ,:only => :index

View File

@ -14,6 +14,7 @@ module Admin::ModuleAppHelper
end end
def get_auth_by(manager_obj) def get_auth_by(manager_obj)
"-AuthBy: " +( manager_obj.rule_creator==current_user ? t('me') : manager_obj.rule_creator.name) showing_name = manager_obj.rule_creator==current_user ? t('me') : manager_obj.rule_creator.name
t("admin.user_role.auth.auth_by",:user_display_name => showing_name)
end end
end end

View File

@ -1,21 +1,21 @@
<div id="open_for_all_user"> <div id="open_for_all_user">
<h1>All User</h1> <h1><%= t("admin.user_role.auth.all_member") %></h1>
<%= form_tag(submit_url) do %> <%= form_tag(submit_url) do %>
<%= check_box_tag 'auth_all',true,(auth.all rescue true) %><%= submit_tag 'Add Role' %><br/> <%= check_box_tag 'auth_all',true,(auth.all rescue true) %><%= submit_tag t("admin.user_role.auth.all_member") %><br/>
<% end %> <% end %>
</div> </div>
<div id="user_role_management"> <div id="user_role_management">
<h1>User Role</h1> <h1><%= t("admin.user_role.auth.user") %></h1>
<%= form_tag(submit_url) do %> <%= form_tag(submit_url) do %>
<%= collection_select(:new,:role, Role.all, :id, :key, :prompt => true) %> <%= collection_select(:new,:role, Role.all, :id, :key, :prompt => true) %>
<%= submit_tag 'Add Role' %><br/> <%= submit_tag t("admin.user_role.auth.by_role") %><br/>
<%= collection_select(:new,:sub_role, SubRole.all, :id, :key, :prompt => true) %> <%= collection_select(:new,:sub_role, SubRole.all, :id, :key, :prompt => true) %>
<%= submit_tag 'Add SubRole' %><br/> <%= submit_tag t("admin.user_role.auth.by_sub_role") %><br/>
<%= collection_select(:new,:privilege_user, User.all, :id, :name, :prompt => true) %> <%= collection_select(:new,:privilege_user, User.all, :id, :name, :prompt => true) %>
<%= submit_tag 'Add PrivilegeList' %><br/> <%= submit_tag t("admin.user_role.auth.add_to_privilege_list") %><br/>
<%= collection_select(:new,:blocked_user, User.all, :id, :name, :prompt => true) %> <%= collection_select(:new,:blocked_user, User.all, :id, :name, :prompt => true) %>
<%= submit_tag 'Add BlockedList' %><br/> <%= submit_tag t("admin.user_role.auth.add_to_block_list") %><br/>
<% end %> <% end %>
<% unless auth.nil? %> <% unless auth.nil? %>
<% auth.roles.each do |role| %> <% auth.roles.each do |role| %>

View File

@ -1,37 +1,30 @@
<% content_for :secondary do %> <% content_for :secondary do %>
<% end %> <% end %>
<!-- Remove if CSS done-->
<br />
<br />
<br />
<!-- Remove if CSS done-->
<h3><%= @module_app.title%></h3> <h3><%= @module_app.title%></h3>
<div id="manager_management"> <div id="manager_management">
<h1>Manager</h1>
<dl id="manager"> <dl id="manager">
<dt>Manager</ht> <dt><%= t("admin.user_role.auth.manager") %></ht>
<% @module_app.managers.each do |manager| %> <% @module_app.managers.each do |manager| %>
<dd><%= manager.user.name %> <%= get_auth_by(manager) %> <%= link_to '[X]',remove_manager_admin_module_app_path(@module_app,manager),:method => :delete if if_permit_to_delete(:manager) && manager.user != current_user %> </dd> <dd><%= manager.user.name %> <%= get_auth_by(manager) %> <%= link_to '[X]',remove_manager_admin_module_app_path(@module_app,manager),:method => :delete if if_permit_to_delete(:manager) && manager.user != current_user %> </dd>
<% end %> <% end %>
<dd>Add: <dd>
<%= form_tag(assign_manager_admin_module_app_path) do %> <%= form_tag(assign_manager_admin_module_app_path) do %>
<%= collection_select(:manager,:id, User.all, :id, :name, :prompt => true,:disabled => !if_permit_to_assign(:manager))%> <%= collection_select(:manager,:id, User.all, :id, :name, :prompt => true,:disabled => !if_permit_to_assign(:manager))%>
<%= submit_tag 'Add Manager' %> <%= submit_tag t("admin.user_role.auth.add_manager") %>
<% end %> <% end %>
</dd> </dd>
</dl> </dl>
<dl id="sub_manager"> <dl id="sub_manager">
<dt>Sub Manager</ht> <dt><%= t("admin.user_role.auth.sub_manager") %></ht>
<% @module_app.sub_managers.each do |manager| %> <% @module_app.sub_managers.each do |manager| %>
<dd><%= manager.user.name %> -AuthBy:<%= manager.rule_creator.name %> <%= link_to '[X]',remove_sub_manager_admin_module_app_path(@module_app,manager),:method => :delete if if_permit_to_delete(:sub_manager) && manager.user != current_user %> </dd> <dd><%= manager.user.name %> <%= get_auth_by(manager) %><%= link_to '[X]',remove_sub_manager_admin_module_app_path(@module_app,manager),:method => :delete if if_permit_to_delete(:sub_manager) && manager.user != current_user %> </dd>
<% end %> <% end %>
<dd>Add: <dd>
<%= form_tag(assign_sub_manager_admin_module_app_path) do %> <%= form_tag(assign_sub_manager_admin_module_app_path) do %>
<%= collection_select(:sub_manager,:id, User.all, :id, :name, :prompt => true,:disabled => !if_permit_to_assign(:sub_manager))%> <%= collection_select(:sub_manager,:id, User.all, :id, :name, :prompt => true,:disabled => !if_permit_to_assign(:sub_manager))%>
<%= submit_tag 'Add Sub Manager' %> <%= submit_tag t("admin.user_role.auth.add_sub_manager") %>
<% end %> <% end %>
</dd> </dd>
</dl> </dl>

View File

@ -1,11 +1,6 @@
<% content_for :secondary do %> <% content_for :secondary do %>
<% end %> <% end %>
<!-- Remove if CSS done-->
<br />
<br />
<br />
<!-- Remove if CSS done-->
<h3><%= @object_auth.title %></h3> <h3><%= @object_auth.title %></h3>
<%= render :partial => "admin/components/user_role_management", :locals => { <%= render :partial => "admin/components/user_role_management", :locals => {

View File

@ -2,7 +2,7 @@
<%#= link_to content_tag(:i, nil, :class => 'icons-purchase') + t('admin.purchase'), admin_purchases_path %> <%#= link_to content_tag(:i, nil, :class => 'icons-purchase') + t('admin.purchase'), admin_purchases_path %>
<%# end -%> <%# end -%>
<%= content_tag :li, :class => active_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals') do -%> <%= content_tag :li, :class => active_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys','module_apps', 'approvals') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %> <%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals')) do -%> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals')) do -%>
<%= content_tag :li, link_to(t('announcement.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %> <%= content_tag :li, link_to(t('announcement.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %>
@ -10,6 +10,8 @@
<%= content_tag :li, link_to(t('announcement.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %> <%= content_tag :li, link_to(t('announcement.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %>
<%= content_tag :li, link_to(t('announcement.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('/panel/announcement/back_end/tags', 'index') %> <%= content_tag :li, link_to(t('announcement.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('/panel/announcement/back_end/tags', 'index') %>
<%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_announcement_back_end_approval_setting_path), :class => active_for_action('approvals', 'setting') if (is_manager? rescue nil) %> <%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_announcement_back_end_approval_setting_path), :class => active_for_action('approvals', 'setting') if (is_manager? rescue nil) %>
<%= content_tag :li, link_to(t('admin.module.authorization'),edit_admin_module_app_path(ModuleApp.first(conditions: {title: "Announcement"}))), :class => active_for_action('module_apps', 'edit') if (is_admin? rescue nil) %>
<% end -%> <% end -%>
<% end -%> <% end -%>

View File

@ -149,6 +149,8 @@ en:
list_infos: User information list list_infos: User information list
list_roles: User roles list list_roles: User roles list
member: Member member: Member
module:
authorization: Module Authorization
move_down: Move down move_down: Move down
move_up: Move up move_up: Move up
multilingual: Multilingual multilingual: Multilingual
@ -201,6 +203,20 @@ en:
upload_design: Upload design upload_design: Upload design
url: URL url: URL
user: User user: User
user_role:
auth:
all_member: All Member
manager: Manager
sub_mamanger: SubManager
by_role: By Role
by_sub_role: By SubRole
block_list: Block List
privilege_list: Privilege List
add_manager: Add Manager
add_sub_manager: Add SubManager
add_to_block_list: Add to block List
add_to_privilege_list: Add to privilege List
auth_by: -AuthBy %{user_display_name}
info: User information info: User information
panel: User panel panel: User panel
role: User role role: User role

View File

@ -122,7 +122,7 @@ zh_tw:
editing_page: 編輯頁面 editing_page: 編輯頁面
editing_snippet: 編輯片段 editing_snippet: 編輯片段
editing_info: 編輯用戶資料 editing_info: 編輯用戶資料
editing_role: 編輯用戶角色 editing_role: 編輯用戶身份
email: Email email: Email
enable_language: 啟用語言 enable_language: 啟用語言
file_name: 檔名 file_name: 檔名
@ -147,8 +147,10 @@ zh_tw:
list_snippets: 斷片列表 list_snippets: 斷片列表
list_users: 使用列表 list_users: 使用列表
list_infos: 用戶資料列表 list_infos: 用戶資料列表
list_roles: 用戶角色列表 list_roles: 用戶身份列表
member: 會員 member: 會員
module:
authorization: 模組授權
move_down: 往下移 move_down: 往下移
move_up: 往上移 move_up: 往上移
multilingual: 多種語言 multilingual: 多種語言
@ -167,7 +169,7 @@ zh_tw:
new_snippet: 新增片段 new_snippet: 新增片段
new_user: 新增使用 new_user: 新增使用
new_info: 新增用戶資料 new_info: 新增用戶資料
new_role: 新增用戶角色 new_role: 新增用戶身份
non_multilingual: 非多種語言 non_multilingual: 非多種語言
options: 選項 options: 選項
orig_upload_file: 原上傳檔名 orig_upload_file: 原上傳檔名
@ -175,8 +177,8 @@ zh_tw:
position: 位置 position: 位置
published?: 發布? published?: 發布?
purchase: 購買 purchase: 購買
role: 角色 role: 身份
roles: 角色 roles: 身份
site_settings: 基本設定 site_settings: 基本設定
setup_member: 成員設置 setup_member: 成員設置
setup_translations: 語系設定 setup_translations: 語系設定
@ -201,9 +203,23 @@ zh_tw:
upload_design: 上傳設計 upload_design: 上傳設計
url: URL url: URL
user: 用戶 user: 用戶
user_role:
auth:
all_member: 所有會員
manager: 管理員
sub_manager: 次管理員
by_role: 根據身份
by_sub_role: 根據次身份
block_list: 封鎖名單
add_manager: 增加到管理員
add_sub_manager: 增加到次管理員
add_to_block_list: 封鎖名單
add_to_privilege_list: 特許名單
auth_by: -由%{user_display_name}授權
user: 使用會員
info: 用戶資料 info: 用戶資料
panel: 用戶面板 panel: 用戶面板
role: 用戶角色 role: 用戶身份
panel: panel:

View File

@ -19,6 +19,10 @@ module OrbitCoreLib
end end
def get_object_auth_by_title(title)
self.object_auths.where({title: title }).first
end
def authed_users(title=nil) def authed_users(title=nil)
users = [] users = []
users = case title users = case title
@ -33,7 +37,7 @@ module OrbitCoreLib
[] []
end end
else else
self.object_auths.where(title: title).first.auth_users rescue [] get_object_auth_by_title(title).auth_users rescue []
end end
users users
end end

View File

@ -0,0 +1,14 @@
module Panel::Announcement::BackEnd::BulletinCategorysHelper
include ActionView::Helpers::UrlHelper
def show_submit_permission_link(bulletin_category)
oa = bulletin_category.get_object_auth_by_title('submit')
if oa.nil?
bulletin_category.object_auths.new(title: 'submit' ).save
oa = bulletin_category.get_object_auth_by_title('submit')
end
link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa)
end
end

View File

@ -7,7 +7,7 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="clear"> <div class="clear">
<% bulletin_category.object_auths.where(title: 'fact_check').first.auth_users.each do |user| %> <% bulletin_category.get_object_auth_by_title('fact_check').auth_users.each do |user| %>
<div class="checkbox clear checked"> <div class="checkbox clear checked">
<div class='member-avatar'> <div class='member-avatar'>
<% if user.avatar? %> <% if user.avatar? %>

View File

@ -5,7 +5,10 @@
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills hide"> <ul class="nav nav-pills hide">
<li><%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %></li> <li><%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %></li>
<li><%= show_submit_permission_link(bulletin_category) %></li>
<li><%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li> <li><%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
</ul> </ul>
</div> </div>
</td> </td>

View File

@ -78,6 +78,7 @@ en:
approval_pass: 'Pass' approval_pass: 'Pass'
approval_setting_window_title: 'Unit' approval_setting_window_title: 'Unit'
approval_user_list: 'Approval Users' approval_user_list: 'Approval Users'
cate_auth: Category Authorization
# admin: # admin:
# action: Action # action: Action
# add_language: Add language # add_language: Add language

View File

@ -60,6 +60,8 @@ zh_tw:
approval_not_pass_reason: '不通過原因' approval_not_pass_reason: '不通過原因'
approval_setting_window_title: '單位' approval_setting_window_title: '單位'
approval_user_list: '審核者' approval_user_list: '審核者'
cate_auth: '分類授權'
bulletin: bulletin:
last_modified: 最後修改於 last_modified: 最後修改於
tags: 標籤 tags: 標籤