change view and action for announcement ,Lin checked. Also add validation for object_auth make sure for each object,the object will be unique for each action.

This commit is contained in:
Matt Fu 2012-02-17 17:50:23 +08:00
parent 9305c2045c
commit 26cd6951db
17 changed files with 76 additions and 78 deletions

View File

@ -100,7 +100,7 @@ class Admin::ModuleAppsController < ApplicationController
end end
#user is not permited to do that #user is not permited to do that
flash[:notice] = t('admin.app_auth.operation_not_permitted') flash[:notice] = t('admin.app_auth.operation_not_permitted')
redirect_to :action => "edit" # [TODO] maybe need to redirect to some other page render :nothing => true, :status => 403
end end
@ -112,7 +112,7 @@ class Admin::ModuleAppsController < ApplicationController
end end
#user is not permited to do that #user is not permited to do that
flash[:notice] = t('admin.app_auth.operation_not_permitted') flash[:notice] = t('admin.app_auth.operation_not_permitted')
redirect_to :action => "edit" # [TODO] maybe need to redirect to some other page render :nothing => true, :status => 403
end end
end end

View File

@ -27,8 +27,13 @@ class Admin::ObjectAuthsController < ApplicationController
def create def create
obj = eval(params[:object_auth][:type]).find params[:object_auth][:obj_id] obj = eval(params[:object_auth][:type]).find params[:object_auth][:obj_id]
@object_auth=obj.object_auths.create :title=> params[:object_auth][:title] @object_auth=obj.object_auths.build :title=> params[:object_auth][:title]
redirect_to edit_admin_object_auth_path(@object_auth) if @object_auth.save
redirect_to edit_admin_object_auth_path(@object_auth)
else
flash[:error] = t('admin.object.a_object_must_have_only_one_object_auth_profile_for_each_action')
redirect_to (:back)
end
end end
def create_role def create_role

View File

@ -1,5 +1,6 @@
class ObjectAuth < PrototypeAuth class ObjectAuth < PrototypeAuth
include OrbitCoreLib::ObjectTokenUnility include OrbitCoreLib::ObjectTokenUnility
validates_uniqueness_of :obj_authable_type,:scope => :title #{ |c| }
belongs_to :obj_authable, polymorphic: true belongs_to :obj_authable, polymorphic: true
# > - Something.find_with_auth(query) # > - Something.find_with_auth(query)
# > - or Something.find(query).auth # > - or Something.find(query).auth

View File

@ -1,7 +1,7 @@
<div id="open_for_all_user"> <div id="open_for_all_user">
<h1>All User</h1> <h1>All User</h1>
<%= form_tag(submit_url) do %> <%= form_tag(submit_url) do %>
<%= check_box_tag 'auth_all',true,auth.all %><%= submit_tag 'Add Role' %><br/> <%= check_box_tag 'auth_all',true,(auth.all rescue true) %><%= submit_tag 'Add Role' %><br/>
<% end %> <% end %>
</div> </div>

View File

@ -5,7 +5,7 @@ namespace :user do
User.all(conditions: {email: /nor/}).destroy_all User.all(conditions: {email: /nor/}).destroy_all
username_list = %w{nor1 nor2 nor3 nor4 nor5 nor6 nor7} username_list = %w{nor1 nor2 nor3 nor4 nor5 nor6 nor7}
userfirstname_list_en = %w{ One Two Thre For Fiv Six Sen } userfirstname_list_en = %w{ UserOne UserTwo Thre For Fiv Six Sen }
userlastname_list_en = %w{ Aa Bb Cc Dd Ee Ff Gg } userlastname_list_en = %w{ Aa Bb Cc Dd Ee Ff Gg }
userfirstname_list_ct = %w{ 一一 二二 三三 四四 五五 六六 七七 } userfirstname_list_ct = %w{ 一一 二二 三三 四四 五五 六六 七七 }

View File

@ -4,8 +4,8 @@ class Panel::Announcement::BackEnd::AnnouncementsController < OrbitBackendContro
render :text => "This is an public_page need to be build" render :text => "This is an public_page need to be build"
end end
def index def list_mine
@bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
end end
# GET /announcements/1 # GET /announcements/1
# GET /announcements/1.xml # GET /announcements/1.xml

View File

@ -1,5 +1,5 @@
class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
include AdminHelper
#before_filter :is_admin? #before_filter :is_admin?
def index def index
@ -136,7 +136,12 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
protected protected
def get_categorys(id = nil) def get_categorys(id = nil)
@bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) @bulletin_categorys = []
if(is_manager? || is_admin?)
@bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true))
elsif is_sub_manager?
@bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new')
end
end end

View File

@ -1,10 +1,18 @@
class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendController class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendController
before_filter :authenticate_user! before_filter :authenticate_user!
include AdminHelper
layout 'admin' layout 'admin'
def index def index
@bulletin_categorys_preview = BulletinCategory.authed_for_user(current_user,'preview') @bulletin_categorys_submit_new = []
@bulletin_categorys_check = BulletinCategory.authed_for_user(current_user,'fact_check') @bulletin_categorys_check =[]
if is_admin? || is_manager?
#@bulletin_categorys_submit_new = BulletinCategory.all
@bulletin_categorys_check = BulletinCategory.all
# elsif is_sub_manager?
# @bulletin_categorys_submit_new = BulletinCategory.authed_for_user(current_user,'submit_new')
# @bulletin_categorys_check = BulletinCategory.authed_for_user(current_user,'fact_check')
end
end end
def new def new

