From df77e37a707b26ace5167a4d20238ba48de84e12 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 26 Mar 2015 18:12:32 +0800 Subject: [PATCH] approve mechanism improved --- .../admin/announcements_controller.rb | 4 ++ app/models/bulletin.rb | 1 + app/views/admin/announcements/_index.html.erb | 38 +++++-------------- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 1 + 5 files changed, 17 insertions(+), 28 deletions(-) diff --git a/app/controllers/admin/announcements_controller.rb b/app/controllers/admin/announcements_controller.rb index 36de13d..120a4f8 100644 --- a/app/controllers/admin/announcements_controller.rb +++ b/app/controllers/admin/announcements_controller.rb @@ -72,8 +72,10 @@ class Admin::AnnouncementsController < OrbitAdminController if params["approved"] == "true" bulletin.approved = true bulletin.rejected = false + bulletin.reapproval = false else bulletin.rejected = true + bulletin.reapproval = false bulletin.rejection_reason = params["reason"] end bulletin.save @@ -104,6 +106,8 @@ class Admin::AnnouncementsController < OrbitAdminController end bulletin.update_attributes(bulletin_params) + bulletin.reapproval = true if bulletin.rejected + bulletin.save build_email(bulletin) redirect_to params['referer_url'] diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index fdcd59c..5bf9715 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -20,6 +20,7 @@ class Bulletin field :rss2_sn field :approved, :type => Boolean, :default => false field :rejected, :type => Boolean, :default => false + field :reapproval, :type => Boolean, :default => false field :rejection_reason field :is_preview, :type => Boolean, :default => false field :expirable_created_at, type: DateTime diff --git a/app/views/admin/announcements/_index.html.erb b/app/views/admin/announcements/_index.html.erb index cfa01b4..f8bd046 100644 --- a/app/views/admin/announcements/_index.html.erb +++ b/app/views/admin/announcements/_index.html.erb @@ -17,30 +17,6 @@ <%= b.status_for_table %> <%= b.category.title %> - - <% if b.expired? %> <% if b.rejected %> @@ -58,6 +34,14 @@ <%= b.title_translations["en"] %> <%= t(:expired) %> <% end %> <% end %> + <% elsif b.rejected && b.reapproval %> + <%# url = page_for_bulletin(b) %> + <% if !b.title_translations["zh_tw"].blank? %> + <%= b.title_translations["zh_tw"] %> <%= t("announcement.reapproval") %> : <%= t(:pending) %>
+ <% end %> + <% if !b.title_translations["en"].blank? %> + <%= b.title_translations["en"] %> <%= t("announcement.reapproval") %> : <%= t(:pending) %> + <% end %> <% elsif b.rejected %> <%# url = page_for_bulletin(b) %> <% if !b.title_translations["zh_tw"].blank? %> @@ -67,7 +51,6 @@ <%= b.title_translations["en"] %> <%= t(:rejected) %> : <%= b.rejection_reason rescue "" %> <% end %> <% elsif !b.approved? %> - <% url = page_for_news_bulletin(b) %> <% if !b.title_translations["zh_tw"].blank? %> <%= b.title_translations["zh_tw"] %> <%= t(:pending) %>
<% end %> @@ -75,7 +58,6 @@ <%= b.title_translations["en"] %> <%= t(:pending) %> <% end %> <% else %> - <% url = page_for_news_bulletin(b) %> <% if !b.title_translations["zh_tw"].blank? %> <%= b.title_translations["zh_tw"] %>
<% end %> @@ -91,7 +73,7 @@
  • <%= t(:edit) %>
  • <%= t(:delete_) %>
  • <% elsif is_user_sub_manager? %> - <% if !b.rejected && !b.approved %> + <% if b.rejected && !b.approved %>
  • <%= t(:edit) %>
  • <% end %>
  • <%= t(:delete_) %>
  • @@ -101,7 +83,7 @@
  • <%= t(:delete_) %>
  • <% end %> <% end %> - <% if !b.rejected && !b.approved && user_can_approve? && !b.expired? %> + <% if b.rejected && !b.approved && user_can_approve? && !b.expired? %>
  • " data-id="<%= b.id.to_s %>"><%= t("announcement.approve") %>
  • <% end %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index af0ae3e..99d2048 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -9,6 +9,7 @@ en: category: Category dept_title: Department add_new: Add New + reapproval: Re-approval approve: Approve tag_cloud: Tag Cloud all_articles: All Articles diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 5622d9c..d543f97 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -10,6 +10,7 @@ zh_tw: dept_title: 單位 add_new: 新建 approve: 審核 + reapproval: 重新審核 tag_cloud: 標籤雲 all_articles: 文章列表 announcement: 公告