Exp with object_auth

This commit is contained in:
Matthew Kaito Juyuan Fu 2012-02-13 17:33:48 +08:00 committed by Christophe Vilayphiou
parent 6b2aeadde6
commit 3bcd7ea349
17 changed files with 161 additions and 10 deletions

View File

@ -66,6 +66,8 @@ class Admin::AppAuthsController < ApplicationController
@module_app = ModuleApp.find(params[:id]) @module_app = ModuleApp.find(params[:id])
end end
def show
@module_app = ModuleApp.find(params[:id])
end
end end

View File

@ -21,6 +21,10 @@ class Admin::ModuleAppsController < ApplicationController
@module_app = ModuleApp.find(params[:id]) @module_app = ModuleApp.find(params[:id])
end end
def show
@module_app = ModuleApp.find(params[:id])
end
def update def update
@module_app = ModuleApp.find(params[:id]) @module_app = ModuleApp.find(params[:id])

View File

@ -14,6 +14,7 @@ class Admin::ObjectAuthsController < ApplicationController
def new def new
obj = eval(params[:type]).find params[:obj_id] obj = eval(params[:type]).find params[:obj_id]
@object_auth=obj.object_auths.build @object_auth=obj.object_auths.build
@object_auth_title_option = eval(params[:type]+"::ObjectAuthTitlesOptions")
respond_to do |format| respond_to do |format|
format.html # new.html.erb format.html # new.html.erb
format.xml { render :xml => @post } format.xml { render :xml => @post }

View File

@ -68,7 +68,7 @@ class PrototypeAuth
end end
end end
def auth_users def auth_users_before_block_list
if self.all? if self.all?
User.all.entries User.all.entries
else else
@ -83,8 +83,8 @@ class PrototypeAuth
end end
end end
def auth_users_after_block_list def auth_users
auth_users - self.blocked_users auth_users_before_block_list - self.blocked_users
end end
# protected # protected

View File

@ -0,0 +1 @@
<%= f.select :module_app_id, @apps.collect { |t| [t.title.capitalize, t.id] }, {:include_blank => true} ,{:rel => admin_module_apps_path } %>

View File

@ -0,0 +1,37 @@
<br /><br /><br /><br />
<%=@module_app.key %><br />
<%=@module_app.title %><br />
<%=@module_app.version %><br />
<%=@module_app.organization %><br />
<%=@module_app.author %><br />
<%=@module_app.intro %><br />
<%=@module_app.update_info %><br />
<%=@module_app.create_date %><br />
<%=@module_app.enable_frontend%><br />
<%=@module_app.app_pages%><br />
<%=@module_app.widgets%><br />
Mangers:
<ul>
<% @module_app.managers.each do |manager|%>
<li><%= manager.user.name %></li>
<%end%>
</ul>
SubManagers:
<div>
<% @module_app.sub_managers.each do |manager|%>
<%= manager.user.name %>
<%end%>
</div>
<br />
All User?:<%= @module_app.app_auth.all %><br />
Blocked Users:<%= @module_app.app_auth.blocked_users.collect{|t| t.name} %><br />
Privilege Users:<%= @module_app.app_auth.privilege_users.collect{|t| t.name}%><br />
User Roles:<%= @module_app.app_auth.roles.collect{|t| t.key} %><br />
User Sub Roles:<%= @module_app.app_auth.sub_roles.collect{|t| t.key} %><br />
Available users after calculation:
<%= @module_app.app_auth.auth_users.collect{|user| user.name}.join(',') %>

View File

@ -12,7 +12,8 @@
<h1><%= t('object_auth.new_object_auth') %></h1> <h1><%= t('object_auth.new_object_auth') %></h1>
<%= form_for @object_auth, :url => admin_object_auths_path do |f| %> <%= form_for @object_auth, :url => admin_object_auths_path do |f| %>
<%= f.label :title %> <%= f.label :title %>
<%= f.text_field :title, :class => 'text' %> <%= f.select :title,@object_auth_title_option %>
<%= f.hidden_field :obj_id, :value => params[:obj_id] %> <%= f.hidden_field :obj_id, :value => params[:obj_id] %>
<%= f.hidden_field :type, :value => params[:type] %> <%= f.hidden_field :type, :value => params[:type] %>

View File

@ -105,7 +105,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
end end
respond_to do |format| respond_to do |format|
if @bulletin.update_attributes(params[:bulletin]) if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save
# format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) } # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) }
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) } format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
format.js { render 'toggle_enable' } format.js { render 'toggle_enable' }

View File

@ -0,0 +1,29 @@
class Panel::Announcement::BackEnd::FactChecksController < ApplicationController
layout 'admin'
def index
@bulletin_categorys_preview = BulletinCategory.authed_for_user(current_user,'preview')
@bulletin_categorys_check = BulletinCategory.authed_for_user(current_user,'check')
end
def new
end
def create
end
def update
end
def edit
end
def destroy
end
end

