Compare commits

...
This repository has been archived on 2023-09-12. You can view files and clone it, but cannot push or open issues or pull requests.

10 Commits
temp ... master

Author SHA1 Message Date
Harry Bomrah 75eaea6214 date time picker range added 2016-12-30 16:17:40 +08:00
Harry Bomrah 72927b1723 removed notifications 2015-11-13 22:04:50 +08:00
Harry Bomrah 7042492328 email to managers on new announcement and email to user if rejected 2015-10-27 20:15:25 +08:00
Harry Bomrah b7d16f0f15 added for file sharing 2015-07-03 20:35:28 +08:00
Harry Bomrah 0df3a5f6a6 models for cache 2015-03-30 15:28:32 +08:00
JiangRu 0c7889e437 add models_to_cache 2015-03-30 15:08:44 +08:00
nccu 50783e56d3 approve btn fix 2015-03-26 20:49:50 +08:00
Harry Bomrah f0f8d26cd9 fix 2015-03-26 20:39:20 +08:00
Harry Bomrah 036de05be5 small fix for approve 2015-03-26 20:32:59 +08:00
Harry Bomrah df77e37a70 approve mechanism improved 2015-03-26 18:12:32 +08:00
12 changed files with 90 additions and 33 deletions

View File

@ -60,8 +60,16 @@ class Admin::AnnouncementsController < OrbitAdminController
bulletin.update_user_id = current_user.id
if user_can_approve?
bulletin.approved = true
bulletin.save
else
bulletin.save
# Thread.new do
# begin
# send_notification_mail_to_managers(bulletin,"approval")
# rescue e
# end
# end
end
bulletin.save
build_email(bulletin)
redirect_to params['referer_url']
end
@ -72,11 +80,15 @@ class Admin::AnnouncementsController < OrbitAdminController
if params["approved"] == "true"
bulletin.approved = true
bulletin.rejected = false
bulletin.reapproval = false
bulletin.save
else
bulletin.rejected = true
bulletin.reapproval = false
bulletin.rejection_reason = params["reason"]
bulletin.save
# send_rejection_email(bulletin)
end
bulletin.save
redirect_to admin_announcements_path
end
@ -104,7 +116,18 @@ class Admin::AnnouncementsController < OrbitAdminController
end
bulletin.update_attributes(bulletin_params)
bulletin.save
if bulletin.rejected
bulletin.reapproval = true
bulletin.save
# Thread.new do
# begin
# send_notification_mail_to_managers(bulletin,"reapproval")
# rescue e
# end
# end
else
bulletin.save
end
build_email(bulletin)
redirect_to params['referer_url']
end

View File

@ -210,6 +210,11 @@ class AnnouncementsController < ApplicationController
links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
update_user = announcement.update_user.member_profile.name rescue ""
request = OrbitHelper.request
meta_desc = announcement.subtitle.nil? || announcement.subtitle == "" ? announcement.text[0..200] : announcement.subtitle
OrbitHelper.render_meta_tags([{"property" => "og:title", "content" => announcement.title},{"property" => "og:site_name", "content" => Site.first.title},{"property" => "og:url", "content" => request.original_url},{"property" => "og:description", "content" => meta_desc},{"property" => "og:image", "content" => "#{request.base_url}#{announcement.image.url}"},{"property" => "og:type", "content" => "Article"}])
{
"tags" => ann_tags,
"categories" => categories,

View File

@ -31,6 +31,39 @@ module Admin::AnnouncementsHelper
request.protocol+(request.host_with_port+'/'+ann_page+'/'+'/'+bulletin.to_param).gsub('//','/') rescue "/"
end
def send_rejection_email(announcement)
user = User.find(announcement.create_user_id) rescue nil
if !user.nil?
email = user.member_profile.email
if !email.nil? && email != ""
url = page_for_bulletin(announcement)
mail = Email.new(:mail_to => email, :mail_subject => "Announcement rejected : #{announcement.title}.", :template => "email/rejection_email.html.erb", :template_data => {"url" => url, "rejector" => current_user.name, "name" => user.name, "reason" => announcement.rejection_reason})
mail.deliver
end
end
end
def send_notification_mail_to_managers(announcement, type)
authorizations = Authorization.where(:module_app_id => @module_app.id)
users = authorizations.collect do |auth|
auth.user
end
users.each do |user|
email = user.member_profile.email
if !email.nil? && email != ""
send_email(user.name, email, announcement, type)
sleep(2)
end
end
end
def send_email(name, useremail, announcement, type)
url = page_for_bulletin(announcement)
template = (type == "approval" ? "email/new_announcement_email.html.erb" : "email/reapproval_announcement_email.html.erb")
email = Email.new(:mail_to => useremail, :mail_subject => "New announcement : #{announcement.title}.", :template => template, :template_data => {"url" => url, "submitter" => current_user.name, "name" => name})
email.deliver
end
def load_access_level
if current_user.is_admin?
@access_level = "admin"

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

@ -46,14 +46,14 @@
<div class="control-group">
<label class="control-label muted"><%= t(:start_date) %></label>
<div class="controls">
<%= f.datetime_picker :postdate, :no_label => true, :new_record => @bulletin.new_record? %>
<%= f.datetime_picker :postdate, :no_label => true, :new_record => @bulletin.new_record?, :data=>{"picker-type" => "range", "range" => "start"} %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t(:end_date) %></label>
<div class="controls">
<%= f.datetime_picker :deadline, :no_label => true, :new_record => @bulletin.new_record? %>
<%= f.datetime_picker :deadline, :no_label => true, :new_record => @bulletin.new_record?,:data=>{"picker-type" => "range", "range" => "end"} %>
</div>
</div>

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?) || (b.rejected && !b.approved && user_can_approve? && !b.expired? && b.reapproval) %>
<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

@ -0,0 +1,3 @@
<h3>Hello <%= @data["name"] %>,</h3>
<p><%= @data["submitter"] %> submitted a new announcement.
<a href="<%= @data['url'] %>" > Please click here to view the announcement.</a>

View File

@ -0,0 +1,3 @@
<h3>Hello <%= @data["name"] %>,</h3>
<p><%= @data["submitter"] %> updated the announcement.
<a href="<%= @data['url'] %>" > Please click here to view the annoucement.</a>

View File

@ -0,0 +1,3 @@
<h3>Hello <%= @data["name"] %>,</h3>
<p><%= @data["rejector"] %> has rejected your announcement<%= @data["reason"].nil? || @data["reason"] == "" ? "." : ", because #{@data["reason"]}" %></p>
<a href="<%= @data['url'] %>" > Please click here to view the annoucement.</a>

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: 公告

View File

@ -6,7 +6,9 @@ module Announcement
base_url File.expand_path File.dirname(__FILE__)
widget_methods ["widget"]
widget_settings [{"data_count"=>10}]
models_to_cache [:bulletin]
taggable "Bulletin"
models_to_cache [:bulletin]
categorizable
authorizable
frontend_enabled