From ffd95ee1fd4e997957722077b4909b9110941f24 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 25 Jun 2012 16:23:16 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=96=B0=E8=81=9E=E8=88=87=E5=85=AC?= =?UTF-8?q?=E5=91=8AQA-=E6=AC=8A=E9=99=90=E8=A8=AD=E5=AE=9A--=E5=84=AA?= =?UTF-8?q?=E5=85=88=E8=99=95=E7=90=863.=E4=B8=80=E8=88=AC=E7=99=BC?= =?UTF-8?q?=E4=BD=88=E6=96=B0=E8=81=9E&=E5=85=AC=E5=91=8A=E4=BA=BA?= =?UTF-8?q?=EF=BC=8C=E6=87=89=E8=A9=B2=E5=8F=AA=E8=83=BD=E7=9C=8B=E5=88=B0?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E7=99=BC=E4=BD=88=E7=9A=84=E6=96=B0=E8=81=9E?= =?UTF-8?q?&=E5=85=AC=E5=91=8A=EF=BC=8C=E4=BD=86=E6=98=AF=E7=9B=AE?= =?UTF-8?q?=E5=89=8D=E5=8F=AF=E4=BB=A5=E7=9C=8B=E5=88=B0=E5=85=A8=E9=83=A8?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E4=B8=94=E5=8F=AF=E4=BB=A5=E5=88=AA=E9=99=A4?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E4=BA=BA=E7=9A=84=E5=85=AC=E5=91=8A.?= =?UTF-8?q?=E8=87=B3=E5=B0=91=E8=A6=81=E4=B8=8D=E8=83=BD=E5=88=AA=E9=99=A4?= =?UTF-8?q?=E5=88=A5=E4=BA=BA=E7=9A=84=E5=85=AC=E5=91=8A=20=E6=96=B0?= =?UTF-8?q?=E8=81=9E=E8=88=87=E5=85=AC=E5=91=8AQA-=E7=B7=A8=E8=BC=AF?= =?UTF-8?q?=E5=95=8F=E9=A1=8C-=E7=99=BC=E4=BD=88=E6=96=B0=E8=81=9E?= =?UTF-8?q?=E6=99=82=EF=BC=8C=E7=99=BC=E4=BD=88=E5=96=AE=E4=BD=8D=E9=A0=90?= =?UTF-8?q?=E8=A8=AD=E7=82=BA=E8=AB=8B=E9=81=B8=E6=93=87=20=E6=96=B0?= =?UTF-8?q?=E8=81=9E=E8=88=87=E5=85=AC=E5=91=8AQA-=E7=B7=A8=E8=BC=AF?= =?UTF-8?q?=E5=95=8F=E9=A1=8C-=E5=85=AC=E5=91=8A=E6=A8=A1=E7=B5=84?= =?UTF-8?q?=E8=AB=8B=E7=A7=BB=E9=99=A4=20Subtitle=20=E6=AC=84=E4=BD=8D=20p?= =?UTF-8?q?ut=20rb-readline=20only=20in=20Linux=20make=20app=5Fmanager=20d?= =?UTF-8?q?estroy=20after=20user=20deletion.=20=20=20may=20need=20to=20run?= =?UTF-8?q?:=20=20AppManager.all.collect{|am|=20=20am=20if=20am.user.nil?= =?UTF-8?q?=3F=20}.delete=5Fif=20{|x|=20x=20=3D=3D=20nil}.each{|am|=20am.d?= =?UTF-8?q?estroy}=20for=20clean=20up=20DB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 3 ++- Gemfile.lock | 2 -- app/models/app_manager.rb | 2 +- app/models/module_app.rb | 6 +++--- app/models/user/user.rb | 6 +++--- app/views/layouts/_side_bar.html.erb | 4 ++-- config/resque.god | 8 ++++---- .../announcement/back_end/bulletins_helper.rb | 6 ++++++ .../back_end/bulletins/_bulletin.html.erb | 8 ++++---- .../back_end/bulletins/_form.html.erb | 15 ++++----------- .../announcement/config/locales/zh_tw.yml | 1 + .../panel/news/back_end/news_bulletins_helper.rb | 6 ++++++ .../news/back_end/news_bulletins/_form.html.erb | 12 ++++++------ .../news_bulletins/_news_bulletin.html.erb | 2 ++ .../built_in_modules/news/config/locales/en.yml | 1 + .../news/config/locales/zh_tw.yml | 4 ++++ 16 files changed, 49 insertions(+), 37 deletions(-) diff --git a/Gemfile b/Gemfile index 6eccd600..ca660050 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,6 @@ gem 'rake' gem 'resque' # background jobs gem 'resque-scheduler' # job scheduling gem 'resque-restriction' -gem 'rb-readline' gem 'ruby-debug19' gem 'rubyzip' gem 'therubyracer' @@ -34,6 +33,8 @@ gem 'sinatra' gem 'sprockets' gem 'tinymce-rails' gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux") +gem 'rb-readline' if RUBY_PLATFORM.downcase.include?("linux") + gem "impressionist", :require => "impressionist", :path => "vendor/impressionist" diff --git a/Gemfile.lock b/Gemfile.lock index e21da804..776d0b32 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -168,7 +168,6 @@ GEM rdoc (~> 3.4) thor (~> 0.14.6) rake (0.9.2.2) - rb-readline (0.4.2) rdoc (3.12) json (~> 1.4) redis (2.2.2) @@ -302,7 +301,6 @@ DEPENDENCIES radius rails (>= 3.1.0, < 3.2.0) rake - rb-readline resque resque-restriction resque-scheduler diff --git a/app/models/app_manager.rb b/app/models/app_manager.rb index 46cbbb91..0d81a0ec 100644 --- a/app/models/app_manager.rb +++ b/app/models/app_manager.rb @@ -1,7 +1,7 @@ class AppManager include Mongoid::Document include Mongoid::Timestamps - + belongs_to :user belongs_to :managing_app, :polymorphic => true #,:class_name => 'ModuleApp',:inverse_of => :managers,:foreign_key => "user_id" diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 7ad4ac1d..9708316f 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -4,7 +4,7 @@ class ModuleApp include OrbitCoreLib::ObjectTokenUnility field :key - field :title + field :title field :version field :organization field :author @@ -16,8 +16,8 @@ class ModuleApp field :app_pages ,type: Array field :widgets ,type: Array - has_many :managers,as: :managing_app ,:class_name => "AppManager" #,:dependent => :destroy,:foreign_key => "managing_app_id",:inverse_of => :managing_app - has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager"#, :dependent => :destroy,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app + has_many :managers,as: :managing_app ,:class_name => "AppManager" ,:dependent => :destroy#,:foreign_key => "managing_app_id",:inverse_of => :managing_app + has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager", :dependent => :destroy#,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app has_many :tags has_many :page_parts diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 7c1e4c63..4f820c16 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -17,10 +17,10 @@ class User has_many :attribute_values, :autosave => true, :dependent => :destroy has_many :app_auths,as: :privilege_apps,:inverse_of => :privilege_lists - has_many :blocked_apps, :inverse_of => :blocked_users, :class_name => "AppAuth" - has_many :privilege_apps, :inverse_of => :privilege_users, :class_name => "AppAuth" + has_many :blocked_apps, :inverse_of => :blocked_users, :class_name => "AppAuth", :dependent => :destroy + has_many :privilege_apps, :inverse_of => :privilege_users, :class_name => "AppAuth", :dependent => :destroy - has_many :managing_apps,:class_name => "AppManager" + has_many :managing_apps,:class_name => "AppManager", :dependent => :destroy belongs_to :role has_and_belongs_to_many :sub_roles diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 73b5191a..26925aee 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -12,7 +12,7 @@ <%= content_tag :li, link_to(t('announcement.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %> <%= content_tag :li, link_to(t('announcement.categories'), panel_announcement_back_end_bulletin_categorys_path), :class =>( active_for_action('bulletin_categorys', 'index') || active_for_ob_auths_object("BulletinCategory") ) %> <%= content_tag :li, link_to(t('announcement.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('/panel/announcement/back_end/tags', 'index') %> - <%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_announcement_back_end_approval_setting_path), :class => active_for_action('approvals', 'setting') if (is_manager? rescue nil) %> + <%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_announcement_back_end_approval_setting_path), :class => active_for_action('approvals', 'setting') if (is_manager? rescue true) %> <%= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: "Announcement"}))), :class => active_for_app_auth('Announcement') if (is_admin? rescue nil) %> <% end -%> @@ -26,7 +26,7 @@ <%= content_tag :li, link_to(t('announcement.add_new'), new_panel_news_back_end_news_bulletin_path), :class => active_for_action('news_bulletins', 'new') %> <%= content_tag :li, link_to(t('announcement.categories'), panel_news_back_end_news_bulletin_categorys_path), :class => active_for_action('news_bulletin_categorys', 'index') || active_for_ob_auths_object("NewsBulletinCategory") %> <%= content_tag :li, link_to(t('announcement.tags'), panel_news_back_end_tags_path), :class => active_for_action('/panel/news/back_end/tags', 'index') %> - <%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_news_back_end_approval_setting_path), :class => active_for_action('news_approvals', 'setting') if (is_manager? rescue nil) %> + <%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_news_back_end_approval_setting_path), :class => active_for_action('news_approvals', 'setting') if (is_manager? rescue true) %> <%= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "news"}))), :class => active_for_app_auth('news') if (is_admin? rescue nil) %> <% end -%> diff --git a/config/resque.god b/config/resque.god index 80da5abe..aa9cb0b4 100644 --- a/config/resque.god +++ b/config/resque.god @@ -2,7 +2,7 @@ default_uid = 'kaito' default_gid = 'staff' -rails_env = 'development' #ENV['RAILS_ENV'] || "production" +rails_env = ENV['RAILS_ENV'] || "production" rails_root = ENV['RAILS_ROOT'] || File.expand_path("..",File.dirname(__FILE__)) @@ -17,10 +17,10 @@ num_workers.times do |num| w.interval = 30.seconds p "/usr/bin/rake -f #{rails_root}/Rakefile resque:work QUEUE=* RAILS_ENV=#{rails_env}" # w.env = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env} - w.start = "rake -f #{rails_root}/Rakefile resque:work QUEUE=* RAILS_ENV=#{rails_env}" + w.start = "rake -f #{rails_root}/Rakefile resque:work QUEUE=* RAILS_ENV=#{rails_env} -P /var/godgod.#{port}.pid" - w.uid = rails_env == 'production' ? nccu : default_uid - w.gid = rails_env == 'production' ? nccu : default_gid + w.uid = rails_env == 'production' ? "nccu" : default_uid + w.gid = rails_env == 'production' ? "nccu" : default_gid w.log = "#{rails_root}/log/god.log" diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb index c384bc8f..49f24079 100644 --- a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb +++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb @@ -6,4 +6,10 @@ module Panel::Announcement::BackEnd::BulletinsHelper by_bulletin and by_user end + def show_delete_link(bulletin) + by_bulletin = (bulletin.create_user_id == current_user.id) + by_user = (is_manager? or is_admin?) + by_bulletin or by_user + end + end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb index 8f879e79..afb57306 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb @@ -48,12 +48,12 @@
  • <%= link_to t(:file), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'files'), :remote => true %>
  • - <%#= debugger %> - <%#= a=1 %> - <% end %> - + <% end -%> + <% if show_delete_link(bulletin) %> + + <% end %> <% if show_approval_link(bulletin) %>
  • <%= link_to t('announcement.bulletin.approval'), panel_announcement_back_end_bulletin_approval_preview_path(bulletin),:class => 'preview_trigger' %>
  • <%#= #TODO add ancher so user can quick access into that part %> <% end %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index c515dc65..c7f544e6 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -123,7 +123,7 @@ <%#= f.label :unit_list_for_anc%> <%#= f.select :unit_list_for_anc_id,@unit_list_for_anc.collect{|t| [ t.title[I18n.locale], t.id ]}, {}, :class => "input-medium" %> - <%= f.label :category %> + <%= f.label :category,t('announcement.bulletin.category')%> <%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>