From 6929d30b5dd2999a30130b67f1f30da3807c7650 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Mon, 25 Feb 2013 11:38:11 +0800 Subject: [PATCH] add conferene list order function --- Gemfile.lock | 9 +++ .../desktop/conference_pages_controller.rb | 8 ++ .../desktop/conference_pages_helper.rb | 35 +++++--- .../app/models/writing_conference.rb | 80 ++++++++----------- .../desktop/conference_pages/index.html.erb | 14 ++-- 5 files changed, 78 insertions(+), 68 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f802d2fa..fa3fbb00 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -135,6 +135,7 @@ GEM jquery-rails railties (>= 3.1.0) json (1.7.7) + libv8 (3.11.8.13) mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -211,6 +212,7 @@ GEM rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) rake (10.0.3) + rb-readline (0.4.2) rdoc (3.12.1) json (~> 1.4) redis (3.0.2) @@ -220,6 +222,7 @@ GEM chinese_pinyin (>= 0.3.0) redis (>= 2.1.1) redis-namespace (>= 1.0.2) + ref (1.0.2) resque (1.23.0) multi_json (~> 1.0) redis-namespace (~> 1.0) @@ -300,6 +303,9 @@ GEM sunspot (= 1.3.3) sunspot_solr (1.3.3) terminal-table (1.4.5) + therubyracer (0.11.3) + libv8 (~> 3.11.8.12) + ref thor (0.17.0) tilt (1.3.3) tinymce-rails (3.5.8) @@ -343,6 +349,7 @@ DEPENDENCIES jquery-rails (= 2.1.4) jquery-ui-rails kaminari! + libv8 (~> 3.11.8) mime-types mini_magick mongo_session_store-rails3 (= 3.0.6) @@ -359,6 +366,7 @@ DEPENDENCIES radius rails (~> 3.2.9) rake + rb-readline redis (>= 2.1.1) redis-namespace redis-search @@ -379,6 +387,7 @@ DEPENDENCIES sunspot-rails-tester sunspot_mongo sunspot_solr + therubyracer tinymce-rails uglifier watchr diff --git a/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/desktop/conference_pages_controller.rb b/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/desktop/conference_pages_controller.rb index 4915d5c7..377d8a11 100644 --- a/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/desktop/conference_pages_controller.rb +++ b/vendor/built_in_modules/personal_conference/app/controllers/panel/personal_conference/desktop/conference_pages_controller.rb @@ -1,6 +1,14 @@ class Panel::PersonalConference::Desktop::ConferencePagesController < ApplicationController def index + @view_by = params[:view] @writing_conferences = WritingConference.all + + if @view_by.nil? + @writing_conferences = @writing_conferences.asc(:paper_title) + else + @writing_conferences = @writing_conferences.asc(@view_by).asc(:paper_title) + end + @level_types = ConferencePaperType.all respond_to do |format| diff --git a/vendor/built_in_modules/personal_conference/app/helpers/panel/personal_conference/desktop/conference_pages_helper.rb b/vendor/built_in_modules/personal_conference/app/helpers/panel/personal_conference/desktop/conference_pages_helper.rb index cac790d3..afff7344 100644 --- a/vendor/built_in_modules/personal_conference/app/helpers/panel/personal_conference/desktop/conference_pages_helper.rb +++ b/vendor/built_in_modules/personal_conference/app/helpers/panel/personal_conference/desktop/conference_pages_helper.rb @@ -1,9 +1,9 @@ module Panel::PersonalConference::Desktop::ConferencePagesHelper - def publication_record publication + def publication_record publication, view content_tag :li, :class => "list_t_item" do marker + \ - content(publication) + \ + content(publication, view) + \ edit_or_delete(publication) end end @@ -15,17 +15,26 @@ module Panel::PersonalConference::Desktop::ConferencePagesHelper content_tag(:a, "", :class => "icon-star-empty") end - def content publication - content_tag(:div, "conference : " + publication.conference_title, - :class => "list_t_title") + \ - content_tag(:div, "title : " + publication.paper_title, - :class => "list_t_des") + \ - content_tag(:div, "keyword :" + publication.keywords, - :class => "list_t_des") + \ - content_tag(:div, "abstract : " + publication.abstract, - :class => "list_t_des") + \ - content_tag(:div, link_publication_file(publication), - :class => "list_t_des") + def content publication, view + case view + when "conference_title" + des = content_tag(:div, publication.conference_title, + :class => "list_t_des") + when "keywords" + des = content_tag(:div, publication.keywords, + :class => "list_t_des") + when "abstract" + des = content_tag(:div, publication.abstract, + :class => "list_t_des") + when "file" + des = content_tag(:div, link_publication_file(publication), + :class => "list_t_des") + else + end + + content_tag(:div, publication.paper_title, + :class => "list_t_title") + des + end def edit_or_delete publication diff --git a/vendor/built_in_modules/personal_conference/app/models/writing_conference.rb b/vendor/built_in_modules/personal_conference/app/models/writing_conference.rb index efb05cf9..9248c977 100644 --- a/vendor/built_in_modules/personal_conference/app/models/writing_conference.rb +++ b/vendor/built_in_modules/personal_conference/app/models/writing_conference.rb @@ -2,24 +2,21 @@ class WritingConference include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes - - # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } - - LANGUAGE_TYPES = [ "English", "Chinese" ] + # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } + + LANGUAGE_TYPES = [ "English", "Chinese" ] field :paper_title, localize: true field :conference_title, localize: true field :authors, localize: true field :location, localize: true field :sponsor, localize: true - + has_and_belongs_to_many :tags, :class_name => "PersonalConferenceTag" - has_and_belongs_to_many :conference_author_types has_and_belongs_to_many :conference_paper_types - - + field :year field :language field :period_start_date, :type => Date @@ -31,54 +28,41 @@ class WritingConference field :note field :create_user_id, :type => BSON::ObjectId field :update_user_id, :type => BSON::ObjectId - + # field :is_top, :type => Boolean, :default => false # field :is_hot, :type => Boolean, :default => false # field :is_hidden, :type => Boolean, :default => false - + has_many :writing_conference_files, :autosave => true, :dependent => :destroy - accepts_nested_attributes_for :writing_conference_files, :allow_destroy => true - + # before_save :update_avliable_language, :clean_checkboxs validates :paper_title, :at_least_one => true - before_validation :add_http - after_save :save_writing_conference_files - validates :url, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?/i, :unless => Proc.new{self.url.blank?} def self.search( category_id = nil ) - - if category_id.to_s.size > 0 - - find(:all, :conditions => {writing_conference_category_id: category_id}).desc( :is_top, :title ) - - else - - find(:all).desc( :is_top, :title) - - end - + if category_id.to_s.size > 0 + find(:all, :conditions => {writing_conference_category_id: category_id}).desc( :is_top, :title ) + else + find(:all).desc( :is_top, :title) + end end - def self.widget_datas - - where( :is_hidden => false ).desc(:is_top, :created_at) - + where( :is_hidden => false ).desc(:is_top, :created_at) end def is_top? self.is_top - end + end def sorted_tags tags.order_by(I18n.locale, :asc) end - + def update_avliable_language VALID_LOCALES.each do |locale| if (title_translations[locale].blank? rescue true) @@ -88,25 +72,25 @@ class WritingConference end end end - + def save_writing_conference_files - self.writing_conference_files.each do |t| - if t.should_destroy - t.destroy - end + self.writing_conference_files.each do |t| + if t.should_destroy + t.destroy + end end end - + def create_link - - title = ["\"#{self.paper_title}\""] - title << self.conference_title - title << self.sponsor - title << self.location - title << "#{period_start_date}-#{period_end_date}" - # title << "(#{self.conference_paper_types.collect{|x| x.title}.join(', ')})" - title.join(', ') - + + title = ["\"#{self.paper_title}\""] + title << self.conference_title + title << self.sponsor + title << self.location + title << "#{period_start_date}-#{period_end_date}" + # title << "(#{self.conference_paper_types.collect{|x| x.title}.join(', ')})" + title.join(', ') + end protected @@ -122,5 +106,5 @@ class WritingConference self.conference_author_type_ids.delete('') self.conference_level_type_ids.delete('') end - + end diff --git a/vendor/built_in_modules/personal_conference/app/views/panel/personal_conference/desktop/conference_pages/index.html.erb b/vendor/built_in_modules/personal_conference/app/views/panel/personal_conference/desktop/conference_pages/index.html.erb index 7a3848df..e30c9e4a 100644 --- a/vendor/built_in_modules/personal_conference/app/views/panel/personal_conference/desktop/conference_pages/index.html.erb +++ b/vendor/built_in_modules/personal_conference/app/views/panel/personal_conference/desktop/conference_pages/index.html.erb @@ -40,12 +40,12 @@
View
-
    -
  • Conference
  • -
  • Title
  • -
  • File
  • -
  • Keywords
  • -
  • Abstract
  • +
      +
    • <%= link_to "Conference", panel_personal_conference_desktop_conference_pages_path + "?view=conference_title", :class => "hp hh2 admtxt", "ajax-remote" => "get" %>
    • +
    • <%= link_to "Title", panel_personal_conference_desktop_conference_pages_path + "?view=paper_title", :class => "hp hh2 admtxt", "ajax-remote" => "get" %>
    • +
    • <%= link_to "File", panel_personal_conference_desktop_conference_pages_path + "?view=file", :class => "hp hh2 admtxt", "ajax-remote" => "get" %>
    • +
    • <%= link_to "Keywords", panel_personal_conference_desktop_conference_pages_path + "?view=keywords", :class => "hp hh2 admtxt", "ajax-remote" => "get" %>
    • +
    • <%= link_to "Abstract", panel_personal_conference_desktop_conference_pages_path + "?view=abstract", :class => "hp hh2 admtxt", "ajax-remote" => "get" %>
@@ -70,7 +70,7 @@
<% @writing_conferences.each do |w| %> - <%= publication_record w%> + <%= publication_record w, @view_by%> <% end %>