From 3bcd7ea349c814b64e401fb0868ec31ed2788aa9 Mon Sep 17 00:00:00 2001 From: Matthew Kaito Juyuan Fu Date: Mon, 13 Feb 2012 17:33:48 +0800 Subject: [PATCH] Exp with object_auth --- app/controllers/admin/app_auths_controller.rb | 4 +- .../admin/module_apps_controller.rb | 4 ++ .../admin/object_auths_controller.rb | 1 + app/models/prototype_auth.rb | 6 +-- .../admin/attributes/_app_selector.html.erb | 1 + app/views/admin/module_apps/show.html.erb | 37 ++++++++++++++ app/views/admin/object_auths/new.html.erb | 3 +- .../back_end/bulletins_controller.rb | 2 +- .../back_end/fact_checks_controller.rb | 29 +++++++++++ .../announcement/app/models/bulletin.rb | 2 +- .../app/models/bulletin_category.rb | 4 ++ .../_bulletin_category.html.erb | 6 +++ .../back_end/bulletins/_bulletins.html.erb | 2 +- .../back_end/bulletins/index.html.erb | 1 - .../back_end/fact_checks/_list_table.html.erb | 15 ++++++ .../back_end/fact_checks/index.html.erb | 51 +++++++++++++++++++ .../announcement/config/routes.rb | 3 +- 17 files changed, 161 insertions(+), 10 deletions(-) create mode 100644 app/views/admin/attributes/_app_selector.html.erb create mode 100644 app/views/admin/module_apps/show.html.erb create mode 100644 vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb diff --git a/app/controllers/admin/app_auths_controller.rb b/app/controllers/admin/app_auths_controller.rb index cb3340fd9..56d0ae23d 100644 --- a/app/controllers/admin/app_auths_controller.rb +++ b/app/controllers/admin/app_auths_controller.rb @@ -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 \ No newline at end of file diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index e80d40238..440f81004 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -21,6 +21,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]) diff --git a/app/controllers/admin/object_auths_controller.rb b/app/controllers/admin/object_auths_controller.rb index ce404e53c..3bff43742 100644 --- a/app/controllers/admin/object_auths_controller.rb +++ b/app/controllers/admin/object_auths_controller.rb @@ -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 } diff --git a/app/models/prototype_auth.rb b/app/models/prototype_auth.rb index 734268c43..893f402b0 100644 --- a/app/models/prototype_auth.rb +++ b/app/models/prototype_auth.rb @@ -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 diff --git a/app/views/admin/attributes/_app_selector.html.erb b/app/views/admin/attributes/_app_selector.html.erb new file mode 100644 index 000000000..c20a38858 --- /dev/null +++ b/app/views/admin/attributes/_app_selector.html.erb @@ -0,0 +1 @@ +<%= f.select :module_app_id, @apps.collect { |t| [t.title.capitalize, t.id] }, {:include_blank => true} ,{:rel => admin_module_apps_path } %> diff --git a/app/views/admin/module_apps/show.html.erb b/app/views/admin/module_apps/show.html.erb new file mode 100644 index 000000000..27cfbc1a0 --- /dev/null +++ b/app/views/admin/module_apps/show.html.erb @@ -0,0 +1,37 @@ +



+<%=@module_app.key %>
+<%=@module_app.title %>
+<%=@module_app.version %>
+<%=@module_app.organization %>
+<%=@module_app.author %>
+<%=@module_app.intro %>
+<%=@module_app.update_info %>
+<%=@module_app.create_date %>
+<%=@module_app.enable_frontend%>
+<%=@module_app.app_pages%>
+<%=@module_app.widgets%>
+ +Mangers: + + + +SubManagers: +
+ <% @module_app.sub_managers.each do |manager|%> + <%= manager.user.name %> + <%end%> +
+
+ +All User?:<%= @module_app.app_auth.all %>
+Blocked Users:<%= @module_app.app_auth.blocked_users.collect{|t| t.name} %>
+Privilege Users:<%= @module_app.app_auth.privilege_users.collect{|t| t.name}%>
+User Roles:<%= @module_app.app_auth.roles.collect{|t| t.key} %>
+User Sub Roles:<%= @module_app.app_auth.sub_roles.collect{|t| t.key} %>
+ +Available users after calculation: +<%= @module_app.app_auth.auth_users.collect{|user| user.name}.join(',') %> diff --git a/app/views/admin/object_auths/new.html.erb b/app/views/admin/object_auths/new.html.erb index 25fd6fd5e..b5b381fb5 100644 --- a/app/views/admin/object_auths/new.html.erb +++ b/app/views/admin/object_auths/new.html.erb @@ -12,7 +12,8 @@

<%= t('object_auth.new_object_auth') %>

<%= 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] %> diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 48b9ac884..6f4c1b7b1 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -105,7 +105,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' } diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb new file mode 100644 index 000000000..ef7e1943e --- /dev/null +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb @@ -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 diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 7c258f236..188142ead 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -4,7 +4,7 @@ class Bulletin include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes - + 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 :text, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_category.rb b/vendor/built_in_modules/announcement/app/models/bulletin_category.rb index 0161847db..4e3dd1861 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin_category.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin_category.rb @@ -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" ] diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb index 579987700..2e0e7ddf0 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb @@ -6,6 +6,12 @@ <% end %> <%= bulletin_category.display %> + <%= link_to t('blog.new_auth'), init_admin_object_auths_path("BulletinCategory",bulletin_category) %>
+ <% bulletin_category.object_auths.each do |obj_auth| %> + <%= link_to obj_auth.title,edit_admin_object_auth_url(obj_auth) %>
+ <% end %> + + <%= 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 %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb index 9fec31f33..bbe383bc7 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb @@ -36,4 +36,4 @@ <%= render :partial => 'bulletin', :collection => @bulletins %> - \ No newline at end of file + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb index d37d2134c..fd2b29b5b 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb @@ -6,4 +6,3 @@
<%= 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' %>
- diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb new file mode 100644 index 000000000..59bac03aa --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb @@ -0,0 +1,15 @@ +

<%= bulletin_category.key %>

+ + + + + + + + + + +<% bulletin_category.bulletins.each do |post| %> + <%= render :partial => 'panel/announcement/back_end/bulletins/bulletins', :locals => {:post => post,:fact_check_allow=>true} %> +<% end %> +
<%= t('bulletin.status') %><%= t('bulletin.category') %><%= t('bulletin.title') %><%= t('bulletin.postdate') %><%= t('bulletin.deadline') %><%= t('bulletin.action') %>
\ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb new file mode 100644 index 000000000..65ebeb286 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb @@ -0,0 +1,51 @@ +<% content_for :secondary do %> +
+
+
+
+
+ +<% end -%> + +<%= flash_messages %> + +
+
+
+
+
+ +
<%= t('bulletin.search') %> + + <%= 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 %> + + +
+ +
+
+ +

<%= t('bulletin.list_announcement') %>

+ + <%= render :partial => "list_table", :collection => @bulletin_categorys_preview,:as => :bulletin_category%> + + <%= render :partial => "list_table", :collection => @bulletin_categorys_check,:as => :bulletin_category%> + +
+ diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index c3a60f74e..cc8777490 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -2,6 +2,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 @@ -21,4 +22,4 @@ Rails.application.routes.draw do end end end -end \ No newline at end of file +end