1 Commits
Author SHA1 Message Date
spen 88e7bdea61 ntu_cph 2014-08-22 15:33:28 +08:00
12 changed files with 41 additions and 270 deletions

No files matched your search

@@ -25,12 +25,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@statuses = get_statuses
category_ids = @categories.collect{|t| t.id}
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
@bulletins = get_sorted_and_filtered("bulletin", :category_id.in => category_ids)
respond_to do |format|
format.html # index.html.erb
format.js { }
@@ -75,8 +70,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@tags = get_tags
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))
redirect_to :action => :index
else
# @summary_variable = @bulletin.summary_variable
@@ -166,25 +166,5 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
def bulletins_search_block
@part = PagePart.find params[:part_id]
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
+2 -5
View File
@@ -21,6 +21,8 @@ class Bulletin
field :title, localize: true
field :subtitle, localize: true
field :text, localize: true
field :image_description, localize: true
field :create_user_id
field :update_user_id, :class_name => "User"
@@ -66,11 +68,6 @@ class Bulletin
def bulletin_category_with_title
self.category.title
end
def bulletin_create_dept
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
end
def get_bulletin_category
self.category
@@ -139,7 +139,32 @@
</label>
</div>
</div>
<div class="image_note"><%= t("announcement.image_note")%></div>
</div>
</div>
<!-- Image Description -->
<div class="control-group">
<%= f.label t("announcement.image_description"),{:class=>"control-label muted", :func=>"field_label"} %>
<div class="controls add-input">
<div class="add-target">
<div class="input-append">
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="image_description_<%= locale %>">
<%= f.fields_for :image_description_translations do |f| %>
<%= f.text_field locale, :value => (@bulletin.image_description_translations[locale] rescue nil), :placeholder=>"#{t("announcement.image_description")}" %>
<% end %>
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#image_description_<%= locale %>" data-toggle="tab"><%= I18nVariable.from_locale(locale) %></a>
<% end %>
</div>
</div>
</div>
</div>
</div>
@@ -1,8 +1,4 @@
<%
@unit_field = User.get_member_list_attribute_field("staff","unit")
set_default_index do
<% set_default_index do
objects @bulletins
quick_edit_link type: 'edit',
link: 'edit_panel_announcement_back_end_bulletin_path'
@@ -53,11 +49,6 @@
translation: 'last_modified',
hide: 'phone',
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',
values: @statuses,
translation: 'status'
@@ -4,13 +4,15 @@
<div class="info1">
<span class="pull-right"><%= dislpay_view_count(@bulletin) %></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>
<% unit = @bulletin.cache_dept[I18n.locale.to_s] rescue nil %>
<span><%= link_to unit,panel_announcement_front_end_index_bulletins_by_unit_path(:name=>unit) unless unit.blank? %></span>
</div>
</div>
<div class="news_image">
<%#= image_tag(@bulletin.image.url, :size => "320x240") if @bulletin.image.file %>
<%= link_to image_tag(@bulletin.image.url), @bulletin.image.url, {:target => '_blank', :title => @bulletin.image_identifier} if @bulletin.image.file %>
<span class="image_description"><%= @bulletin.image_description unless @bulletin.image_description.blank? %></span>
</div>
<div class="news_paragraph">
<%= @bulletin.text.html_safe rescue '' %>
</div>
@@ -1,110 +0,0 @@
<% # 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') %>
@@ -1,103 +0,0 @@
<% # 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' %>
+1 -2
View File
@@ -18,7 +18,6 @@ en:
postdate: Post Date
subtitle: Subtitle
title: Title
bulletin_create_dept: Unit
editing_announcement: Edit Announcement
editing_announcement_category: Edit Category
file: Attachment
@@ -28,7 +27,7 @@ en:
bulletins: Announcement front-end
search_result: Search result
image: Cover image
image_note: The image will not show in content
image_description: Cover Image Description
link_name: Link Name
new_bulletin_category: New Bulletin Category
picture: Cover Picture
+1 -2
View File
@@ -18,7 +18,6 @@ zh_tw:
postdate: 張貼日期
subtitle: 副標題
title: 標題
bulletin_create_dept: 單位
editing_announcement: 編輯類別
editing_announcement_category: 編輯類別
error:
@@ -30,7 +29,7 @@ zh_tw:
bulletins: 公告前台
search_result: 搜尋結果頁
image: 封面圖片
image_note: 此處上傳的圖片不會在公告內文出現
image_description: 封面圖片說明
link_name: 連結名稱
new_bulletin_category: 新增公告類別
picture: 刊頭圖片
-2
View File
@@ -40,8 +40,6 @@ Rails.application.routes.draw do
match "reload_web_links" => "bulletins#reload_web_links"
match "bulletins_side_bar" => "bulletins#bulletins_side_bar"
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"
-1
View File
@@ -41,7 +41,6 @@ module Announcement
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]}}
field :subtitle
field :bulletin_create_dept
link_to_more 'panel_announcement_front_end_bulletins_path',:title_i18n=> 'more_plus'
end