Compare commits

..

1 Commits
master ... temp

Author SHA1 Message Date
JiangRu 5837e842e1 add is_hidden didn't show on json 2015-04-15 20:30:48 +08:00
13 changed files with 35 additions and 90 deletions

View File

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

View File

@ -19,6 +19,8 @@ class Admin::BulletinsController < ApplicationController
end end
bulletins = bulletins.where(:is_hot => params[:is_hot]) if !params[:is_hot].blank? bulletins = bulletins.where(:is_hot => params[:is_hot]) if !params[:is_hot].blank?
bulletins = bulletins.where(:is_hidden => false)
bulletins = bulletins.where(:category_id.in => params[:categories]) if !params[:categories].blank? bulletins = bulletins.where(:category_id.in => params[:categories]) if !params[:categories].blank?
bulletins = bulletins.where(:tagged_ids.in => params[:tags]) if !params[:tags].blank? bulletins = bulletins.where(:tagged_ids.in => params[:tags]) if !params[:tags].blank?
bulletins = bulletins.where(:is_preview.in=>[false,nil]) bulletins = bulletins.where(:is_preview.in=>[false,nil])

View File

@ -210,11 +210,6 @@ class AnnouncementsController < ApplicationController
links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue [] 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 "" 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, "tags" => ann_tags,
"categories" => categories, "categories" => categories,

View File

@ -31,39 +31,6 @@ module Admin::AnnouncementsHelper
request.protocol+(request.host_with_port+'/'+ann_page+'/'+'/'+bulletin.to_param).gsub('//','/') rescue "/" request.protocol+(request.host_with_port+'/'+ann_page+'/'+'/'+bulletin.to_param).gsub('//','/') rescue "/"
end 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 def load_access_level
if current_user.is_admin? if current_user.is_admin?
@access_level = "admin" @access_level = "admin"

View File

@ -20,7 +20,6 @@ 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

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

View File

@ -17,6 +17,30 @@
<%= 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 %>
@ -34,14 +58,6 @@
<%= 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? %>
@ -51,6 +67,7 @@
<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 %>
@ -58,6 +75,7 @@
<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 %>
@ -73,7 +91,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>
@ -83,7 +101,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?) || (b.rejected && !b.approved && user_can_approve? && !b.expired? && b.reapproval) %> <% 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

@ -1,3 +0,0 @@
<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

@ -1,3 +0,0 @@
<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

@ -1,3 +0,0 @@
<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,7 +9,6 @@ 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,7 +10,6 @@ zh_tw:
dept_title: 單位 dept_title: 單位
add_new: 新建 add_new: 新建
approve: 審核 approve: 審核
reapproval: 重新審核
tag_cloud: 標籤雲 tag_cloud: 標籤雲
all_articles: 文章列表 all_articles: 文章列表
announcement: 公告 announcement: 公告

View File

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