Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fbea06642 | ||
|
|
ce2ec4fc1a | ||
|
|
39386930ef | ||
|
|
ca2b66a210 | ||
|
|
a39d979a54 | ||
|
|
d88b2a4e32 | ||
|
|
a7005c6e8b | ||
|
|
768f03954f | ||
|
|
64b80092f6 | ||
|
|
8e89a1647d | ||
|
|
7121223a4d | ||
|
|
eb7627a28a | ||
|
|
7193e2efb4 | ||
|
|
45d9bbc342 | ||
|
|
5bab384195 | ||
|
|
cfda9365ab | ||
|
|
f38985bb34 | ||
|
|
dc3a44d181 | ||
|
|
592692eefd | ||
|
|
c10800acd7 | ||
|
|
c96646844a | ||
|
|
5efebe2ab2 | ||
|
|
60dce13fd8 | ||
|
|
16aacf3d2a | ||
|
|
0e5909c1f5 | ||
|
|
758ceaf5e3 | ||
|
|
1dfa7e91ee | ||
|
|
caad66cfb8 | ||
|
|
781a49750e | ||
|
|
0af4fb0502 | ||
|
|
62fbcee0f0 | ||
|
|
8306511819 | ||
|
|
beac76f29a | ||
|
|
725bfcac5a | ||
|
|
c9dd3cb9eb | ||
|
|
c0473a3f13 | ||
|
|
0587c118d1 |
No files matched your search
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
= Announcement
|
= Announcement
|
||||||
|
|
||||||
This project rocks and uses MIT-LICENSE.
|
This project rocks and uses MIT-LICENSE.
|
||||||
|
* Tagging
|
||||||
|
* Categories
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
@@ -0,0 +1,83 @@
|
|||||||
|
# API for Announcement Module
|
||||||
|
#
|
||||||
|
# Simple access control
|
||||||
|
# params[:access_token] = Site ID
|
||||||
|
# ex: /panel/announcement/api/bulletins.json?access_token=5301d8be45d5f42f4f000001
|
||||||
|
#
|
||||||
|
# Set Language
|
||||||
|
# Language can be "zh_tw" or "en"
|
||||||
|
# ex: /panel/announcement/api/bulletins.json?lang=en&access_token=5301d8be45d5f42f4f000001
|
||||||
|
#
|
||||||
|
# Get Categories and Tags
|
||||||
|
# ex: /panel/announcement/api/categories_tags.json&access_token=5301d8be45d5f42f4f000001
|
||||||
|
#
|
||||||
|
# Query Bulletins
|
||||||
|
# Set page number use params[:page_num]
|
||||||
|
# Set number of results per page use params[:per_page]
|
||||||
|
# ex: /panel/announcement/api/bulletins.json?page_num=3&per_page=15&access_token=5301d8be45d5f42f4f000001
|
||||||
|
#
|
||||||
|
# Filter bulletins with categories use params[:categories]
|
||||||
|
# ex: /panel/announcement/api/bulletins.json?categories[]=53046e4045d5f462a2000006&access_token=5301d8be45d5f42f4f000001
|
||||||
|
#
|
||||||
|
# Filter bulletins with tags use params[:tags]
|
||||||
|
# ex: /panel/announcement/api/bulletins.json?tags[]=5318e58d45d5f41127000007&access_token=5301d8be45d5f42f4f000001
|
||||||
|
#
|
||||||
|
# Filter bulletins with "is_hot" use params[:is_hot]
|
||||||
|
# ex: /panel/announcement/api/bulletins.json?is_hot=1&access_token=5301d8be45d5f42f4f000001
|
||||||
|
#
|
||||||
|
# Search bulletin title, subtitle, text with params[:keyword]
|
||||||
|
# ex: /panel/announcement/api/bulletins.json?keyword=大學&access_token=5301d8be45d5f42f4f000001
|
||||||
|
|
||||||
|
class Panel::Announcement::Api::BulletinsController < OrbitWidgetController
|
||||||
|
before_filter :set_I18n, :check_site_id
|
||||||
|
|
||||||
|
def get_categories_tags
|
||||||
|
module_id = ModuleApp.where(:key=>"announcement").first.id
|
||||||
|
categories = Category.where(:module_app_id => module_id).collect{|c| {"id"=>c.id, "title"=>c.title_translations}}
|
||||||
|
module_tags = ModuleTag.where(:module_app_id => module_id).collect{|t| t.id}
|
||||||
|
tags = Tag.any_of({:tag_lease_id.in => module_tags}).collect{|t| {"id"=>t.id, "title"=>t.name_translations}}
|
||||||
|
|
||||||
|
render :json => {
|
||||||
|
"categories" => categories,
|
||||||
|
"tags" => tags
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_bulletins
|
||||||
|
page_num = params[:page_num].blank? ? 0 : params[:page_num].to_i
|
||||||
|
per_page = params[:per_page].blank? ? 10 : params[:per_page].to_i
|
||||||
|
per_page = per_page > 0 ? per_page : 10
|
||||||
|
|
||||||
|
if !params[:keyword].blank?
|
||||||
|
keyword = Regexp.new(".*"+params[:keyword]+".*")
|
||||||
|
bulletins = Bulletin.any_of({:title=>keyword},{:subtitle=>keyword},{:text=>keyword}).available_for_lang(I18n.locale)
|
||||||
|
else
|
||||||
|
bulletins = Bulletin.available_for_lang(I18n.locale)
|
||||||
|
end
|
||||||
|
|
||||||
|
bulletins = bulletins.where(:is_hot => params[:is_hot]) if !params[:is_hot].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.desc( :is_top, :postdate).page(page_num).per(per_page)
|
||||||
|
|
||||||
|
total_pages = (bulletins.count / per_page) + 1
|
||||||
|
render :json => {
|
||||||
|
"bulletins" => bulletins,
|
||||||
|
"bulletins_count" => bulletins.count,
|
||||||
|
"page_num" => page_num,
|
||||||
|
"total_pages" => total_pages,
|
||||||
|
"lang"=>I18n.locale
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def set_I18n
|
||||||
|
I18n.locale = params[:lang] if params[:lang].present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_site_id
|
||||||
|
raise ActionController::RoutingError.new('Not Found') if Site.first.id.to_s != params['access_token']
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
# 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?
|
||||||
@@ -7,7 +6,6 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
|
|||||||
|
|
||||||
|
|
||||||
def preview_and_approve
|
def preview_and_approve
|
||||||
email_group_data
|
|
||||||
@bulletin = Bulletin.find params[:bulletin_id]
|
@bulletin = Bulletin.find params[:bulletin_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -17,14 +15,6 @@ 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')
|
||||||
@@ -71,68 +61,5 @@ 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
|
|
||||||
|
|
||||||
email_group_data
|
|
||||||
|
|
||||||
@group_mail = Array.new
|
|
||||||
|
|
||||||
bulletin.email_group.each do |egroup|
|
|
||||||
|
|
||||||
if @email_group_data.include?(egroup) and (egroup == 'e_0' or egroup == 'e_1' or egroup == 'e_2' or egroup == 'e_3')
|
|
||||||
|
|
||||||
@group_mail << @email_group_data[egroup]["email"]
|
|
||||||
|
|
||||||
elsif @email_group_data.include?(egroup) and egroup == 'e_4'
|
|
||||||
|
|
||||||
@group_mail << bulletin.other_mailaddress
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
if !@group_mail.join.blank?
|
|
||||||
|
|
||||||
@mail_content = {
|
|
||||||
"host" => @host,
|
|
||||||
"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,
|
|
||||||
:mail_sentdate => DateTime.now,
|
|
||||||
:create_user_id => bulletin.create_user_id,
|
|
||||||
:update_user_id => bulletin.create_user_id
|
|
||||||
}
|
|
||||||
|
|
||||||
@mail_cron = MailCron.new(@mail_cron)
|
|
||||||
|
|
||||||
@mail_cron.save
|
|
||||||
|
|
||||||
MailCron.send_mail_now(@mail_cron.id)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def email_group_data
|
|
||||||
|
|
||||||
@email_group_data = Bulletin.email_group_data
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||||
# include OrbitControllerLib::DivisionForDisable
|
# include OrbitControllerLib::DivisionForDisable
|
||||||
|
|
||||||
@@ -21,14 +20,17 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||||||
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
email_group_data
|
|
||||||
|
|
||||||
@tags = get_tags
|
@tags = get_tags
|
||||||
@categories = get_categories_for_index
|
@categories = get_categories_for_index
|
||||||
@statuses = get_statuses
|
@statuses = get_statuses
|
||||||
category_ids = @categories.collect{|t| t.id}
|
category_ids = @categories.collect{|t| t.id}
|
||||||
|
|
||||||
@bulletins = get_sorted_and_filtered("bulletin", :category_id.in => category_ids)
|
if is_manager? or is_admin?
|
||||||
|
@bulletins = get_sorted_and_filtered("bulletin", :category_id.in => category_ids)
|
||||||
|
else
|
||||||
|
@bulletins = get_sorted_and_filtered("bulletin", {:category_id.in => category_ids, :create_user_id => current_user.id})
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
format.js { }
|
format.js { }
|
||||||
@@ -51,11 +53,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||||||
# GET /bulletins/new
|
# GET /bulletins/new
|
||||||
# GET /bulletins/new.xml
|
# GET /bulletins/new.xml
|
||||||
def new
|
def new
|
||||||
|
|
||||||
email_group_data
|
|
||||||
|
|
||||||
if(session[:in_validate_object].blank?)
|
if(session[:in_validate_object].blank?)
|
||||||
@bulletin = Bulletin.new(:postdate => DateTime.now)
|
@bulletin = Bulletin.new(:postdate => DateTime.now, :email_sentdate => DateTime.now)
|
||||||
else
|
else
|
||||||
@bulletin = session[:in_validate_object]
|
@bulletin = session[:in_validate_object]
|
||||||
session[:in_validate_object] = {}
|
session[:in_validate_object] = {}
|
||||||
@@ -71,14 +70,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||||||
|
|
||||||
# GET /bulletins/1/edit
|
# GET /bulletins/1/edit
|
||||||
def edit
|
def edit
|
||||||
|
|
||||||
email_group_data
|
|
||||||
|
|
||||||
@bulletin = Bulletin.find(params[:id])
|
@bulletin = Bulletin.find(params[:id])
|
||||||
|
@email_users = @bulletin.get_email_users
|
||||||
@tags = get_tags
|
@tags = get_tags
|
||||||
is_authorized_sub_manager = @bulletin.category.auth_sub_manager.authorized_user_ids rescue nil
|
is_authorized_sub_manager = @bulletin.category.auth_sub_manager.authorized_user_ids rescue nil
|
||||||
|
|
||||||
if !(is_manager? || is_admin? || (is_authorized_sub_manager.include?(current_user.id) and @bulletin.create_user_id == current_user.id))
|
if !(is_manager? || is_admin? || (is_authorized_sub_manager.include?(current_user.id) and @bulletin.create_user_id == current_user.id))
|
||||||
|
|
||||||
redirect_to :action => :index
|
redirect_to :action => :index
|
||||||
else
|
else
|
||||||
# @summary_variable = @bulletin.summary_variable
|
# @summary_variable = @bulletin.summary_variable
|
||||||
@@ -92,31 +90,33 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||||||
# POST /bulletins
|
# POST /bulletins
|
||||||
# POST /bulletins.xml
|
# POST /bulletins.xml
|
||||||
def create
|
def create
|
||||||
|
|
||||||
email_group_data
|
|
||||||
|
|
||||||
@tags = get_tags
|
@tags = get_tags
|
||||||
|
|
||||||
|
params[:bulletin][:email_user_ids] = params[:bulletin][:email_user_ids].uniq
|
||||||
|
params[:bulletin][:email_user_ids].delete('')
|
||||||
|
|
||||||
@bulletin = Bulletin.new(params[:bulletin])
|
@bulletin = Bulletin.new(params[:bulletin])
|
||||||
@bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
|
@bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil)
|
||||||
|
|
||||||
@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?)
|
# if(is_manager? || is_admin?)
|
||||||
@bulletin.is_checked = true
|
# @bulletin.is_checked = true
|
||||||
@bulletin.is_rejected = false
|
# @bulletin.is_rejected = false
|
||||||
@bulletin.de_pending
|
# @bulletin.de_pending
|
||||||
end
|
# end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @bulletin.save
|
if @bulletin.save
|
||||||
|
|
||||||
if @bulletin.email_sent == true && @bulletin.is_checked == true && !@bulletin.is_rejected
|
if @bulletin.email_sent == true && (is_manager? || is_admin?)
|
||||||
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
|
||||||
@@ -141,20 +141,26 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||||||
# PUT /bulletins/1.xml
|
# PUT /bulletins/1.xml
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@bulletin = Bulletin.find(params[:id])
|
||||||
|
|
||||||
email_group_data
|
params[:bulletin][:tag_ids] = (params[:bulletin][:tag_ids] ? params[:bulletin][:tag_ids] : [])
|
||||||
|
|
||||||
@bulletin = Bulletin.find(params[:id])
|
|
||||||
|
|
||||||
params[:bulletin][:update_user_id] = current_user.id
|
params[:bulletin][:email_user_ids] = params[:bulletin][:email_user_ids].uniq
|
||||||
|
params[:bulletin][:email_user_ids].delete('')
|
||||||
|
|
||||||
|
params[:bulletin][:update_user_id] = current_user.id
|
||||||
|
|
||||||
|
delete_out_invalid_date_from_params
|
||||||
|
respond_to do |format|
|
||||||
|
if @bulletin.update_attributes(params[:bulletin])
|
||||||
|
|
||||||
|
if @bulletin.email_sent == true && (is_manager? || is_admin?)
|
||||||
|
send_email_data(@bulletin)
|
||||||
|
|
||||||
|
@bulletin.email_sent = false
|
||||||
|
@bulletin.save
|
||||||
|
end
|
||||||
|
|
||||||
delete_out_invalid_date_from_params
|
|
||||||
respond_to do |format|
|
|
||||||
if @bulletin.update_attributes(params[:bulletin])
|
|
||||||
if(is_manager? || is_admin?)
|
|
||||||
@bulletin.is_checked = true
|
|
||||||
@bulletin.is_rejected = false
|
|
||||||
@bulletin.de_pending!
|
|
||||||
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
|
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
|
||||||
format.js { render 'toggle_enable' }
|
format.js { render 'toggle_enable' }
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
@@ -163,27 +169,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||||||
format.html { render :action => "edit" }
|
format.html { render :action => "edit" }
|
||||||
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
|
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
|
||||||
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
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
# DELETE /bulletins/1
|
# DELETE /bulletins/1
|
||||||
# DELETE /bulletins/1.xml
|
# DELETE /bulletins/1.xml
|
||||||
def destroy
|
def destroy
|
||||||
@@ -215,28 +204,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||||||
@user = User.find(bulletin.create_user_id)
|
@user = User.find(bulletin.create_user_id)
|
||||||
@host = request.host_with_port
|
@host = request.host_with_port
|
||||||
|
|
||||||
email_group_data
|
@group_mail = MailCron.get_send_group_mail( bulletin.email_user_ids , bulletin.other_mailaddress )
|
||||||
|
|
||||||
@group_mail = Array.new
|
|
||||||
|
|
||||||
bulletin.email_group.each do |egroup|
|
|
||||||
|
|
||||||
if @email_group_data.include?(egroup) and (egroup == 'e_0' or egroup == 'e_1' or egroup == 'e_2' or egroup == 'e_3')
|
|
||||||
|
|
||||||
@group_mail << @email_group_data[egroup]["email"]
|
|
||||||
|
|
||||||
elsif @email_group_data.include?(egroup) and egroup == 'e_4'
|
|
||||||
|
|
||||||
@group_mail << bulletin.other_mailaddress
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
if !@group_mail.join.blank?
|
if !@group_mail.join.blank?
|
||||||
|
|
||||||
@mail_content = {
|
@mail_content = {
|
||||||
"host" => @host,
|
"host" => @host,
|
||||||
|
"lang" => I18n.locale,
|
||||||
"site_title" => @site.title,
|
"site_title" => @site.title,
|
||||||
"title" => bulletin.title,
|
"title" => bulletin.title,
|
||||||
"template" => 'announcement_mailer/cron_mail',
|
"template" => 'announcement_mailer/cron_mail',
|
||||||
@@ -245,14 +219,12 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||||||
|
|
||||||
@mail_cron = {
|
@mail_cron = {
|
||||||
:mail_from_app => 'announcement',
|
:mail_from_app => 'announcement',
|
||||||
:mail_from => @user.email,
|
# :mail_from => @user.email,
|
||||||
:mail_reply_to => @user.email,
|
# :mail_reply_to => @user.email,
|
||||||
:mail_subject => "#{t("announcement.mail_subject")}:",
|
|
||||||
:mail_subject => "#{t("announcement.mail_subject",:site_title => @site.title)}:#{bulletin.title}",
|
:mail_subject => "#{t("announcement.mail_subject",:site_title => @site.title)}:#{bulletin.title}",
|
||||||
:mail_to => @group_mail.join(','),
|
:mail_to => @group_mail.join(','),
|
||||||
:mail_content => @mail_content ,
|
:mail_content => @mail_content ,
|
||||||
# :mail_sentdate => bulletin.email_sentdate,
|
:mail_sentdate => bulletin.email_sentdate,
|
||||||
:mail_sentdate => DateTime.now,
|
|
||||||
:create_user_id => bulletin.create_user_id,
|
:create_user_id => bulletin.create_user_id,
|
||||||
:update_user_id => bulletin.create_user_id
|
:update_user_id => bulletin.create_user_id
|
||||||
}
|
}
|
||||||
@@ -261,17 +233,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
|||||||
|
|
||||||
@mail_cron.save
|
@mail_cron.save
|
||||||
|
|
||||||
MailCron.send_mail_now(@mail_cron.id)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def email_group_data
|
|
||||||
|
|
||||||
@email_group_data = Bulletin.email_group_data
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def delete_out_invalid_date_from_params
|
def delete_out_invalid_date_from_params
|
||||||
if((params[:bulletin]["deadline(1i)"] && params[:bulletin]["deadline(1i)"].blank?) or (params[:bulletin]["deadline(2i)"] && params[:bulletin]["deadline(2i)"].blank?) or (params[:bulletin]["deadline(3i)"] && params[:bulletin]["deadline(3i)"].blank?))
|
if((params[:bulletin]["deadline(1i)"] && params[:bulletin]["deadline(1i)"].blank?) or (params[:bulletin]["deadline(2i)"] && params[:bulletin]["deadline(2i)"].blank?) or (params[:bulletin]["deadline(3i)"] && params[:bulletin]["deadline(3i)"].blank?))
|
||||||
|
|||||||
@@ -12,8 +12,13 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
|||||||
if params[:search_query] == ""
|
if params[:search_query] == ""
|
||||||
@bulletins = get_bulletins_for_index
|
@bulletins = get_bulletins_for_index
|
||||||
else
|
else
|
||||||
@search = Bulletin.tire.search "#{params[:search_query]}"
|
key_string = params[:search_query]
|
||||||
search_result = @search.collect{|result| result.id}
|
keywords = key_string.split(/\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/)
|
||||||
|
regex = Regexp.union(keywords.map{|word| Regexp.new(".*"+word+".*", "i")})
|
||||||
|
|
||||||
|
query = ["title","subtitle","text"].map{|f| {f.to_sym => regex} }
|
||||||
|
res = Bulletin.any_of(query)
|
||||||
|
search_result = res.collect{|result| result.id}
|
||||||
|
|
||||||
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(@page_num)
|
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(@page_num)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -166,5 +166,25 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
|
|||||||
def bulletins_search_block
|
def bulletins_search_block
|
||||||
@part = PagePart.find params[:part_id]
|
@part = PagePart.find params[:part_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def sync_data
|
||||||
|
@create_users = ( params[:dept].blank? or !params[:dept].kind_of?(Array)) ? [] : User.where(:sid.in => params[:dept]).collect{|p| p.id}
|
||||||
|
@page_num = params[:page_num].blank? ? '10' : params[:page_num]
|
||||||
|
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:category_id.nin => ['53abbd0b45ef444e6a0001a0','53abbd2045ef444e6a00095d','53abbd0745ef444e6a000001'], :create_user_id.in => @create_users).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_sync_data
|
||||||
|
@bulletin = Bulletin.all.can_display.where(_id: params[:id]).first
|
||||||
|
if @bulletin and !@bulletin.disable?
|
||||||
|
if @bulletin.enabled_for_lang(I18n.locale.to_s)
|
||||||
|
impressionist(@bulletin)
|
||||||
|
else
|
||||||
|
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render :nothing => true, :status => 403
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
+13
-86
@@ -13,10 +13,10 @@ class Bulletin
|
|||||||
include OrbitModel::TimeFrame
|
include OrbitModel::TimeFrame
|
||||||
include OrbitTag::Taggable
|
include OrbitTag::Taggable
|
||||||
|
|
||||||
include Tire::Model::Search
|
# include Tire::Model::Search
|
||||||
include Tire::Model::Callbacks
|
# include Tire::Model::Callbacks
|
||||||
|
|
||||||
is_impressionable :counter_cache => { :column_name => :view_count }
|
is_impressionable
|
||||||
|
|
||||||
field :title, localize: true
|
field :title, localize: true
|
||||||
field :subtitle, localize: true
|
field :subtitle, localize: true
|
||||||
@@ -25,25 +25,14 @@ 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_group, :type => Array
|
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
|
||||||
|
|
||||||
@@ -55,9 +44,9 @@ class Bulletin
|
|||||||
|
|
||||||
validates :title, :at_least_one => true
|
validates :title, :at_least_one => true
|
||||||
|
|
||||||
def to_indexed_json
|
# def to_indexed_json
|
||||||
self.to_json
|
# self.to_json
|
||||||
end
|
# end
|
||||||
|
|
||||||
# search_in :title, :subtitle, :text
|
# search_in :title, :subtitle, :text
|
||||||
|
|
||||||
@@ -79,7 +68,7 @@ class Bulletin
|
|||||||
end
|
end
|
||||||
|
|
||||||
def bulletin_create_dept
|
def bulletin_create_dept
|
||||||
unit_field = User.get_member_list_attribute_field("staff","Unit")
|
unit_field = User.get_member_list_attribute_field("staff","unit")
|
||||||
User.get_member_list_attribute_value(self.create_user_id,unit_field.id).get_value_by_locale(I18n.locale) rescue nil
|
User.get_member_list_attribute_value(self.create_user_id,unit_field.id).get_value_by_locale(I18n.locale) rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -130,37 +119,6 @@ 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|
|
||||||
@@ -201,47 +159,16 @@ class Bulletin
|
|||||||
preview_object
|
preview_object
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_email_group_data(email_group_data)
|
def get_email_users
|
||||||
|
User.find(self.email_user_ids) rescue []
|
||||||
group_mail = Array.new
|
|
||||||
|
|
||||||
self.email_group.each do |egroup|
|
|
||||||
|
|
||||||
if email_group_data.include?(egroup) and (egroup == 'e_0' or egroup == 'e_1' or egroup == 'e_2' or egroup == 'e_3')
|
|
||||||
|
|
||||||
group_mail << "#{email_group_data[egroup]["email"]}(#{email_group_data[egroup]["name"]})"
|
|
||||||
|
|
||||||
elsif email_group_data.include?(egroup) and egroup == 'e_4'
|
|
||||||
|
|
||||||
self.other_mailaddress.split(",").each do |otmail|
|
|
||||||
|
|
||||||
group_mail << "#{otmail}(#{email_group_data[egroup]["name"]})"
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
group_mail.join("<br />").html_safe
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def view_count
|
||||||
|
Impression.where(:impressionable_id=>self.id).count
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def self.email_group_data
|
|
||||||
|
|
||||||
@email_group_data = {
|
|
||||||
'e_0'=> {"name"=>I18n.t('announcement.email_group_data_0'), "email"=>"alluser@tea.ntue.edu.tw"},
|
|
||||||
'e_1'=> {"name"=>I18n.t('announcement.email_group_data_1'), "email"=>"allstu@tea.ntue.edu.tw"},
|
|
||||||
'e_2'=> {"name"=>I18n.t('announcement.email_group_data_2'), "email"=>"allgrad@tea.ntue.edu.tw"},
|
|
||||||
'e_3'=> {"name"=>I18n.t('announcement.email_group_data_3'), "email"=>"allad@tea.ntue.edu.tw"},
|
|
||||||
'e_4'=> {"name"=>I18n.t('announcement.email_group_data_4')}
|
|
||||||
}
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
# def clean_values
|
# def clean_values
|
||||||
# self.bulletin_links.each do |link|
|
# self.bulletin_links.each do |link|
|
||||||
# link.delete if link.url.blank? && link.title.blank?
|
# link.delete if link.url.blank? && link.title.blank?
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<% # encoding: utf-8 %>
|
<% # encoding: utf-8 %>
|
||||||
|
|
||||||
|
<% I18n.locale = @data.mail_content["lang"] %>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|||||||
@@ -5,18 +5,8 @@
|
|||||||
<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 clearfix">
|
<div class="modal-body">
|
||||||
<div class="modal-left">
|
|
||||||
|
|
||||||
<% if !@bulletin.email_group.blank? %>
|
|
||||||
<%= label_tag 'group_mail' %>
|
|
||||||
<%= @bulletin.get_email_group_data(@email_group_data) %>
|
|
||||||
<% 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">
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
||||||
<%= javascript_include_tag "lib/modal-preview" %>
|
<%= javascript_include_tag "lib/modal-preview" %>
|
||||||
<%= javascript_include_tag "lib/file-type" %>
|
<%= javascript_include_tag "lib/file-type" %>
|
||||||
<%= javascript_include_tag "lib/module-area" %>
|
<%= javascript_include_tag "lib/module-area" %>
|
||||||
|
<%= javascript_include_tag "member-selection" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= f.error_messages %>
|
<%= f.error_messages %>
|
||||||
@@ -36,7 +37,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#mail-group" data-toggle="tab"><%= t('announcement.email_reminder')%></a>
|
<a href="#mail-group" data-toggle="tab"><%= t('announcement.email_reminder')%></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!-- Module -->
|
<!-- Module -->
|
||||||
@@ -103,7 +104,6 @@
|
|||||||
<% @tags.each do |tag| %>
|
<% @tags.each do |tag| %>
|
||||||
<label class="checkbox inline btn <%= 'active' if @bulletin.tag_ids.include?(tag.id) %>">
|
<label class="checkbox inline btn <%= 'active' if @bulletin.tag_ids.include?(tag.id) %>">
|
||||||
<%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id) %> <%= tag.name %>
|
<%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id) %> <%= tag.name %>
|
||||||
<%= hidden_field_tag 'bulletin[tag_ids][]', '' %>
|
|
||||||
</label>
|
</label>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
<% if @bulletin.image.file %>
|
<% if @bulletin.image.file %>
|
||||||
<%= image_tag @bulletin.image %>
|
<%= image_tag @bulletin.image %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<img src="http://www.placehold.it/290x230/EFEFEF/AAAAAA" />
|
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
||||||
@@ -138,15 +138,8 @@
|
|||||||
<%= f.check_box :remove_image %><%= t(:remove) %>
|
<%= f.check_box :remove_image %><%= t(:remove) %>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
|
||||||
<span>
|
|
||||||
<%= t("ad.widget_info_for_ad_image_size", :best_size=> "290px(w) x 230px(h)") %>
|
|
||||||
<br />
|
|
||||||
<%= t("announcement.image_upload_size_note", :image_upload_size =>'900kb') %>
|
|
||||||
<br />
|
|
||||||
<%= t("announcement.image_note")%>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="image_note"><%= t("announcement.image_note")%></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -157,24 +150,17 @@
|
|||||||
|
|
||||||
<!-- Mail Group -->
|
<!-- Mail Group -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted"><%= t("announcement.email_group") %></label>
|
<label class="control-label muted"><%= t("announcement.email_to") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
|
||||||
<label class="checkbox inline">
|
<label class="checkbox inline">
|
||||||
<%= check_box_tag('bulletin[email_sent]', '1', (!@bulletin.email_sent.blank? ? true : false), :id=>'remind-check') %><%= t('announcement.activate_email_eminder')%>
|
<%= check_box_tag('bulletin[email_sent]', '1', (!@bulletin.email_sent.blank? ? true : false), :id=>'remind-check') %><%= t('announcement.activate_email_reminder')%>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div class="content-box">
|
<div class="content-box">
|
||||||
|
<p>
|
||||||
<% @email_group_data.collect do |k,v| %>
|
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'bulletin[email_user_ids][]', users: @email_users} %>
|
||||||
|
</p>
|
||||||
<label class="checkbox inline">
|
|
||||||
<%= check_box_tag 'bulletin[email_group][]', k, (@bulletin.email_group.nil? ? false : @bulletin.email_group.include?(k)), :id => "field-#{k}" %> <%= v["name"] %>
|
|
||||||
<%= hidden_field_tag 'bulletin[email_group][]', '' %>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<% end if !@email_group_data.blank? %>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -186,6 +172,15 @@
|
|||||||
<%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %>
|
<%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content-box">
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t("announcement.email_sentdate") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.datetime_picker :email_sentdate, :no_label => true %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -360,6 +355,7 @@
|
|||||||
$('#remind-check').on('change', function() {
|
$('#remind-check').on('change', function() {
|
||||||
$(this).prop('checked') ? $('.content-box').removeClass('hide'):$('.content-box').addClass('hide')
|
$(this).prop('checked') ? $('.content-box').removeClass('hide'):$('.content-box').addClass('hide')
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
<% set_default_index do
|
<%
|
||||||
|
|
||||||
|
@unit_field = User.get_member_list_attribute_field("staff","unit")
|
||||||
|
|
||||||
|
set_default_index do
|
||||||
objects @bulletins
|
objects @bulletins
|
||||||
quick_edit_link type: 'edit',
|
quick_edit_link type: 'edit',
|
||||||
link: 'edit_panel_announcement_back_end_bulletin_path'
|
link: 'edit_panel_announcement_back_end_bulletin_path'
|
||||||
@@ -6,9 +10,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',
|
||||||
@@ -37,6 +41,11 @@
|
|||||||
field type: 'tags',
|
field type: 'tags',
|
||||||
hide: 'all',
|
hide: 'all',
|
||||||
sort: 'tags'
|
sort: 'tags'
|
||||||
|
field db_field: 'email_user_ids',
|
||||||
|
hide: 'all',
|
||||||
|
translation: 'announcement.email_to',
|
||||||
|
display_option: '"<br />#{MailCron.get_send_group_mail(object.email_user_ids , object.other_mailaddress).join(", ").html_safe}"',
|
||||||
|
sort: 'email_user_ids'
|
||||||
field type: 'id',
|
field type: 'id',
|
||||||
db_field: 'update_user_id',
|
db_field: 'update_user_id',
|
||||||
model: User,
|
model: User,
|
||||||
@@ -44,6 +53,11 @@
|
|||||||
translation: 'last_modified',
|
translation: 'last_modified',
|
||||||
hide: 'phone',
|
hide: 'phone',
|
||||||
sort: 'last_modified'
|
sort: 'last_modified'
|
||||||
|
field db_field: 'update_user_id',
|
||||||
|
translation: 'announcement.default_widget.bulletin_create_dept',
|
||||||
|
display_option: 'User.get_member_list_attribute_value(object.create_user_id,@unit_field.id).get_value_by_locale(I18n.locale) rescue nil',
|
||||||
|
sort: 'last_modified'
|
||||||
|
|
||||||
filter_field type: 'array',
|
filter_field type: 'array',
|
||||||
values: @statuses,
|
values: @statuses,
|
||||||
translation: 'status'
|
translation: 'status'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<span class="pull-right"><%= dislpay_view_count(@bulletin) %></span>
|
<span class="pull-right"><%= dislpay_view_count(@bulletin) %></span>
|
||||||
<span class="date"><%= display_date_time(@bulletin.postdate) %></span>
|
<span class="date"><%= display_date_time(@bulletin.postdate) %></span>
|
||||||
<%
|
<%
|
||||||
unit_field = User.get_member_list_attribute_field("staff","Unit")
|
unit_field = User.get_member_list_attribute_field("staff","unit")
|
||||||
unit = User.get_member_list_attribute_value(@bulletin.create_user_id,unit_field.id).get_value_by_locale(I18n.locale) rescue nil
|
unit = User.get_member_list_attribute_value(@bulletin.create_user_id,unit_field.id).get_value_by_locale(I18n.locale) rescue nil
|
||||||
%>
|
%>
|
||||||
<span><%= t('announcement.default_widget.bulletin_create_dept') + ": " + unit unless unit.blank? %></span>
|
<span><%= t('announcement.default_widget.bulletin_create_dept') + ": " + unit unless unit.blank? %></span>
|
||||||
@@ -37,4 +37,4 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= share_links(@bulletin, 'announcement') %>
|
<%= share_links(@bulletin, 'announcement') %>
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
<% # encoding: utf-8 %>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
.h1{
|
||||||
|
font: 22px/1.5 'open sans','微軟正黑體',sans-serif;
|
||||||
|
margin: 0 0 10px;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.info {
|
||||||
|
background: none repeat scroll 0 0 #FFFFFF;
|
||||||
|
border: 1px solid #DDDDDD;
|
||||||
|
font: 13px/1 'arial',sans-serif;
|
||||||
|
margin: 0 0 20px;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.info span {
|
||||||
|
margin: 0 7px 0 0;
|
||||||
|
border-right: 1px solid #ddd;
|
||||||
|
padding: 0 10px 0 0;
|
||||||
|
}
|
||||||
|
.news_paragraph{
|
||||||
|
margin: 0 0 20px;
|
||||||
|
}
|
||||||
|
.linkAndFile{
|
||||||
|
border-top: 1px solid #CCCCCC;
|
||||||
|
border-left: 1px solid #CCCCCC;
|
||||||
|
border-right: 1px solid #CCCCCC;
|
||||||
|
border-radius: 5px 5px 0 0;
|
||||||
|
clear: both;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 10px 10px 0 10px;
|
||||||
|
}
|
||||||
|
.fb{
|
||||||
|
border-bottom : 1px solid #CCCCCC;
|
||||||
|
border-left: 1px solid #CCCCCC;
|
||||||
|
border-right: 1px solid #CCCCCC;
|
||||||
|
border-radius: 0 0 5px 5px;
|
||||||
|
clear: both;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 5px 10px 5px 10px;
|
||||||
|
}
|
||||||
|
.linkAndFile>div{
|
||||||
|
border-bottom: 1px solid #CCCCCC;
|
||||||
|
display: block;
|
||||||
|
margin: 0 0 5px;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 0 0 5px;
|
||||||
|
}
|
||||||
|
.icons-link, .icons-paperclip{
|
||||||
|
float: left;
|
||||||
|
margin: 0 10px 0 0;
|
||||||
|
}
|
||||||
|
.showLink, .showFile {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
.showLink a, .showFile a{
|
||||||
|
margin: 0 10px 0 0;
|
||||||
|
}
|
||||||
|
.fb a{
|
||||||
|
margin: 0 5px 0 0;
|
||||||
|
}
|
||||||
|
.showLink:before, .showFile:before {
|
||||||
|
content: "●";
|
||||||
|
margin: 0 10px 0 5px;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<h1 class="h1"><%= @bulletin.title %></h1>
|
||||||
|
<div class="info">
|
||||||
|
<div class="info1">
|
||||||
|
<span class="category"><%= t('announcement.categories') %> : <%= @bulletin.category.title rescue nil %></span>
|
||||||
|
<span class="date"><%= display_date_time(@bulletin.postdate) %></span>
|
||||||
|
<%
|
||||||
|
unit_field = User.get_member_list_attribute_field("staff","unit")
|
||||||
|
unit = User.get_member_list_attribute_value(@bulletin.create_user_id,unit_field.id).get_value_by_locale(I18n.locale) rescue nil
|
||||||
|
%>
|
||||||
|
<span><%= t('announcement.default_widget.bulletin_create_dept') + ": " + unit unless unit.blank? %></span>
|
||||||
|
<span class="pull-right"><%= dislpay_view_count(@bulletin) %></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="news_paragraph">
|
||||||
|
<%= @bulletin.text.html_safe rescue '' %>
|
||||||
|
</div>
|
||||||
|
<div class="linkAndFile">
|
||||||
|
<% if @bulletin.bulletin_links.size > 0 %>
|
||||||
|
<div>
|
||||||
|
<i class="icons-link"></i>
|
||||||
|
<div class="showLink">
|
||||||
|
<% @bulletin.bulletin_links.each do | blink | %>
|
||||||
|
<%= link_to blink.title, blink.url, :target => '_blank' %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% if @bulletin.bulletin_files.size > 0 %>
|
||||||
|
<div>
|
||||||
|
<i class="icons-paperclip"></i>
|
||||||
|
<div class="showFile">
|
||||||
|
<% @bulletin.bulletin_files.each do | bfile | %>
|
||||||
|
<%= link_to bfile.title, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= share_links(@bulletin, 'announcement') %>
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
<% # encoding: utf-8 %>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
th {
|
||||||
|
background: #fff;
|
||||||
|
border-bottom: 2px solid #333;
|
||||||
|
padding: 10px 5px;
|
||||||
|
font: 15px/1 '微軟正黑體',sans-serif;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
padding: 10px 5px;
|
||||||
|
font: 13px/1.5 'arial',sans-serif;
|
||||||
|
vertical-align: top;
|
||||||
|
text-align: left;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
tr{
|
||||||
|
background: #fafafa
|
||||||
|
}
|
||||||
|
.odd{
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
td a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
td a:hover {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
.pagination{
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
.pagination ul{
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.pagination li:first-child {
|
||||||
|
border-radius: 5px 0 0 5px;
|
||||||
|
}
|
||||||
|
.pagination li {
|
||||||
|
background: none repeat scroll 0 0 #FFFFFF !important;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-right: 0px solid #ccc;
|
||||||
|
display: block;
|
||||||
|
float: left;
|
||||||
|
font: 13px/30px 'open sans',sans-serif !important;
|
||||||
|
padding: 0 10px !important;
|
||||||
|
}
|
||||||
|
.pagination li:last-child {
|
||||||
|
border-radius: 0 5px 5px 0;
|
||||||
|
border-right: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
.pagination li a {
|
||||||
|
color: #333;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.pagination li a:hover {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
// Popup window code
|
||||||
|
function newPopup(url) {
|
||||||
|
popupWindow = window.open(
|
||||||
|
url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<table class="table table-bordered">
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><%= t('announcement.categories') %></th>
|
||||||
|
<th><%= t('announcement.default_widget.title') %></th>
|
||||||
|
<th><%= t('announcement.default_widget.postdate') %></th>
|
||||||
|
<th><%= t('announcement.default_widget.bulletin_create_dept') %></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% @bulletins.each_with_index do |post, i| %>
|
||||||
|
<tr <%= (i % 2 == 0) ? 'class=odd' : '' %>>
|
||||||
|
<td><%= post.category.title rescue nil %></td>
|
||||||
|
<td><a href="JavaScript:newPopup('<%= panel_announcement_widget_show_sync_data_path(post) %>');"><%= post.title %></a></td>
|
||||||
|
<td><%= display_date(post.postdate) %></td>
|
||||||
|
<%
|
||||||
|
unit_field = User.get_member_list_attribute_field("staff","unit")
|
||||||
|
unit = User.get_member_list_attribute_value(post.create_user_id,unit_field.id).get_value_by_locale(I18n.locale) rescue nil
|
||||||
|
%>
|
||||||
|
<td><%= unit %></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= paginate( @bulletins, :param_name => :page_main, :params => {:inner => 'false'} ) rescue nil if params[:show_page] == 'true' %>
|
||||||
|
|
||||||
|
|
||||||
@@ -41,16 +41,10 @@ en:
|
|||||||
index: Index
|
index: Index
|
||||||
search: Search
|
search: Search
|
||||||
email_reminder: Email Reminder
|
email_reminder: Email Reminder
|
||||||
activate_email_eminder: Activate Email Reminder
|
activate_email_reminder: Activate Email Reminder
|
||||||
email_sentdate: Email Time
|
email_sentdate: Email Time
|
||||||
email_group: Email Group
|
email_to: Email To
|
||||||
email_group_data_0: All Faculty
|
mail_subject: this is an announcement reminder from【%{site_title}】
|
||||||
email_group_data_1: Undergraduates
|
|
||||||
email_group_data_2: Postgraduates
|
|
||||||
email_group_data_3: Continuing Ed. Postgraduates
|
|
||||||
email_group_data_4: Other
|
|
||||||
# mail_subject: this is an announcement reminder from【%{site_title}】
|
|
||||||
mail_subject: 【北教大公告提醒】
|
|
||||||
other_mailaddress: Other Email
|
other_mailaddress: Other Email
|
||||||
other_mailaddress_note: Divide different email accounts with ","
|
other_mailaddress_note: Divide different email accounts with ","
|
||||||
mail_hi: Hi
|
mail_hi: Hi
|
||||||
|
|||||||
@@ -44,18 +44,12 @@ zh_tw:
|
|||||||
search: 搜尋
|
search: 搜尋
|
||||||
more: 更多+
|
more: 更多+
|
||||||
email_reminder: 寄送提醒
|
email_reminder: 寄送提醒
|
||||||
activate_email_eminder: 開啟寄送提醒
|
activate_email_reminder: 開啟寄送提醒
|
||||||
email_sentdate: 寄送時間
|
email_sentdate: 寄送時間
|
||||||
email_group: 寄送群組
|
email_to: 寄送對象
|
||||||
other_mailaddress: 其他Mail
|
other_mailaddress: 其他Mail
|
||||||
other_mailaddress_note: 輸入多組mail時,請用","逗號隔開
|
other_mailaddress_note: 輸入多組mail時,請用","逗號隔開
|
||||||
email_group_data_0: 全校教職員
|
mail_subject: 來自【%{site_title}】的公告事件提醒
|
||||||
email_group_data_1: 大學部學生
|
|
||||||
email_group_data_2: 日間部研究生
|
|
||||||
email_group_data_3: 進修部研究生
|
|
||||||
email_group_data_4: 其他
|
|
||||||
# mail_subject: 來自【%{site_title}】的公告事件提醒
|
|
||||||
mail_subject: 【北教大公告提醒】
|
|
||||||
mail_hi: 您好
|
mail_hi: 您好
|
||||||
mail_url_view: 此封信件為公告事件提醒,請點選以下連結詳細觀看
|
mail_url_view: 此封信件為公告事件提醒,請點選以下連結詳細觀看
|
||||||
mail_source: 來源
|
mail_source: 來源
|
||||||
|
|||||||
@@ -40,6 +40,12 @@ Rails.application.routes.draw do
|
|||||||
match "reload_web_links" => "bulletins#reload_web_links"
|
match "reload_web_links" => "bulletins#reload_web_links"
|
||||||
match "bulletins_side_bar" => "bulletins#bulletins_side_bar"
|
match "bulletins_side_bar" => "bulletins#bulletins_side_bar"
|
||||||
match "bulletins_search_block" => "bulletins#bulletins_search_block"
|
match "bulletins_search_block" => "bulletins#bulletins_search_block"
|
||||||
|
match "sync_data" => "bulletins#sync_data",:as => :sync_data,:via => :get
|
||||||
|
match "show_sync_data/:id" => "bulletins#show_sync_data",:as => :show_sync_data,:via => :get
|
||||||
|
end
|
||||||
|
namespace :api do
|
||||||
|
get "categories_tags.json" => "bulletins#get_categories_tags"
|
||||||
|
get "bulletins.json" => "bulletins#get_bulletins"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+4
-4
@@ -28,20 +28,20 @@ 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.can_display.available_for_lang(I18n.locale).any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )'
|
query 'Bulletin'
|
||||||
enable ["typeA", "typeB_style3", "typeC"]
|
enable ["typeA", "typeB_style3", "typeC"]
|
||||||
image :image
|
image :image
|
||||||
field :postdate
|
field :postdate
|
||||||
link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self}
|
link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self}
|
||||||
link_field :bulletin_category_with_title,{:method => 'panel_announcement_front_end_bulletins_path',:args=>{:category_id => [:category,:id]}}
|
link_field :bulletin_category_with_title,{:method => 'panel_announcement_front_end_bulletins_path',:args=>{:category_id => [:category,:id]}}
|
||||||
link_field :subtitle,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self,:preview=>true}
|
field :subtitle
|
||||||
field :bulletin_create_dept
|
field :bulletin_create_dept
|
||||||
link_to_more 'panel_announcement_front_end_bulletins_path',:title_i18n=> 'more_plus'
|
link_to_more 'panel_announcement_front_end_bulletins_path',:title_i18n=> 'more_plus'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user