From a7005c6e8b6e9a3aa53330ebd31fe7d8b065f3b7 Mon Sep 17 00:00:00 2001 From: manson Date: Mon, 16 Jun 2014 15:03:25 +0800 Subject: [PATCH 1/3] Removed impressionist counter cache --- app/models/bulletin.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index ffb5cc8..e8bdd98 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -16,7 +16,7 @@ class Bulletin # include Tire::Model::Search # include Tire::Model::Callbacks - is_impressionable :counter_cache => { :column_name => :view_count } + is_impressionable field :title, localize: true field :subtitle, localize: true @@ -158,6 +158,10 @@ class Bulletin User.find(self.email_user_ids) rescue [] end + def view_count + Impression.where(:impressionable_id=>self.id).count + end + protected # def clean_values From d88b2a4e327aaa17dcbcfa617af89baa2bc870e8 Mon Sep 17 00:00:00 2001 From: spen Date: Tue, 13 May 2014 16:29:23 +0800 Subject: [PATCH 2/3] ydu --- .../panel/announcement/front_end/bulletins/show.html.erb | 7 +++++-- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 1 + lib/announcement.rb | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/views/panel/announcement/front_end/bulletins/show.html.erb b/app/views/panel/announcement/front_end/bulletins/show.html.erb index b6d6df2..ca11e10 100644 --- a/app/views/panel/announcement/front_end/bulletins/show.html.erb +++ b/app/views/panel/announcement/front_end/bulletins/show.html.erb @@ -4,8 +4,11 @@
<%= dislpay_view_count(@bulletin) %> <%= display_date_time(@bulletin.postdate) %> - <% unit = @bulletin.cache_dept[I18n.locale.to_s] rescue nil %> - <%= link_to unit,panel_announcement_front_end_index_bulletins_by_unit_path(:name=>unit) unless unit.blank? %> + <% + 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 + %> + <%= t('announcement.default_widget.bulletin_create_dept') + ": " + unit unless unit.blank? %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 5f0bb5e..060de27 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -18,6 +18,7 @@ en: postdate: Post Date subtitle: Subtitle title: Title + bulletin_create_dept: Unit editing_announcement: Edit Announcement editing_announcement_category: Edit Category file: Attachment diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 6e7509e..65d4044 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -18,6 +18,7 @@ zh_tw: postdate: 張貼日期 subtitle: 副標題 title: 標題 + bulletin_create_dept: 單位 editing_announcement: 編輯類別 editing_announcement_category: 編輯類別 error: diff --git a/lib/announcement.rb b/lib/announcement.rb index cabf028..f517bb4 100644 --- a/lib/announcement.rb +++ b/lib/announcement.rb @@ -41,6 +41,7 @@ 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 From a39d979a54ed3694b331e3e74acd7d0e587b98e8 Mon Sep 17 00:00:00 2001 From: spen Date: Tue, 20 May 2014 17:49:18 +0800 Subject: [PATCH 3/3] fix field --- app/models/bulletin.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index e8bdd98..57e996e 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -66,6 +66,11 @@ 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