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:
1 parent
80887ace3c
commit
cbf7ccc13b
21 files changed
+126
-56
No files matched your search
+14
-5
@@ -7,7 +7,12 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||
|
||||
# GET /bulletins
|
||||
# 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
|
||||
@page = Page.find(params[:page_id])
|
||||
if !params[:search_query].blank?
|
||||
@@ -44,10 +49,14 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||
if params[:preview] == "true"
|
||||
preview_content
|
||||
else
|
||||
@bulletin = Bulletin.all.available_for_lang(I18n.locale).can_display.where(_id: params[:id]).first
|
||||
unless @bulletin.disable?
|
||||
impressionist(@bulletin)
|
||||
get_categorys
|
||||
@bulletin = Bulletin.all.can_display.where(_id: params[:id]).first
|
||||
if !@bulletin.disable?
|
||||
if @bulletin.enabled_for_lang(I18n.locale.to_s)
|
||||
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
|
||||
render :nothing => true, :status => 403
|
||||
end
|
||||
|
||||
+12
-17
@@ -25,6 +25,8 @@ class Bulletin
|
||||
field :postdate , :type => DateTime
|
||||
field :deadline , :type => DateTime
|
||||
# field :url
|
||||
field :cache_dept,type: Hash
|
||||
|
||||
field :create_user_id
|
||||
field :update_user_id, :class_name => "User"
|
||||
|
||||
@@ -61,7 +63,8 @@ class Bulletin
|
||||
validates :title, :at_least_one => true
|
||||
|
||||
before_save :check_deadline,:update_status,:update_avliable_language
|
||||
|
||||
|
||||
before_save :fetch_dept
|
||||
after_save :save_bulletin_links
|
||||
after_save :save_bulletin_files
|
||||
|
||||
@@ -94,26 +97,14 @@ class Bulletin
|
||||
self.title_was["en"]
|
||||
end
|
||||
|
||||
# def s_text_en
|
||||
# Nokogiri::HTML(self.text.en).text
|
||||
# end
|
||||
# def s_text_zh_tw
|
||||
# Nokogiri::HTML(self.text.zh_tw).text
|
||||
# end
|
||||
|
||||
# scope :currently_available, lambda { |category, limit|
|
||||
# # limit ||= 5
|
||||
# # {
|
||||
# # debugger
|
||||
# # a=1
|
||||
# :where => {:bulletin_category_id => bulletin_category_id, :disable => false}#,
|
||||
# # :limit => limit
|
||||
# # }
|
||||
# }
|
||||
def de_pending
|
||||
self.is_pending = false
|
||||
end
|
||||
|
||||
def enabled_for_lang(lang)
|
||||
eval("self.available_for_#{lang}")
|
||||
end
|
||||
|
||||
def publish_month
|
||||
published_at.strftime("%B %Y")
|
||||
end
|
||||
@@ -240,4 +231,8 @@ class Bulletin
|
||||
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
|
||||
vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb
Vendored
+10
-2
@@ -7,10 +7,16 @@
|
||||
|
||||
<table class="table table-bordered">
|
||||
<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.postdate') %></th>
|
||||
</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? %>
|
||||
<%=render :partial => 'shared/search_not_found' %>
|
||||
<% elsif !params[:search_query].blank? %>
|
||||
@@ -18,7 +24,9 @@
|
||||
<% end %>
|
||||
<% @bulletins.each do |post| %>
|
||||
<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) %>
|
||||
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
|
||||
</td>
|
||||
|
||||
Vendored
+1
-1
@@ -4,7 +4,7 @@
|
||||
<div class="info1">
|
||||
<span class="pull-right"><%= dislpay_view_count(@bulletin) %></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 class="news_image">
|
||||
|
||||
@@ -34,6 +34,7 @@ Rails.application.routes.draw do
|
||||
resources :tags
|
||||
end
|
||||
namespace :front_end do
|
||||
match "index_by_unit" => "bulletins#index_bulletins_by_unit",:as => :index_bulletins_by_unit
|
||||
resources :bulletins # do
|
||||
# match "preview" => "bulletins#preview_content",:as => :get_preview_content
|
||||
# end
|
||||
|
||||
Vendored
+14
-4
@@ -8,6 +8,12 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
|
||||
# GET /news_bulletins
|
||||
# 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
|
||||
@page = Page.find(params[:page_id])
|
||||
if !params[:search_query].blank?
|
||||
@@ -42,10 +48,14 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
|
||||
preview_content
|
||||
else
|
||||
''
|
||||
@news_bulletin = NewsBulletin.all.available_for_lang(I18n.locale).can_display.where(_id: params[:id]).first
|
||||
unless @news_bulletin.disable?
|
||||
impressionist(@news_bulletin)
|
||||
get_categorys
|
||||
@news_bulletin = NewsBulletin.all.can_display.where(_id: params[:id]).first
|
||||
if !@news_bulletin.disable?
|
||||
if @news_bulletin.enabled_for_lang(I18n.locale.to_s)
|
||||
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
|
||||
render :nothing => true, :status => 403
|
||||
end
|
||||
|
||||
@@ -140,6 +140,10 @@ class NewsBulletin
|
||||
|
||||
end
|
||||
|
||||
def enabled_for_lang(lang)
|
||||
eval("self.available_for_#{lang}")
|
||||
end
|
||||
|
||||
def de_pending
|
||||
self.is_pending = false
|
||||
end
|
||||
|
||||
+4
@@ -4,6 +4,10 @@
|
||||
|
||||
<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? %>
|
||||
<%=render :partial => 'shared/search_not_found' %>
|
||||
<% elsif !params[:search_query].blank? %>
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<span class="date"><%= display_date(@news_bulletin.postdate) %></span>
|
||||
<% unit = @news_bulletin.unit_list_for_anc.title rescue nil %>
|
||||
<%= " | " 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 class="news_image">
|
||||
|
||||
@@ -34,6 +34,7 @@ Rails.application.routes.draw do
|
||||
resources :tags
|
||||
end
|
||||
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
|
||||
# match "preview" => "news_bulletins#preview_content",:as => :get_preview_content
|
||||
# end
|
||||
|
||||
Reference in new issue
Block a user