Add Approval
This commit is contained in:
parent
5bab384195
commit
6ae35f3b94
|
@ -1,3 +1,4 @@
|
|||
# encoding: utf-8
|
||||
class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendController
|
||||
before_filter :authenticate_user!
|
||||
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.de_pending
|
||||
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')
|
||||
else
|
||||
notice = t('announcement.approve_bulletin_fail')
|
||||
|
@ -62,4 +71,43 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
|
|||
object_auth
|
||||
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
|
||||
|
|
|
@ -94,23 +94,23 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||
|
||||
@bulletin.create_user_id = current_user.id
|
||||
@bulletin.update_user_id = current_user.id
|
||||
# if(is_manager? || is_admin?)
|
||||
# @bulletin.is_checked = true
|
||||
# @bulletin.is_rejected = false
|
||||
# @bulletin.de_pending
|
||||
# end
|
||||
|
||||
if(is_manager? || is_admin?)
|
||||
@bulletin.is_checked = true
|
||||
@bulletin.is_rejected = false
|
||||
@bulletin.de_pending
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
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)
|
||||
|
||||
@bulletin.email_sent = false
|
||||
@bulletin.save
|
||||
end
|
||||
|
||||
|
||||
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.js
|
||||
|
@ -146,7 +146,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||
respond_to do |format|
|
||||
if @bulletin.update_attributes(params[:bulletin])
|
||||
|
||||
if @bulletin.email_sent == true && (is_manager? || is_admin?)
|
||||
if(is_manager? || is_admin?)
|
||||
@bulletin.is_checked = true
|
||||
@bulletin.is_rejected = false
|
||||
@bulletin.de_pending!
|
||||
end
|
||||
|
||||
if @bulletin.email_sent == true && @bulletin.is_checked == true && !@bulletin.is_rejected
|
||||
send_email_data(@bulletin)
|
||||
|
||||
@bulletin.email_sent = false
|
||||
|
|
|
@ -25,8 +25,16 @@ class Bulletin
|
|||
field :create_user_id
|
||||
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 :not_checked_reason
|
||||
|
||||
field :public, :type => Boolean, :default => true
|
||||
|
||||
field :email_sent, :type => Boolean, :default => false
|
||||
|
@ -34,6 +42,9 @@ class Bulletin
|
|||
field :email_user_ids
|
||||
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
|
||||
|
||||
has_many :bulletin_links, :autosave => true, :dependent => :destroy
|
||||
|
@ -114,6 +125,36 @@ class Bulletin
|
|||
|
||||
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
|
||||
self.bulletin_links.each do |t|
|
||||
|
|
|
@ -5,9 +5,19 @@
|
|||
<a class="close" data-dismiss="modal">×</a>
|
||||
<h3><%= t(:preview) %></h3>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
||||
<%= form_for bulletin, :url => panel_announcement_back_end_bulletin_approve_path(bulletin),:method => :post, :html => {:class => 'form-horizontal'} do |f| %>
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
quick_edit_link type: 'delete',
|
||||
link: 'panel_announcement_back_end_bulletin_path'
|
||||
# can have: title, warning, cancel and submit values
|
||||
# quick_edit_link type: 'approval',
|
||||
# link: 'panel_announcement_back_end_bulletin_approval_preview_path'
|
||||
# quick_edit_link type: 'reject_reason'
|
||||
quick_edit_link type: 'approval',
|
||||
link: 'panel_announcement_back_end_bulletin_approval_preview_path'
|
||||
quick_edit_link type: 'reject_reason'
|
||||
field type: 'status',
|
||||
db_field: @statuses,
|
||||
translation: 'status',
|
||||
|
|
|
@ -28,13 +28,13 @@ module Announcement
|
|||
data_count 1..10
|
||||
|
||||
authorizable
|
||||
# approvable
|
||||
approvable
|
||||
categorizable
|
||||
taggable
|
||||
|
||||
widgets 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"]
|
||||
image :image
|
||||
field :postdate
|
||||
|
|
Loading…
Reference in New Issue