View File

@ -4,7 +4,7 @@ class Bulletin
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes include Mongoid::MultiParameterAttributes
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :text, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_one :text, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy

View File

@ -3,6 +3,10 @@
class BulletinCategory class BulletinCategory
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include OrbitCoreLib::ObjectAuthable
ObjectAuthTitlesOptions = %W{preview fact_check}
# include Mongoid::MultiParameterAttributes # include Mongoid::MultiParameterAttributes
PAYMENT_TYPES = [ "List", "Picture" ] PAYMENT_TYPES = [ "List", "Picture" ]

View File

@ -6,6 +6,12 @@
<% end %> <% end %>
<td><%= bulletin_category.display %></td> <td><%= bulletin_category.display %></td>
<td> <td>
<%= link_to t('blog.new_auth'), init_admin_object_auths_path("BulletinCategory",bulletin_category) %> <br/ >
<% bulletin_category.object_auths.each do |obj_auth| %>
<%= link_to obj_auth.title,edit_admin_object_auth_url(obj_auth) %><br />
<% end %>
</td>
<td>
<%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %> | <%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %> |
<%= link_to t('bulletin_category.quick_edit'), panel_announcement_back_end_bulletin_category_quick_edit_path(bulletin_category), :remote => true %> | <%= link_to t('bulletin_category.quick_edit'), panel_announcement_back_end_bulletin_category_quick_edit_path(bulletin_category), :remote => true %> |
<%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %> <%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %>

View File

@ -36,4 +36,4 @@
</thead> </thead>
<tbody class="sort-holder"> <tbody class="sort-holder">
<%= render :partial => 'bulletin', :collection => @bulletins %> <%= render :partial => 'bulletin', :collection => @bulletins %>
</tbody> </tbody>

View File

@ -6,4 +6,3 @@
<div class="form-actions"> <div class="form-actions">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %> <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %>
</div> </div>

View File

@ -0,0 +1,15 @@
<h1><%= bulletin_category.key %></h1>
<table>
<tr>
<th><%= t('bulletin.status') %></th>
<th><%= t('bulletin.category') %></th>
<th><%= t('bulletin.title') %></th>
<th><%= t('bulletin.postdate') %></th>
<th><%= t('bulletin.deadline') %></th>
<th><%= t('bulletin.action') %></th>
</tr>
<% bulletin_category.bulletins.each do |post| %>
<%= render :partial => 'panel/announcement/back_end/bulletins/bulletins', :locals => {:post => post,:fact_check_allow=>true} %>
<% end %>
</table>

View File

@ -0,0 +1,51 @@
<% content_for :secondary do %>
<br />
<br />
<br />
<br />
<br />
<ul class="list">
<li><%= link_to t('bulletin.new_announcement'), new_panel_announcement_back_end_bulletin_path %></li>
<li><%= link_to t('bulletin.announcement_list'), panel_announcement_back_end_bulletins_path %></li>
<li><%= link_to t('bulletin.new_announcement_class'), panel_announcement_back_end_bulletin_categorys_path %></li>
<li><%= link_to t('bulletin.my_announcement_fact_check'), panel_announcement_back_end_fact_checks_path %></li>
</ul>
<% end -%>
<%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<fieldset><legend><%= t('bulletin.search') %></legend>
<%= form_for :bulletin, :action => 'search', :method => 'get', :url => panel_announcement_back_end_bulletins_path do |f| %>
<%#= f.select :bulletin_category_id, @bulletin_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ] },{ :include_blank => t('bulletin.select') }%>
Category <%#= select_tag "category_id", options_for_select(@bulletin_categorys.collect{|t| [t.i18n_variable[I18n.locale], t.id]}), :prompt => t('bulletin.select') %>
KeyWord <%#= text_field_tag :search, params[:search], :id => 'search_field' %>
<%= submit_tag "Search", :name => nil %>
<% end %>
</fieldset>
<br />
<br />
<h1><%= t('bulletin.list_announcement') %></h1>
<%= render :partial => "list_table", :collection => @bulletin_categorys_preview,:as => :bulletin_category%>
<%= render :partial => "list_table", :collection => @bulletin_categorys_check,:as => :bulletin_category%>
<br />

View File

@ -2,6 +2,7 @@ Rails.application.routes.draw do
namespace :panel do namespace :panel do
namespace :announcement do namespace :announcement do
namespace :back_end do namespace :back_end do
resources :fact_checks
root :to => "bulletins#index" root :to => "bulletins#index"
resources :bulletins resources :bulletins
resources :bulletin_categorys, :controller => 'bulletin_categorys' do resources :bulletin_categorys, :controller => 'bulletin_categorys' do
@ -21,4 +22,4 @@ Rails.application.routes.draw do
end end
end end
end end
end end