diff --git a/Gemfile.lock b/Gemfile.lock index a34c36349..18f66fbf0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -84,10 +84,6 @@ GEM railties (~> 3.0) thor (~> 0.14) json (1.6.5) - kaminari (0.13.0) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) - railties (>= 3.0.0) linecache19 (0.5.12) ruby_core_source (>= 0.1.4) mail (2.3.0) diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 13d282bb4..d74a543b9 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -48,5 +48,9 @@ class User value = values.detect {|value| value.attribute_field_id == field_id} rescue nil value ? value : self.attribute_values.build end + + def self.from_id(id) + User.find(id) rescue nil + end end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 919fc387e..7e66179a4 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -18,7 +18,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController @bulletin_categories = BulletinCategory.all module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) - @tags = Tag.all(:conditions => {:module_app_id => module_app.id}) + @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) respond_to do |format| format.html # index.html.erb @@ -156,7 +156,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController bulletins.order_by([params[:sort], params[:direction]]) when 'category' category_ids = bulletins.distinct(:bulletin_category_id) - categories = BulletinCategory.find(category_ids) if category_ids + categories = BulletinCategory.find(category_ids) rescue nil if categories h = Hash.new categories.each { |category| h[category.i18n_variable[I18n.locale]] = category.id } @@ -172,10 +172,24 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! sorted.collect {|a| a[1] } when 'status' - # a << bulletins.order_by(:is_top, params[:direction]).order_by - # a << bulletins.where(:is_hot => true).entries - # a << bulletins.where(:is_hidden => true).entries - # a.flatten.uniq + bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction]) + when 'update_user_id' + user_ids = bulletins.distinct(:update_user_id) + users = User.find(user_ids) rescue nil + if users + h = Hash.new + users.each { |user| h[user.name] = user.id } + sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! + sorted_users = sorted.collect {|a| bulletins.where(:update_user_id => a[1]).entries } + sorted_users.flatten + else + nil + end + when 'tags' + a = Array.new + AnnouncementTag.all.order_by(I18n.locale, params[:direction]).each { |tag| a << tag.bulletins } + a.flatten! + a.uniq end end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index d086d531d..7c258f236 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -106,6 +106,17 @@ class Bulletin def text @text ||= I18nVariable.first(:conditions => {:key => 'text', :language_value_id => self.id, :language_value_type => self.class}) rescue nil end + + def self.filter(bulletins) + bulletins.each do |bulletin| + p "#{bulletin.id}/#{bulletin.is_top}/#{bulletin.is_hot}/#{bulletin.is_hidden}" + end + return nil + end + + def sorted_tags + tags.order_by(I18n.locale, :asc) + end protected diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb index dcfa74854..3f6f50e1e 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb @@ -32,11 +32,11 @@