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" if params["approved"] == "true"
bulletin.approved = true bulletin.approved = true
bulletin.rejected = false bulletin.rejected = false
bulletin.reapproval = false
else else
bulletin.rejected = true bulletin.rejected = true
bulletin.reapproval = false
bulletin.rejection_reason = params["reason"] bulletin.rejection_reason = params["reason"]
end end
bulletin.save bulletin.save
@ -104,6 +106,8 @@ class Admin::AnnouncementsController < OrbitAdminController
end end
bulletin.update_attributes(bulletin_params) bulletin.update_attributes(bulletin_params)
bulletin.reapproval = true if bulletin.rejected
bulletin.save bulletin.save
build_email(bulletin) build_email(bulletin)
redirect_to params['referer_url'] redirect_to params['referer_url']

View File

@ -20,6 +20,7 @@ class Bulletin
field :rss2_sn field :rss2_sn
field :approved, :type => Boolean, :default => false field :approved, :type => Boolean, :default => false
field :rejected, :type => Boolean, :default => false field :rejected, :type => Boolean, :default => false
field :reapproval, :type => Boolean, :default => false
field :rejection_reason field :rejection_reason
field :is_preview, :type => Boolean, :default => false field :is_preview, :type => Boolean, :default => false
field :expirable_created_at, type: DateTime field :expirable_created_at, type: DateTime

View File

@ -17,30 +17,6 @@
<%= b.status_for_table %> <%= b.status_for_table %>
</td> </td>
<td><%= b.category.title %></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> <td>
<% if b.expired? %> <% if b.expired? %>
<% if b.rejected %> <% if b.rejected %>
@ -58,6 +34,14 @@
<%= b.title_translations["en"] %> <span class='label'><%= t(:expired) %></span> <%= b.title_translations["en"] %> <span class='label'><%= t(:expired) %></span>
<% end %> <% end %>
<% 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 %> <% elsif b.rejected %>
<%# url = page_for_bulletin(b) %> <%# url = page_for_bulletin(b) %>
<% if !b.title_translations["zh_tw"].blank? %> <% 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> <a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title_translations["en"] %></a> <span class='label'><%= t(:rejected) %> : <%= b.rejection_reason rescue "" %></span>
<% end %> <% end %>
<% elsif !b.approved? %> <% elsif !b.approved? %>
<% url = page_for_news_bulletin(b) %>
<% if !b.title_translations["zh_tw"].blank? %> <% 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 /> <a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title_translations["zh_tw"] %></a> <span class='label'><%= t(:pending) %></span><br />
<% end %> <% end %>
@ -75,7 +58,6 @@
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title_translations["en"] %></a> <span class='label'><%= t(:pending) %></span> <a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title_translations["en"] %></a> <span class='label'><%= t(:pending) %></span>
<% end %> <% end %>
<% else %> <% else %>
<% url = page_for_news_bulletin(b) %>
<% if !b.title_translations["zh_tw"].blank? %> <% if !b.title_translations["zh_tw"].blank? %>
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title_translations["zh_tw"] %></a><br /> <a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title_translations["zh_tw"] %></a><br />
<% end %> <% end %>
@ -91,7 +73,7 @@
<li><a href="/admin/announcements/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li> <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> <li><a href="#" class="delete text-error" rel="/admin/announcements/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
<% elsif is_user_sub_manager? %> <% 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> <li><a href="/admin/announcements/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
<% end %> <% end %>
<li><a href="#" class="delete text-error" rel="/admin/announcements/<%=b.id.to_s%>"><%= t(:delete_) %></a></li> <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> <li><a href="#" class="delete text-error" rel="/admin/announcements/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
<% end %> <% end %>
<% 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> <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 %>
<% end %> <% end %>

View File

@ -9,6 +9,7 @@ en:
category: Category category: Category
dept_title: Department dept_title: Department
add_new: Add New add_new: Add New
reapproval: Re-approval
approve: Approve approve: Approve
tag_cloud: Tag Cloud tag_cloud: Tag Cloud
all_articles: All Articles all_articles: All Articles

View File

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