approve mechanism improved

This commit is contained in:
Harry Bomrah 2015-03-26 18:12:32 +08:00
parent fa3fa2278f
commit df77e37a70
5 changed files with 17 additions and 28 deletions

View File

@ -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']

View File

@ -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

View File

@ -17,30 +17,6 @@
<%= b.status_for_table %>
</td>
<td><%= b.category.title %></td>
<!-- <td>
<% if b.expired? %>
<%= b.title %> <span class='label'><%= t(:expired) %></span>
<% elsif b.rejected %>
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title %></a> <span class='label'><%= t(:rejected) %> : <%= b.rejection_reason rescue "" %></span>
<% elsif !b.approved? %>
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title %></a> <span class='label'><%= t(:pending) %></span>
<% else %>
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title %></a>
<% end %>
<div class="quick-edit">
<ul class="nav nav-pills">
<li><a href="#" class="detail-row" onclick="$('#<%= "#{b.id.to_s}-detail" %>').slideToggle(300); return false;"><%= t(:detail) %></a></li>
<% if can_edit_or_delete?(b) %>
<li><a href="/admin/announcements/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
<li><a href="#" class="delete text-error" rel="/admin/announcements/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
<% if !b.approved && user_can_approve? %>
<li><a href="#" class="appoval_button" data-approve-link="<%= "/#{I18n.locale.to_s}/announcement/#{b.to_param}" %>" data-id="<%= b.id.to_s %>"><%= t("announcement.approve") %></a></li>
<% end %>
<% end %>
</ul>
</div>
</td> -->
<td>
<% if b.expired? %>
<% if b.rejected %>
@ -58,6 +34,14 @@
<%= b.title_translations["en"] %> <span class='label'><%= t(:expired) %></span>
<% end %>
<% end %>
<% elsif b.rejected && b.reapproval %>
<%# url = page_for_bulletin(b) %>
<% if !b.title_translations["zh_tw"].blank? %>
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title_translations["zh_tw"] %></a> <span class='label'><%= t("announcement.reapproval") %> : <%= t(:pending) %></span><br />
<% end %>
<% if !b.title_translations["en"].blank? %>
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title_translations["en"] %></a> <span class='label'><%= t("announcement.reapproval") %> : <%= t(:pending) %></span>
<% end %>
<% elsif b.rejected %>
<%# url = page_for_bulletin(b) %>
<% if !b.title_translations["zh_tw"].blank? %>
@ -67,7 +51,6 @@
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title_translations["en"] %></a> <span class='label'><%= t(:rejected) %> : <%= b.rejection_reason rescue "" %></span>
<% end %>
<% elsif !b.approved? %>
<% url = page_for_news_bulletin(b) %>
<% if !b.title_translations["zh_tw"].blank? %>
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title_translations["zh_tw"] %></a> <span class='label'><%= t(:pending) %></span><br />
<% end %>
@ -75,7 +58,6 @@
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title_translations["en"] %></a> <span class='label'><%= t(:pending) %></span>
<% end %>
<% else %>
<% url = page_for_news_bulletin(b) %>
<% if !b.title_translations["zh_tw"].blank? %>
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title_translations["zh_tw"] %></a><br />
<% end %>
@ -91,7 +73,7 @@
<li><a href="/admin/announcements/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
<li><a href="#" class="delete text-error" rel="/admin/announcements/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
<% elsif is_user_sub_manager? %>
<% if !b.rejected && !b.approved %>
<% if b.rejected && !b.approved %>
<li><a href="/admin/announcements/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
<% end %>
<li><a href="#" class="delete text-error" rel="/admin/announcements/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
@ -101,7 +83,7 @@
<li><a href="#" class="delete text-error" rel="/admin/announcements/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
<% end %>
<% end %>
<% if !b.rejected && !b.approved && user_can_approve? && !b.expired? %>
<% if b.rejected && !b.approved && user_can_approve? && !b.expired? %>
<li><a href="#" class="appoval_button" data-approve-link="<%= "/#{I18n.locale.to_s}/announcement/#{b.to_param}" %>" data-id="<%= b.id.to_s %>"><%= t("announcement.approve") %></a></li>
<% end %>
<% end %>

View File

@ -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

View File

@ -10,6 +10,7 @@ zh_tw:
dept_title: 單位
add_new: 新建
approve: 審核
reapproval: 重新審核
tag_cloud: 標籤雲
all_articles: 文章列表
announcement: 公告