Exp with object_auth

This commit is contained in:
Matthew Kaito Juyuan Fu 2012-02-13 17:33:48 +08:00
parent c88e1c8419
commit 17caa7cb1b
17 changed files with 174 additions and 8 deletions

View File

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

View File

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

View File

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

View File

@ -68,7 +68,7 @@ class PrototypeAuth
end
end
def auth_users
def auth_users_before_block_list
if self.all?
User.all.entries
else
@ -83,8 +83,8 @@ class PrototypeAuth
end
end
def auth_users_after_block_list
auth_users - self.blocked_users
def auth_users
auth_users_before_block_list - self.blocked_users
end
# 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>
<%= form_for @object_auth, :url => admin_object_auths_path do |f| %>
<%= 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 :type, :value => params[:type] %>

View File

@ -99,7 +99,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
end
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_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
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

@ -7,6 +7,7 @@ class Bulletin
# field :category_id, :type => Integer
field :title
field :status , :type=> Boolean
# has_one :title_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
# has_one :subtitle_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
# has_one :text_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy

View File

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

View File

@ -6,6 +6,12 @@
<% end %>
<td><%= bulletin_category.display %></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.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 %>

View File

@ -1,12 +1,23 @@
<tr id="<%= dom_id post %>">
<td></td>
<td><% if (fact_check_allow rescue false) %>
<%#= link_to("#{post?? 'Check': 'Checked'}",panel_announcement_back_end_bulletin_path ) %>
<% attribute_type = "post" %>
<% attribute = post %>
<%= link_to t(:ClickToCheck), panel_announcement_back_end_bulletin_path(attribute, :authenticity_token => form_authenticity_token, :bulletin => {:status => true}), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.status ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:ClickToUnCheck), panel_announcement_back_end_bulletin_path(attribute, :authenticity_token => form_authenticity_token, :bulletin => {:status => false}), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.status ? '' : 'none'}", :class => 'switch' %>
<% end %>
</td>
<td><%= post.bulletin_category.i18n_variable[I18n.locale] %></td>
<td><%#= link_to post.title, panel_announcement_front_end_bulletin_path(post) %>
<%= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td>
<td><%= post.postdate %></td>
<td><%= (post.deadline) ? post.deadline : t('bulletin.no_deadline') %></td>
<td>
<%= (post.deadline) ? post.deadline : t('bulletin.no_deadline') %>
</td>
<td>
<%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(post) %> |

View File

@ -8,6 +8,8 @@
<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 -%>

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

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