diff --git a/app/controllers/admin/news_controller.rb b/app/controllers/admin/news_controller.rb
index 8360c1d..a22105d 100644
--- a/app/controllers/admin/news_controller.rb
+++ b/app/controllers/admin/news_controller.rb
@@ -57,7 +57,13 @@ class Admin::NewsController < OrbitAdminController
def approve_news_bulletin
id = params[:id]
news_bulletin = NewsBulletin.find(id)
- news_bulletin.approved = true
+ if params["approved"] == "true"
+ news_bulletin.approved = true
+ news_bulletin.rejected = false
+ else
+ news_bulletin.rejected = true
+ news_bulletin.rejection_reason = params["reason"]
+ end
news_bulletin.save
redirect_to "/admin/news"
end
diff --git a/app/models/news_bulletin.rb b/app/models/news_bulletin.rb
index 120235c..28c67ac 100644
--- a/app/models/news_bulletin.rb
+++ b/app/models/news_bulletin.rb
@@ -21,6 +21,8 @@ class NewsBulletin
field :deadline , :type => DateTime
field :rss2_sn
field :approved, :type => Boolean, :default => false
+ field :rejected, :type => Boolean, :default => false
+ field :rejection_reason
field :is_preview, :type => Boolean, :default => false
field :email_id
diff --git a/app/views/admin/news/_approval_modal.html.erb b/app/views/admin/news/_approval_modal.html.erb
new file mode 100644
index 0000000..29e9ae5
--- /dev/null
+++ b/app/views/admin/news/_approval_modal.html.erb
@@ -0,0 +1,122 @@
+
+
\ No newline at end of file
diff --git a/app/views/admin/news/_index.html.erb b/app/views/admin/news/_index.html.erb
index 466f67b..e2c39fb 100644
--- a/app/views/admin/news/_index.html.erb
+++ b/app/views/admin/news/_index.html.erb
@@ -20,6 +20,8 @@
<% if b.expired? %>
<%= b.title %> <%= t(:expired) %>
+ <% elsif b.rejected %>
+ <%= b.title %> <%= t(:rejected) %> : <%= b.rejection_reason rescue "" %>
<% elsif !b.approved? %>
<%= b.title %> <%= t(:pending) %>
<% else %>
@@ -32,7 +34,7 @@
<%= t(:edit) %>
<%= t(:delete_) %>
<% if !b.approved && user_can_approve? %>
- <%= t("news.approve") %>
+ " data-id="<%= b.id.to_s %>"><%= t("news.approve") %>
<% end %>
<% end %>
diff --git a/app/views/admin/news/index.html.erb b/app/views/admin/news/index.html.erb
index 1ad9a26..7723682 100644
--- a/app/views/admin/news/index.html.erb
+++ b/app/views/admin/news/index.html.erb
@@ -3,4 +3,17 @@
<%= render 'index'%>
-<%= render 'layouts/delete_modal', delete_options: @delete_options %>
\ No newline at end of file
+<%= render 'layouts/delete_modal', delete_options: @delete_options %>
+
+<%= render :partial=> "approval_modal" %>
+
+
\ No newline at end of file
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index afe80ff..97ca238 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -29,6 +29,7 @@ zh_tw:
all_articles: 文章列表
all: 全部類別
news: 新聞
+ approve: 審核
admins: 單位設定
append_note: 以下之附加連結與檔案,為使前台顯示名稱,建議您輸入註解。
approval_setting: 審核設定
diff --git a/config/routes.rb b/config/routes.rb
index 1f30f06..1e6ccf1 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -6,7 +6,7 @@ Rails.application.routes.draw do
namespace :admin do
post 'news/preview', to: 'news#preview'
get 'news/destroy_preview/:slug_title-:uid', to: 'news#destroy_preview'
- get 'news/approve_news_bulletin', to: 'news#approve_news_bulletin'
+ post 'news/approve_news_bulletin', to: 'news#approve_news_bulletin'
get 'news_admins/get_departments' => "news_admins#get_departments"
resources :news
resources :news_admins
|