Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
manson | 0b88e53b62 | |
spen | b8464ae461 | |
spen | a357ce6669 | |
spen | be8d8ff1e6 | |
rulingcom | f31481af18 | |
Manson Wang | 829fc54a1d | |
spen | 6ae35f3b94 |
|
@ -1,3 +1,4 @@
|
||||||
|
# encoding: utf-8
|
||||||
class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendController
|
class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
before_filter :is_admin?
|
before_filter :is_admin?
|
||||||
|
@ -15,6 +16,14 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
|
||||||
@bulletin.proc_check(params[:bulletin][:is_checked],params[:bulletin][:not_checked_reason])
|
@bulletin.proc_check(params[:bulletin][:is_checked],params[:bulletin][:not_checked_reason])
|
||||||
@bulletin.de_pending
|
@bulletin.de_pending
|
||||||
if @bulletin.save
|
if @bulletin.save
|
||||||
|
|
||||||
|
if @bulletin.email_sent == true && @bulletin.is_checked == true && !@bulletin.is_rejected
|
||||||
|
send_email_data(@bulletin)
|
||||||
|
|
||||||
|
@bulletin.email_sent = false
|
||||||
|
@bulletin.save
|
||||||
|
end
|
||||||
|
|
||||||
notice = t('announcement.approve_bulletin_success')
|
notice = t('announcement.approve_bulletin_success')
|
||||||
else
|
else
|
||||||
notice = t('announcement.approve_bulletin_fail')
|
notice = t('announcement.approve_bulletin_fail')
|
||||||
|
@ -61,5 +70,44 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
|
||||||
object_auth.privilege_users = privilege_users
|
object_auth.privilege_users = privilege_users
|
||||||
object_auth
|
object_auth
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def send_email_data(bulletin)
|
||||||
|
|
||||||
|
@site = Site.first
|
||||||
|
@user = User.find(bulletin.create_user_id)
|
||||||
|
@host = request.host_with_port
|
||||||
|
|
||||||
|
@group_mail = MailCron.get_send_group_mail( bulletin.email_user_ids , bulletin.other_mailaddress )
|
||||||
|
|
||||||
|
if !@group_mail.join.blank?
|
||||||
|
|
||||||
|
@mail_content = {
|
||||||
|
"host" => @host,
|
||||||
|
"lang" => I18n.locale,
|
||||||
|
"site_title" => @site.title,
|
||||||
|
"title" => bulletin.title,
|
||||||
|
"template" => 'announcement_mailer/cron_mail',
|
||||||
|
"url" => "http://#{@host}#{panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category.id)}"
|
||||||
|
}
|
||||||
|
|
||||||
|
@mail_cron = {
|
||||||
|
:mail_from_app => 'announcement',
|
||||||
|
# :mail_from => @user.email,
|
||||||
|
# :mail_reply_to => @user.email,
|
||||||
|
:mail_subject => "#{t("announcement.mail_subject",:site_title => @site.title)}:#{bulletin.title}",
|
||||||
|
:mail_to => @group_mail.join(','),
|
||||||
|
:mail_content => @mail_content ,
|
||||||
|
:mail_sentdate => bulletin.email_sentdate,
|
||||||
|
:create_user_id => bulletin.create_user_id,
|
||||||
|
:update_user_id => bulletin.create_user_id
|
||||||
|
}
|
||||||
|
|
||||||
|
@mail_cron = MailCron.new(@mail_cron)
|
||||||
|
|
||||||
|
@mail_cron.save
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -94,23 +94,23 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
|
|
||||||
@bulletin.create_user_id = current_user.id
|
@bulletin.create_user_id = current_user.id
|
||||||
@bulletin.update_user_id = current_user.id
|
@bulletin.update_user_id = current_user.id
|
||||||
# if(is_manager? || is_admin?)
|
|
||||||
# @bulletin.is_checked = true
|
if(is_manager? || is_admin?)
|
||||||
# @bulletin.is_rejected = false
|
@bulletin.is_checked = true
|
||||||
# @bulletin.de_pending
|
@bulletin.is_rejected = false
|
||||||
# end
|
@bulletin.de_pending
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @bulletin.save
|
if @bulletin.save
|
||||||
|
|
||||||
if @bulletin.email_sent == true && (is_manager? || is_admin?)
|
if @bulletin.email_sent == true && @bulletin.is_checked == true && !@bulletin.is_rejected
|
||||||
send_email_data(@bulletin)
|
send_email_data(@bulletin)
|
||||||
|
|
||||||
@bulletin.email_sent = false
|
@bulletin.email_sent = false
|
||||||
@bulletin.save
|
@bulletin.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
|
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
|
||||||
format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin }
|
format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin }
|
||||||
# format.js
|
# format.js
|
||||||
|
@ -135,38 +135,44 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
# PUT /bulletins/1.xml
|
# PUT /bulletins/1.xml
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@bulletin = Bulletin.find(params[:id])
|
@bulletin = Bulletin.find(params[:id])
|
||||||
|
|
||||||
params[:bulletin][:tag_ids] = (params[:bulletin][:tag_ids] ? params[:bulletin][:tag_ids] : [])
|
params[:bulletin][:tag_ids] = (params[:bulletin][:tag_ids] ? params[:bulletin][:tag_ids] : [])
|
||||||
|
|
||||||
params[:bulletin][:email_user_ids] = params[:bulletin][:email_user_ids].uniq
|
params[:bulletin][:email_user_ids] = params[:bulletin][:email_user_ids].uniq
|
||||||
params[:bulletin][:email_user_ids].delete('')
|
params[:bulletin][:email_user_ids].delete('')
|
||||||
|
|
||||||
params[:bulletin][:update_user_id] = current_user.id
|
params[:bulletin][:update_user_id] = current_user.id
|
||||||
|
|
||||||
delete_out_invalid_date_from_params
|
delete_out_invalid_date_from_params
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @bulletin.update_attributes(params[:bulletin])
|
if @bulletin.update_attributes(params[:bulletin])
|
||||||
|
|
||||||
if @bulletin.email_sent == true && (is_manager? || is_admin?)
|
if(is_manager? || is_admin?)
|
||||||
send_email_data(@bulletin)
|
@bulletin.is_checked = true
|
||||||
|
@bulletin.is_rejected = false
|
||||||
@bulletin.email_sent = false
|
@bulletin.de_pending!
|
||||||
@bulletin.save
|
|
||||||
end
|
|
||||||
|
|
||||||
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
|
|
||||||
format.js { render 'toggle_enable' }
|
|
||||||
format.xml { head :ok }
|
|
||||||
else
|
|
||||||
@tags = get_tags
|
|
||||||
format.html { render :action => "edit" }
|
|
||||||
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
if @bulletin.email_sent == true && @bulletin.is_checked == true && !@bulletin.is_rejected
|
||||||
|
send_email_data(@bulletin)
|
||||||
|
|
||||||
|
@bulletin.email_sent = false
|
||||||
|
@bulletin.save
|
||||||
|
end
|
||||||
|
|
||||||
|
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
|
||||||
|
format.js { render 'toggle_enable' }
|
||||||
|
format.xml { head :ok }
|
||||||
|
else
|
||||||
|
@tags = get_tags
|
||||||
|
format.html { render :action => "edit" }
|
||||||
|
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
# DELETE /bulletins/1
|
# DELETE /bulletins/1
|
||||||
# DELETE /bulletins/1.xml
|
# DELETE /bulletins/1.xml
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
@ -25,14 +25,25 @@ class Bulletin
|
||||||
field :create_user_id
|
field :create_user_id
|
||||||
field :update_user_id, :class_name => "User"
|
field :update_user_id, :class_name => "User"
|
||||||
|
|
||||||
|
field :is_top, :type => Boolean, :default => false
|
||||||
|
field :is_hot, :type => Boolean, :default => false
|
||||||
|
field :is_hidden, :type => Boolean, :default => false
|
||||||
|
field :is_checked, :type => Boolean, :default => false
|
||||||
|
field :is_pending, :type => Boolean, :default => true
|
||||||
|
field :is_rejected, :type => Boolean, :default => false
|
||||||
field :view_count, :type => Integer, :default => 0
|
field :view_count, :type => Integer, :default => 0
|
||||||
|
|
||||||
|
field :not_checked_reason
|
||||||
|
|
||||||
field :public, :type => Boolean, :default => true
|
field :public, :type => Boolean, :default => true
|
||||||
|
|
||||||
field :email_sent, :type => Boolean, :default => false
|
field :email_sent, :type => Boolean, :default => false
|
||||||
field :email_sentdate , :type => DateTime
|
field :email_sentdate , :type => DateTime
|
||||||
field :email_user_ids
|
field :email_user_ids
|
||||||
field :other_mailaddress
|
field :other_mailaddress
|
||||||
|
|
||||||
|
scope :can_display, where(is_checked: true, is_rejected: false, is_pending: false)
|
||||||
|
scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
||||||
|
|
||||||
mount_uploader :image, ImageUploader
|
mount_uploader :image, ImageUploader
|
||||||
|
|
||||||
|
@ -114,6 +125,36 @@ class Bulletin
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def proc_check(check,not_pass_info = "")
|
||||||
|
self.is_checked = true
|
||||||
|
if check =="true"
|
||||||
|
self.is_rejected = false
|
||||||
|
elsif check == "false"
|
||||||
|
self.is_rejected = true
|
||||||
|
self.not_checked_reason = not_pass_info
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def de_pending
|
||||||
|
self.is_pending = false
|
||||||
|
end
|
||||||
|
|
||||||
|
def de_pending!
|
||||||
|
de_pending
|
||||||
|
self.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_checked?
|
||||||
|
!self.is_pending && self.is_checked && (self.is_rejected == false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_pending?
|
||||||
|
self.is_pending
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_rejected?
|
||||||
|
!self.is_pending && self.is_rejected && (self.is_rejected == true)
|
||||||
|
end
|
||||||
|
|
||||||
def save_bulletin_links
|
def save_bulletin_links
|
||||||
self.bulletin_links.each do |t|
|
self.bulletin_links.each do |t|
|
||||||
|
|
|
@ -5,8 +5,18 @@
|
||||||
<a class="close" data-dismiss="modal">×</a>
|
<a class="close" data-dismiss="modal">×</a>
|
||||||
<h3><%= t(:preview) %></h3>
|
<h3><%= t(:preview) %></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body clearfix">
|
||||||
|
<div class="modal-left">
|
||||||
|
<%= label_tag t('announcement.email_to') %>
|
||||||
|
<% if @bulletin.email_sent == true and ( !@bulletin.email_user_ids.blank? || !@bulletin.other_mailaddress.blank? ) %>
|
||||||
|
|
||||||
|
<%= MailCron.get_send_group_mail(@bulletin.email_user_ids , @bulletin.other_mailaddress).join("<br />").html_safe %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-right">
|
||||||
<iframe src=<%= panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category.id ,:preview=>true) %>></iframe>
|
<iframe src=<%= panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category.id ,:preview=>true) %>></iframe>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
quick_edit_link type: 'delete',
|
quick_edit_link type: 'delete',
|
||||||
link: 'panel_announcement_back_end_bulletin_path'
|
link: 'panel_announcement_back_end_bulletin_path'
|
||||||
# can have: title, warning, cancel and submit values
|
# can have: title, warning, cancel and submit values
|
||||||
# quick_edit_link type: 'approval',
|
quick_edit_link type: 'approval',
|
||||||
# link: 'panel_announcement_back_end_bulletin_approval_preview_path'
|
link: 'panel_announcement_back_end_bulletin_approval_preview_path'
|
||||||
# quick_edit_link type: 'reject_reason'
|
quick_edit_link type: 'reject_reason'
|
||||||
field type: 'status',
|
field type: 'status',
|
||||||
db_field: @statuses,
|
db_field: @statuses,
|
||||||
translation: 'status',
|
translation: 'status',
|
||||||
|
|
|
@ -28,13 +28,13 @@ module Announcement
|
||||||
data_count 1..10
|
data_count 1..10
|
||||||
|
|
||||||
authorizable
|
authorizable
|
||||||
# approvable
|
approvable
|
||||||
categorizable
|
categorizable
|
||||||
taggable
|
taggable
|
||||||
|
|
||||||
widgets do
|
widgets do
|
||||||
default_widget do
|
default_widget do
|
||||||
query 'Bulletin'
|
query 'Bulletin.can_display.available_for_lang(I18n.locale).any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )'
|
||||||
enable ["typeA", "typeB_style3", "typeC"]
|
enable ["typeA", "typeB_style3", "typeC"]
|
||||||
image :image
|
image :image
|
||||||
field :postdate
|
field :postdate
|
||||||
|
|
Loading…
Reference in New Issue