View File

@ -5,7 +5,7 @@ class BulletinCategory
include Mongoid::Timestamps include Mongoid::Timestamps
include OrbitCoreLib::ObjectAuthable include OrbitCoreLib::ObjectAuthable
ObjectAuthTitlesOptions = %W{preview fact_check} ObjectAuthTitlesOptions = %W{submit_new fact_check}
AfterObjectAuthUrl = '/panel/announcement/back_end/bulletin_categorys' AfterObjectAuthUrl = '/panel/announcement/back_end/bulletin_categorys'
# include Mongoid::MultiParameterAttributes # include Mongoid::MultiParameterAttributes

View File

@ -1,22 +1,17 @@
<% content_for :secondary do %> <% content_for :secondary do %>
<br /> <%= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
<br />
<br />
<br />
<br />
<ul class="list">
<li><%#= link_to t('bulletin_category.new_announcement_class'), new_panel_announcement_back_end_bulletin_category_path, :class => 'seclink1' %></li>
</ul>
<% end -%> <% end -%>
<%= flash_messages %> <%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<h1><%= t('bulletin_category.list_announcement_class') %></h1> <h1><%= t('bulletin_category.list_announcement_class') %></h1>
<br />
<br />
<br />
<br />
<br />
<table id="bulletin_categorys"> <table id="bulletin_categorys">
<tr> <tr>
<th><%= t('bulletin_category.key') %></th> <th><%= t('bulletin_category.key') %></th>

View File

@ -1,15 +1,15 @@
<br />
<br />
<br />
<br />
<% content_for :secondary do %> <% content_for :secondary do %>
<ul class="list"> <%= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
<li><%= link_to t('bulletin_category.index'), panel_announcement_back_end_bulletin_categorys_path, :class => 'seclink2' %></li>
</ul>
<% end -%> <% end -%>
<%= flash_messages %> <%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<h1><%= t('bulletin_category.new_announcement_class') %></h1> <h1><%= t('bulletin_category.new_announcement_class') %></h1>
<%= form_for @bulletin_category, :url => panel_announcement_back_end_bulletin_categorys_path do |f| %> <%= form_for @bulletin_category, :url => panel_announcement_back_end_bulletin_categorys_path do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>

View File

@ -1,9 +1,14 @@
<br /> <% content_for :secondary do %>
<br /> <%= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
<br /> <% end -%>
<br />
<h1><%= t('announcement.editing_announcement') %></h1> <%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletin_path(@bulletin) do |f| %> <%= form_for @bulletin, :url => panel_announcement_back_end_bulletin_path(@bulletin) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>

View File

@ -1,15 +1,5 @@
<% content_for :secondary do %> <% content_for :secondary do %>
<br /> <%= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
<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 if is_manager?%></li>
<li><%= link_to t('bulletin.my_announcement_fact_check'), panel_announcement_back_end_fact_checks_path if is_sub_manager?%></li>
</ul>
<% end -%> <% end -%>
<%= flash_messages %> <%= flash_messages %>

View File

@ -1,15 +1,14 @@
<br />
<br />
<br />
<br />
<% content_for :secondary do %> <% content_for :secondary do %>
<ul class="list"> <%= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
<li><%= link_to t('bulletin.index'), panel_announcement_back_end_bulletins_path, :class => 'seclink2' %></li>
</ul>
<% end -%> <% end -%>
<%= flash_messages %> <%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<h1><%= t('bulletin.new_announcement') %></h1> <h1><%= t('bulletin.new_announcement') %></h1>
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path do |f| %> <%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>

View File

@ -1,10 +1,14 @@
<% # encoding: utf-8 %> <% content_for :secondary do %>
<%= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
<% end -%>
<%= flash_messages %>
<br /> <br />
<br /> <br />
<br /> <br />
<br />
<p id="notice"><%= flash_messages %></p> <br />
<ul> <ul>
<li> <li>

View File

@ -1,16 +1,5 @@
<% content_for :secondary do %> <% content_for :secondary do %>
<br /> <%= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
<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 -%> <% end -%>
<%= flash_messages %> <%= flash_messages %>
@ -42,11 +31,7 @@
<br /> <br />
<h1><%= t('bulletin.list_announcement') %></h1> <h1><%= t('bulletin.list_announcement') %></h1>
<div id="preview_block">
<h1>Preview</h1>
<%= render :partial => "list_table", :collection => @bulletin_categorys_preview,:as => :bulletin_category%>
</div>
===================================================================================================================
<div id="check_block"> <div id="check_block">
<h1>Check Please</h1> <h1>Check Please</h1>
<%= render :partial => "list_table", :collection => @bulletin_categorys_check,:as => :bulletin_category%> <%= render :partial => "list_table", :collection => @bulletin_categorys_check,:as => :bulletin_category%>

View File

@ -5,6 +5,7 @@ Rails.application.routes.draw do
namespace :back_end do namespace :back_end do
match 'public' => "announcements#public",:as => :public match 'public' => "announcements#public",:as => :public
resources :fact_checks resources :fact_checks
match 'list_mine' => "announcements#list_mine"
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