1.Remove category column when category is specified
2.Showing category if not in category browsing 3.Redirect to home and show error if app page is not available for user language 4.Showing no context to display if object has no language for it. 5.Browse new and announcement by unit is now applicable.
This commit is contained in:
parent
b4c2dfe0ef
commit
e8317e0a4b
|
@ -186,6 +186,7 @@ GEM
|
||||||
chinese_pinyin (>= 0.3.0)
|
chinese_pinyin (>= 0.3.0)
|
||||||
redis (>= 2.1.1)
|
redis (>= 2.1.1)
|
||||||
redis-namespace (~> 1.0.2)
|
redis-namespace (~> 1.0.2)
|
||||||
|
remotipart (1.0.2)
|
||||||
resque (1.20.0)
|
resque (1.20.0)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
redis-namespace (~> 1.0.2)
|
redis-namespace (~> 1.0.2)
|
||||||
|
@ -332,6 +333,7 @@ DEPENDENCIES
|
||||||
redis (>= 2.1.1)
|
redis (>= 2.1.1)
|
||||||
redis-namespace (~> 1.0.2)
|
redis-namespace (~> 1.0.2)
|
||||||
redis-search (= 0.7.1)
|
redis-search (= 0.7.1)
|
||||||
|
remotipart
|
||||||
resque
|
resque
|
||||||
resque-restriction
|
resque-restriction
|
||||||
resque-scheduler
|
resque-scheduler
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
class PagesController < ApplicationController
|
class PagesController < ApplicationController
|
||||||
|
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
before_filter :get_item, :only => [:index_from_link, :show_from_link]
|
before_filter :get_item, :only => [:index_from_link, :show_from_link]
|
||||||
|
|
||||||
# caches_page :index
|
# caches_page :index
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -11,7 +8,7 @@ class PagesController < ApplicationController
|
||||||
|
|
||||||
if @item
|
if @item
|
||||||
impressionist(@item)
|
impressionist(@item)
|
||||||
render_page
|
render_page
|
||||||
else
|
else
|
||||||
render :text => 'You need a home page'
|
render :text => 'You need a home page'
|
||||||
end
|
end
|
||||||
|
@ -19,14 +16,15 @@ class PagesController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
#begin
|
#begin
|
||||||
|
|
||||||
@item = Item.first(:conditions => {:path => params[:page_name]})
|
@item = Item.first(:conditions => {:path => params[:page_name]})
|
||||||
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
|
if @item && @item.is_published #&& (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
|
||||||
impressionist(@item)
|
impressionist(@item)
|
||||||
case @item.class.to_s
|
case @item.class.to_s
|
||||||
when 'Page'
|
when 'Page'
|
||||||
render_page
|
render_page unless save_from_no_lang_for_page
|
||||||
when 'Link'
|
when 'Link'
|
||||||
redirect_to @item[:url]
|
redirect_to(@item[:url]) unless save_from_no_lang_for_page
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
||||||
|
@ -43,15 +41,17 @@ class PagesController < ApplicationController
|
||||||
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
||||||
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
||||||
options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank?
|
options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank?
|
||||||
|
options << "#{options.blank? ? '?' : '&'}name=#{params[:name]}" unless params[:name].blank?
|
||||||
uri = URI::escape(url + options)
|
uri = URI::escape(url + options)
|
||||||
redirect_to uri
|
#uri = URI::escape("#{url}?" + params.collect{|k,v| "#{k}=#{v}"}.join('&'))
|
||||||
|
redirect_to(uri)unless save_from_no_lang_for_page
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_from_link
|
def show_from_link
|
||||||
url = "/#{@item.path}?id=#{params[:id]}"
|
url = "/#{@item.path}?id=#{params[:id]}"
|
||||||
options = ''
|
options = ''
|
||||||
options << "&preview=#{params[:preview]}" unless params[:preview].blank?
|
options << "&preview=#{params[:preview]}" unless params[:preview].blank?
|
||||||
redirect_to url + options
|
redirect_to(url + options) unless save_from_no_lang_for_page
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_orbit_bar
|
def load_orbit_bar
|
||||||
|
@ -66,12 +66,22 @@ class PagesController < ApplicationController
|
||||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]})
|
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]})
|
||||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item
|
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item
|
||||||
elsif !params[:category_id].blank?
|
elsif !params[:category_id].blank?
|
||||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''})
|
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],category: params[:category_id]).any_in(tag: [nil,'']).first
|
||||||
elsif !params[:tag_id].blank?
|
elsif !params[:tag_id].blank?
|
||||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => '', :tag => params[:tag_id]})
|
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],tag: params[:tag_id]).any_in(category: [nil,'']).first
|
||||||
end
|
end
|
||||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => '', :tag => ''}) unless @item
|
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item
|
||||||
#TODO 需要做 error handler 處理沒有新增該模組頁面導致錯誤的可能性
|
#TODO 需要做 error handler 處理沒有新增該模組頁面導致錯誤的可能性
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
def save_from_no_lang_for_page
|
||||||
|
if @item.nil? or !@item.enabled_for_lang(I18n.locale.to_s)
|
||||||
|
flash[:notice] = t('sys.module_page_lang_not_support')
|
||||||
|
redirect_to '/'
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,10 @@ class Item
|
||||||
before_destroy :destroy_children
|
before_destroy :destroy_children
|
||||||
after_rearrange :rebuild_path, :if => "parent_id_changed? || name_changed?"
|
after_rearrange :rebuild_path, :if => "parent_id_changed? || name_changed?"
|
||||||
|
|
||||||
|
def enabled_for_lang(lang)
|
||||||
|
enabled_for.include?(lang)
|
||||||
|
end
|
||||||
|
|
||||||
def self.find_by_name(item_name)
|
def self.find_by_name(item_name)
|
||||||
Item.first(:conditions => { :name => item_name, :is_published => true })
|
Item.first(:conditions => { :name => item_name, :is_published => true })
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,8 @@ class Page < Item
|
||||||
field :content
|
field :content
|
||||||
field :app_frontend_url
|
field :app_frontend_url
|
||||||
field :theme_id, :type => BSON::ObjectId, :default => nil
|
field :theme_id, :type => BSON::ObjectId, :default => nil
|
||||||
field :category
|
field :category, :default => ''
|
||||||
field :tag
|
field :tag, :default => ''
|
||||||
field :view_count, :type => Integer, :default => 0
|
field :view_count, :type => Integer, :default => 0
|
||||||
field :page_title, localize: true
|
field :page_title, localize: true
|
||||||
|
|
||||||
|
|
|
@ -31,12 +31,7 @@ class User
|
||||||
|
|
||||||
VALID_LOCALES.each do |loc|
|
VALID_LOCALES.each do |loc|
|
||||||
locale = loc.to_sym
|
locale = loc.to_sym
|
||||||
# debugger
|
|
||||||
# if(self.cache_dept.nil?)
|
|
||||||
# self.build_cache_dept key: "dept_cache_user_#{self.id}"
|
|
||||||
# end
|
|
||||||
dept_hash[locale] = sub_roles.collect{|sr| sr.title}.join(',')
|
dept_hash[locale] = sub_roles.collect{|sr| sr.title}.join(',')
|
||||||
# self.cache_dept[locale] = sub_roles.collect{|sr| sr.title}.join(',')
|
|
||||||
end
|
end
|
||||||
self.cache_dept = dept_hash
|
self.cache_dept = dept_hash
|
||||||
self.save!
|
self.save!
|
||||||
|
|
|
@ -12,6 +12,17 @@
|
||||||
<%= page_javascripts(@item).html_safe %>
|
<%= page_javascripts(@item).html_safe %>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
|
<% if !flash.empty? %>
|
||||||
|
<div class="modal alert alert-error hide" id="myModal">
|
||||||
|
<p type="button" class="close" data-dismiss="modal">×</p>
|
||||||
|
<% flash.each do |key, msg| %>
|
||||||
|
<%= "<strong>#{msg}</strong><br/>".html_safe%>
|
||||||
|
<% end%>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$('#myModal').modal('show')
|
||||||
|
</script>
|
||||||
|
<% end -%>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -298,7 +298,8 @@ en:
|
||||||
sys:
|
sys:
|
||||||
not_previewable: "Preview not support"
|
not_previewable: "Preview not support"
|
||||||
limit_of_upload_file_size: "Upload file must be less than: %{best_size}"
|
limit_of_upload_file_size: "Upload file must be less than: %{best_size}"
|
||||||
|
can_not_display_due_to_no_context: "Can not display due to no context for English"
|
||||||
|
module_page_lang_not_support: "We are sorry, this page is not available for English"
|
||||||
search:
|
search:
|
||||||
not_found: "NOT FOUND"
|
not_found: "NOT FOUND"
|
||||||
domains: Google Search Domains
|
domains: Google Search Domains
|
||||||
|
@ -307,3 +308,4 @@ en:
|
||||||
site_setting_help: Please Enter the search argument for Google search.
|
site_setting_help: Please Enter the search argument for Google search.
|
||||||
result_get: "Searched about ' %{search_word} ' Found %{item_num} items"
|
result_get: "Searched about ' %{search_word} ' Found %{item_num} items"
|
||||||
too_many: "Search about ' %{search_word} 'resulted more than %{exceed_num} items maybe try to search with more specific terms?"
|
too_many: "Search about ' %{search_word} 'resulted more than %{exceed_num} items maybe try to search with more specific terms?"
|
||||||
|
unit_get: "Listed items created by :%{unit_name} Found %{item_num} items"
|
||||||
|
|
|
@ -445,6 +445,8 @@ zh_tw:
|
||||||
result_get: "搜尋有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料"
|
result_get: "搜尋有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料"
|
||||||
too_many: "搜尋有關 ' %{search_word} ' 尋找到超過 %{exceed_num} 筆資料,請嘗試加入更多關鍵字縮小搜尋範圍,以作更精確的搜尋"
|
too_many: "搜尋有關 ' %{search_word} ' 尋找到超過 %{exceed_num} 筆資料,請嘗試加入更多關鍵字縮小搜尋範圍,以作更精確的搜尋"
|
||||||
|
|
||||||
|
result_get: "搜尋標題有關 ' %{search_word} ' 共搜尋到%{item_num}筆資料"
|
||||||
|
unit_get: "列出由:%{unit_name}發佈的資料,共有%{item_num}筆"
|
||||||
activerecord:
|
activerecord:
|
||||||
errors:
|
errors:
|
||||||
template: # ~ 2.3.5 backward compatible
|
template: # ~ 2.3.5 backward compatible
|
||||||
|
@ -526,7 +528,8 @@ zh_tw:
|
||||||
sys:
|
sys:
|
||||||
not_previewable: "不支援預覽"
|
not_previewable: "不支援預覽"
|
||||||
limit_of_upload_file_size: "上傳檔案大小限制: %{best_size}"
|
limit_of_upload_file_size: "上傳檔案大小限制: %{best_size}"
|
||||||
|
can_not_display_due_to_no_context: "因為沒有中文版本,所以無法顯示"
|
||||||
|
module_page_lang_not_support: "很抱歉,本頁沒有開放中文版本"
|
||||||
object_disable:
|
object_disable:
|
||||||
change_to_true: "設為停用"
|
change_to_true: "設為停用"
|
||||||
change_to_false: "重新啓用"
|
change_to_false: "重新啓用"
|
|
@ -8,7 +8,7 @@ defaults: &defaults
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
database: prototype_r4_ldap0229
|
database: i18n_var
|
||||||
|
|
||||||
test:
|
test:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
|
@ -180,7 +180,7 @@ module ParserCommon
|
||||||
if (content["main"] == "true" && !page.module_app.nil?)
|
if (content["main"] == "true" && !page.module_app.nil?)
|
||||||
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
|
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
|
||||||
ret << "/#{params[:id]}" if params[:id] && !params[:id].eql?(page.id.to_s)
|
ret << "/#{params[:id]}" if params[:id] && !params[:id].eql?(page.id.to_s)
|
||||||
ret << "?inner=true&page_id=#{page.id}&category_id=#{category}&tag_id=#{tag}&preview=#{params[:preview]}&page_main=#{params[:page_main]}&search_query=#{params[:search_query]}"
|
ret << "?inner=true&page_id=#{page.id}&category_id=#{category}&tag_id=#{tag}&preview=#{params[:preview]}&page_main=#{params[:page_main]}&search_query=#{params[:search_query]}&name=#{params[:name]}"
|
||||||
ret << "'></div>"
|
ret << "'></div>"
|
||||||
else
|
else
|
||||||
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
||||||
|
|
|
@ -83,4 +83,17 @@ namespace :data_migration do
|
||||||
puts("#{'='*10}Finished#{'='*10}")
|
puts("#{'='*10}Finished#{'='*10}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
task :make_bulletin_save_dept_data => :environment do
|
||||||
|
Bulletin.all.each{|bt| bt.save!}
|
||||||
|
end
|
||||||
|
|
||||||
|
task :extend_exsisted_app_module_for_dept_search => :environment do
|
||||||
|
app = ModuleApp.first({:conditions=>{:title => 'news'}})
|
||||||
|
app.app_pages << "index_by_unit" if !app.widgets.include?("index_by_unit")
|
||||||
|
app.save!
|
||||||
|
app = ModuleApp.first({:conditions=>{:title => 'Announcement'}})
|
||||||
|
app.app_pages << "index_by_unit" if !app.widgets.include?("index_by_unit")
|
||||||
|
app.save!
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -7,7 +7,12 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
|
|
||||||
# GET /bulletins
|
# GET /bulletins
|
||||||
# GET /bulletins.xml
|
# GET /bulletins.xml
|
||||||
|
def index_bulletins_by_unit
|
||||||
|
@page = Page.find(params[:page_id])
|
||||||
|
@bulletins=Bulletin.all.available_for_lang(I18n.locale).can_display.where("cache_dept.#{I18n.locale.to_s.downcase}"=>params[:name]).page( params[:page_main]).per(15)
|
||||||
|
render :index
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@page = Page.find(params[:page_id])
|
@page = Page.find(params[:page_id])
|
||||||
if !params[:search_query].blank?
|
if !params[:search_query].blank?
|
||||||
|
@ -48,10 +53,14 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
if params[:preview] == "true"
|
if params[:preview] == "true"
|
||||||
preview_content
|
preview_content
|
||||||
else
|
else
|
||||||
@bulletin = Bulletin.all.available_for_lang(I18n.locale).can_display.where(_id: params[:id]).first
|
@bulletin = Bulletin.all.can_display.where(_id: params[:id]).first
|
||||||
unless @bulletin.disable?
|
if !@bulletin.disable?
|
||||||
impressionist(@bulletin)
|
if @bulletin.enabled_for_lang(I18n.locale.to_s)
|
||||||
get_categorys
|
impressionist(@bulletin)
|
||||||
|
get_categorys
|
||||||
|
else
|
||||||
|
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
|
||||||
|
end
|
||||||
else
|
else
|
||||||
render :nothing => true, :status => 403
|
render :nothing => true, :status => 403
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,6 +25,8 @@ class Bulletin
|
||||||
field :postdate , :type => DateTime
|
field :postdate , :type => DateTime
|
||||||
field :deadline , :type => DateTime
|
field :deadline , :type => DateTime
|
||||||
# field :url
|
# field :url
|
||||||
|
field :cache_dept,type: Hash
|
||||||
|
|
||||||
field :create_user_id
|
field :create_user_id
|
||||||
field :update_user_id, :class_name => "User"
|
field :update_user_id, :class_name => "User"
|
||||||
|
|
||||||
|
@ -59,9 +61,10 @@ class Bulletin
|
||||||
accepts_nested_attributes_for :bulletin_links, :allow_destroy => true
|
accepts_nested_attributes_for :bulletin_links, :allow_destroy => true
|
||||||
|
|
||||||
validates :title, :at_least_one => true
|
validates :title, :at_least_one => true
|
||||||
|
|
||||||
before_save :check_deadline,:update_avliable_language
|
before_save :check_deadline,:update_status,:update_avliable_language
|
||||||
|
|
||||||
|
before_save :fetch_dept
|
||||||
after_save :save_bulletin_links
|
after_save :save_bulletin_links
|
||||||
after_save :save_bulletin_files
|
after_save :save_bulletin_files
|
||||||
|
|
||||||
|
@ -103,6 +106,11 @@ class Bulletin
|
||||||
self.save!
|
self.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def enabled_for_lang(lang)
|
||||||
|
eval("self.available_for_#{lang}")
|
||||||
|
end
|
||||||
|
|
||||||
def publish_month
|
def publish_month
|
||||||
published_at.strftime("%B %Y")
|
published_at.strftime("%B %Y")
|
||||||
end
|
end
|
||||||
|
@ -214,4 +222,8 @@ class Bulletin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fetch_dept
|
||||||
|
self.cache_dept = (User.current.cache_dept rescue nil) || (User.find(self.create_user_id).cache_dept rescue nil)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -7,10 +7,16 @@
|
||||||
|
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= t('announcement.bulletin.category') %></th>
|
<%= content_tag (:th) do %>
|
||||||
|
<%= t('announcement.bulletin.category') %>
|
||||||
|
<% end if (!params[:search_query].blank? or params[:category_id].blank?)-%>
|
||||||
<th><%= t('announcement.bulletin.title') %></th>
|
<th><%= t('announcement.bulletin.title') %></th>
|
||||||
<th><%= t('announcement.bulletin.postdate') %></th>
|
<th><%= t('announcement.bulletin.postdate') %></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% if !params[:name].blank?%>
|
||||||
|
<%= t("search.unit_get",:unit_name => params[:name],:item_num=>@bulletins.count) %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% if @bulletins.blank? and !params[:search_query].blank? %>
|
<% if @bulletins.blank? and !params[:search_query].blank? %>
|
||||||
<%=render :partial => 'shared/search_not_found' %>
|
<%=render :partial => 'shared/search_not_found' %>
|
||||||
<% elsif !params[:search_query].blank? %>
|
<% elsif !params[:search_query].blank? %>
|
||||||
|
@ -20,7 +26,9 @@
|
||||||
|
|
||||||
<% @bulletins.each do |post| %>
|
<% @bulletins.each do |post| %>
|
||||||
<tr class=<%= cycle('odd', '') %>>
|
<tr class=<%= cycle('odd', '') %>>
|
||||||
<td><%= (post.bulletin_category.title rescue nil ) if !params[:search_query].blank? %></td>
|
<%= content_tag(:th) do%>
|
||||||
|
<td><%= (post.bulletin_category.title rescue nil ) %></td>
|
||||||
|
<% end if(!params[:search_query].blank? or params[:category_id].blank?) %>
|
||||||
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
|
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
|
||||||
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
|
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="info1">
|
<div class="info1">
|
||||||
<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>
|
||||||
<span><%= User.find(@bulletin.create_user_id).cache_dept[I18n.locale.to_s] rescue nil %></span>
|
<span><%= link_to @bulletin.cache_dept[I18n.locale.to_s],panel_announcement_front_end_index_bulletins_by_unit_path(:name=>@bulletin.cache_dept[I18n.locale.to_s]) rescue nil %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="news_image">
|
<div class="news_image">
|
||||||
|
|
|
@ -34,6 +34,7 @@ Rails.application.routes.draw do
|
||||||
resources :tags
|
resources :tags
|
||||||
end
|
end
|
||||||
namespace :front_end do
|
namespace :front_end do
|
||||||
|
match "index_by_unit" => "bulletins#index_bulletins_by_unit",:as => :index_bulletins_by_unit
|
||||||
resources :bulletins # do
|
resources :bulletins # do
|
||||||
# match "preview" => "bulletins#preview_content",:as => :get_preview_content
|
# match "preview" => "bulletins#preview_content",:as => :get_preview_content
|
||||||
# end
|
# end
|
||||||
|
|
|
@ -8,6 +8,12 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
|
||||||
# GET /news_bulletins
|
# GET /news_bulletins
|
||||||
# GET /news_bulletins.xml
|
# GET /news_bulletins.xml
|
||||||
|
|
||||||
|
def index_news_bulletins_by_unit
|
||||||
|
@page = Page.find(params[:page_id])
|
||||||
|
@news_bulletins=NewsBulletin.all.available_for_lang(I18n.locale).can_display.where("unit_list_for_anc_id"=>params[:name]).page( params[:page_main]).per(15).page( params[:page_main]).per(10)
|
||||||
|
render :index
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@page = Page.find(params[:page_id])
|
@page = Page.find(params[:page_id])
|
||||||
if !params[:search_query].blank?
|
if !params[:search_query].blank?
|
||||||
|
@ -47,10 +53,14 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
|
||||||
preview_content
|
preview_content
|
||||||
else
|
else
|
||||||
''
|
''
|
||||||
@news_bulletin = NewsBulletin.all.available_for_lang(I18n.locale).can_display.where(_id: params[:id]).first
|
@news_bulletin = NewsBulletin.all.can_display.where(_id: params[:id]).first
|
||||||
unless @news_bulletin.disable?
|
if !@news_bulletin.disable?
|
||||||
impressionist(@news_bulletin)
|
if @news_bulletin.enabled_for_lang(I18n.locale.to_s)
|
||||||
get_categorys
|
impressionist(@news_bulletin)
|
||||||
|
get_categorys
|
||||||
|
else
|
||||||
|
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
|
||||||
|
end
|
||||||
else
|
else
|
||||||
render :nothing => true, :status => 403
|
render :nothing => true, :status => 403
|
||||||
end
|
end
|
||||||
|
|
|
@ -166,6 +166,10 @@ class NewsBulletin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def enabled_for_lang(lang)
|
||||||
|
eval("self.available_for_#{lang}")
|
||||||
|
end
|
||||||
|
|
||||||
def de_pending
|
def de_pending
|
||||||
self.is_pending = false
|
self.is_pending = false
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
<h1 class="h1"><%= @page.title %></h1>
|
<h1 class="h1"><%= @page.title %></h1>
|
||||||
|
|
||||||
|
<% if !params[:name].blank?%>
|
||||||
|
<%= t("search.unit_get",:unit_name => UnitListForAnc.find(params[:name]).title,:item_num=>@news_bulletins.count) %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% if @news_bulletins.blank? and !params[:search_query].blank? %>
|
<% if @news_bulletins.blank? and !params[:search_query].blank? %>
|
||||||
<%=render :partial => 'shared/search_not_found' %>
|
<%=render :partial => 'shared/search_not_found' %>
|
||||||
<% elsif !params[:search_query].blank? %>
|
<% elsif !params[:search_query].blank? %>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<span class="date"><%= display_date(@news_bulletin.postdate) %></span>
|
<span class="date"><%= display_date(@news_bulletin.postdate) %></span>
|
||||||
<% unit = @news_bulletin.unit_list_for_anc.title rescue nil %>
|
<% unit = @news_bulletin.unit_list_for_anc.title rescue nil %>
|
||||||
<%= " | " if unit %>
|
<%= " | " if unit %>
|
||||||
<a href="" class="unit"><%= unit %></a>
|
<%= link_to unit, panel_news_front_end_index_news_bulletins_by_unit_path(:name=>@news_bulletin.unit_list_for_anc_id)%>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="news_image">
|
<div class="news_image">
|
||||||
|
|
|
@ -34,6 +34,7 @@ Rails.application.routes.draw do
|
||||||
resources :tags
|
resources :tags
|
||||||
end
|
end
|
||||||
namespace :front_end do
|
namespace :front_end do
|
||||||
|
match "index_by_unit" => "news_bulletins#index_news_bulletins_by_unit",:as => :index_news_bulletins_by_unit
|
||||||
resources :news_bulletins # do
|
resources :news_bulletins # do
|
||||||
# match "preview" => "news_bulletins#preview_content",:as => :get_preview_content
|
# match "preview" => "news_bulletins#preview_content",:as => :get_preview_content
|
||||||
# end
|
# end
|
||||||
|
|
Reference in New Issue