Category authorization

This commit is contained in:
Bernie Chiu 2013-08-22 17:17:27 +08:00 committed by chris
parent 1086037b2b
commit 31ee2d2be2
7 changed files with 32 additions and 12 deletions

View File

@ -0,0 +1,15 @@
module Panel::Dictionary::BackEnd::DictionaryVocabCategorysHelper
include ActionView::Helpers::UrlHelper
def show_anc_cate_permission_link(dictionary_vocab_category)
type = 'submit'
oa = dictionary_vocab_category.get_object_auth_by_title(type)
if oa.nil?
dictionary_vocab_category.object_auths.new(title: type ).save
oa = dictionary_vocab_category.get_object_auth_by_title(type)
end
link_to t(:category_auth),admin_object_auth_ob_auth_path(oa)
end
end

View File

@ -5,10 +5,10 @@ class DictionaryVocabCategory
include OrbitCoreLib::ObjectAuthable include OrbitCoreLib::ObjectAuthable
include OrbitCoreLib::ObjectDisable include OrbitCoreLib::ObjectDisable
include Sunspot::Mongo include Sunspot::Mongo
# include Mongoid::MultiParameterAttributes include Mongoid::MultiParameterAttributes
# APP_NAME = 'Archive' APP_NAME = 'Dictionary'
# ObjectAuthTitlesOptions = %W{submit_new fact_check} ObjectAuthTitlesOptions = %W{submit_new fact_check}
# AfterObjectAuthUrl = '/panel/archive/back_end/archive_file_categorys' AfterObjectAuthUrl = '/panel/dictionary/back_end/dictionary_vocab_categorys'
field :disable, type: Boolean, :default => false field :disable, type: Boolean, :default => false
field :display field :display
@ -36,7 +36,7 @@ class DictionaryVocabCategory
end end
def self.from_id(id) def self.from_id(id)
ArchiveFileCategory.find(id) rescue nil DictionaryVocabCategory.find(id) rescue nil
end end
end end

View File

@ -5,9 +5,10 @@
<ul class="nav nav-pills hide"> <ul class="nav nav-pills hide">
<% if is_admin?%> <% if is_admin?%>
<li><%= link_to t(:edit), edit_panel_dictionary_back_end_dictionary_vocab_category_path(dictionary_vocab_category), :remote => true %></li> <li><%= link_to t(:edit), edit_panel_dictionary_back_end_dictionary_vocab_category_path(dictionary_vocab_category), :remote => true %></li>
<% end %> <% end %>
<%if is_manager? || is_admin? %>
<li><%= show_anc_cate_permission_link(dictionary_vocab_category) %></li>
<% end %>
</ul> </ul>
</div> </div>
</td> </td>

View File

@ -2,10 +2,10 @@
<%= form_for(@dictionary_vocab_category, :remote => true, :url => @url) do |f| %> <%= form_for(@dictionary_vocab_category, :remote => true, :url => @url) do |f| %>
<h2><%= (@dictionary_vocab_category.new_record? ? 'Add' : 'Edit') %></h2> <h2><%= (@dictionary_vocab_category.new_record? ? t(:new, scope: :dictionary) : t(:edit, scope: :dictionary)) %></h2>
<div id="widget-title"> <div id="widget-title">
<%= f.label :key %> <%= f.label t(:key, scope: :dictionary) %>
<%= f.text_field :key %> <%= f.text_field :key %>
</div> </div>
@ -13,7 +13,7 @@
<%= f.fields_for :title_translations do |f| %> <%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<div class="control-group"> <div class="control-group">
<%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> <%= label_tag "name-#{locale}", "#{t(:name)} - #{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls"> <div class="controls">
<%= f.text_field locale, :class =>' input-xxlarge', :value => (@dictionary_vocab_category.title_translations[locale] rescue nil) %> <%= f.text_field locale, :class =>' input-xxlarge', :value => (@dictionary_vocab_category.title_translations[locale] rescue nil) %>
</div> </div>

View File

@ -3,7 +3,7 @@
<table id="dictionary_vocab_categorys" class="table main-list"> <table id="dictionary_vocab_categorys" class="table main-list">
<thead> <thead>
<tr> <tr>
<th class="span1-2"><%= t('dictionary_vocab_category.key') %></th> <th class="span1-2"><%= t(:key, scope: :dictionary) %></th>
<% @site_valid_locales.each do |locale| %> <% @site_valid_locales.each do |locale| %>
<th class="span1-2"><%= I18nVariable.first(:conditions => { :key => locale })[I18n.locale] %></th> <th class="span1-2"><%= I18nVariable.first(:conditions => { :key => locale })[I18n.locale] %></th>
<% end %> <% end %>

View File

@ -21,3 +21,4 @@ en:
definition: Definition definition: Definition
time: Created time time: Created time
ago: ago ago: ago

View File

@ -25,3 +25,6 @@ zh_tw:
definition: 定義 definition: 定義
time: 建立時間 time: 建立時間
ago: ago:
new: 新增
edit: 修改
key: 索引值