add conferene list order function

This commit is contained in:
Rueshyna 2013-02-25 11:38:11 +08:00 committed by chris
parent 1f58ed5cda
commit 522e0481e1
5 changed files with 78 additions and 68 deletions

View File

@ -141,6 +141,7 @@ GEM
jquery-rails jquery-rails
railties (>= 3.1.0) railties (>= 3.1.0)
json (1.7.7) json (1.7.7)
libv8 (3.11.8.13)
mail (2.4.4) mail (2.4.4)
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
@ -224,6 +225,7 @@ GEM
rdoc (~> 3.4) rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0) thor (>= 0.14.6, < 2.0)
rake (10.0.3) rake (10.0.3)
rb-readline (0.4.2)
rdoc (3.12.1) rdoc (3.12.1)
json (~> 1.4) json (~> 1.4)
redis (3.0.2) redis (3.0.2)
@ -233,6 +235,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)
ref (1.0.2)
resque (1.23.0) resque (1.23.0)
multi_json (~> 1.0) multi_json (~> 1.0)
redis-namespace (~> 1.0) redis-namespace (~> 1.0)
@ -313,6 +316,9 @@ GEM
sunspot (= 1.3.3) sunspot (= 1.3.3)
sunspot_solr (1.3.3) sunspot_solr (1.3.3)
terminal-table (1.4.5) terminal-table (1.4.5)
therubyracer (0.11.3)
libv8 (~> 3.11.8.12)
ref
thor (0.17.0) thor (0.17.0)
tilt (1.3.3) tilt (1.3.3)
tinymce-rails (3.5.8) tinymce-rails (3.5.8)
@ -357,6 +363,7 @@ DEPENDENCIES
jquery-rails (= 2.1.4) jquery-rails (= 2.1.4)
jquery-ui-rails jquery-ui-rails
kaminari! kaminari!
libv8 (~> 3.11.8)
mime-types mime-types
mini_magick mini_magick
mongo_session_store-rails3 (= 3.0.6) mongo_session_store-rails3 (= 3.0.6)
@ -373,6 +380,7 @@ DEPENDENCIES
radius radius
rails (~> 3.2.9) rails (~> 3.2.9)
rake rake
rb-readline
redis (>= 2.1.1) redis (>= 2.1.1)
redis-namespace redis-namespace
redis-search redis-search
@ -393,6 +401,7 @@ DEPENDENCIES
sunspot-rails-tester sunspot-rails-tester
sunspot_mongo sunspot_mongo
sunspot_solr sunspot_solr
therubyracer
tinymce-rails tinymce-rails
uglifier uglifier
watchr watchr

View File

@ -1,6 +1,14 @@
class Panel::PersonalConference::Desktop::ConferencePagesController < ApplicationController class Panel::PersonalConference::Desktop::ConferencePagesController < ApplicationController
def index def index
@view_by = params[:view]
@writing_conferences = WritingConference.all @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 @level_types = ConferencePaperType.all
respond_to do |format| respond_to do |format|

View File

@ -1,9 +1,9 @@
module Panel::PersonalConference::Desktop::ConferencePagesHelper module Panel::PersonalConference::Desktop::ConferencePagesHelper
def publication_record publication def publication_record publication, view
content_tag :li, content_tag :li,
:class => "list_t_item" do :class => "list_t_item" do
marker + \ marker + \
content(publication) + \ content(publication, view) + \
edit_or_delete(publication) edit_or_delete(publication)
end end
end end
@ -15,17 +15,26 @@ module Panel::PersonalConference::Desktop::ConferencePagesHelper
content_tag(:a, "", :class => "icon-star-empty") content_tag(:a, "", :class => "icon-star-empty")
end end
def content publication def content publication, view
content_tag(:div, "conference : " + publication.conference_title, case view
:class => "list_t_title") + \ when "conference_title"
content_tag(:div, "title : " + publication.paper_title, des = content_tag(:div, publication.conference_title,
:class => "list_t_des") + \ :class => "list_t_des")
content_tag(:div, "keyword :" + publication.keywords, when "keywords"
:class => "list_t_des") + \ des = content_tag(:div, publication.keywords,
content_tag(:div, "abstract : " + publication.abstract, :class => "list_t_des")
:class => "list_t_des") + \ when "abstract"
content_tag(:div, link_publication_file(publication), des = content_tag(:div, publication.abstract,
:class => "list_t_des") :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 end
def edit_or_delete publication def edit_or_delete publication

View File

@ -2,24 +2,21 @@ class WritingConference
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes 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 :paper_title, localize: true
field :conference_title, localize: true field :conference_title, localize: true
field :authors, localize: true field :authors, localize: true
field :location, localize: true field :location, localize: true
field :sponsor, localize: true field :sponsor, localize: true
has_and_belongs_to_many :tags, :class_name => "PersonalConferenceTag" has_and_belongs_to_many :tags, :class_name => "PersonalConferenceTag"
has_and_belongs_to_many :conference_author_types has_and_belongs_to_many :conference_author_types
has_and_belongs_to_many :conference_paper_types has_and_belongs_to_many :conference_paper_types
field :year field :year
field :language field :language
field :period_start_date, :type => Date field :period_start_date, :type => Date
@ -31,54 +28,41 @@ class WritingConference
field :note field :note
field :create_user_id, :type => BSON::ObjectId field :create_user_id, :type => BSON::ObjectId
field :update_user_id, :type => BSON::ObjectId field :update_user_id, :type => BSON::ObjectId
# field :is_top, :type => Boolean, :default => false # field :is_top, :type => Boolean, :default => false
# field :is_hot, :type => Boolean, :default => false # field :is_hot, :type => Boolean, :default => false
# field :is_hidden, :type => Boolean, :default => false # field :is_hidden, :type => Boolean, :default => false
has_many :writing_conference_files, :autosave => true, :dependent => :destroy has_many :writing_conference_files, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :writing_conference_files, :allow_destroy => true accepts_nested_attributes_for :writing_conference_files, :allow_destroy => true
# before_save :update_avliable_language, :clean_checkboxs # before_save :update_avliable_language, :clean_checkboxs
validates :paper_title, :at_least_one => true validates :paper_title, :at_least_one => true
before_validation :add_http before_validation :add_http
after_save :save_writing_conference_files 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?} 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 ) def self.search( category_id = nil )
if category_id.to_s.size > 0
if category_id.to_s.size > 0 find(:all, :conditions => {writing_conference_category_id: category_id}).desc( :is_top, :title )
else
find(:all, :conditions => {writing_conference_category_id: category_id}).desc( :is_top, :title ) find(:all).desc( :is_top, :title)
end
else
find(:all).desc( :is_top, :title)
end
end end
def self.widget_datas def self.widget_datas
where( :is_hidden => false ).desc(:is_top, :created_at)
where( :is_hidden => false ).desc(:is_top, :created_at)
end end
def is_top? def is_top?
self.is_top self.is_top
end end
def sorted_tags def sorted_tags
tags.order_by(I18n.locale, :asc) tags.order_by(I18n.locale, :asc)
end end
def update_avliable_language def update_avliable_language
VALID_LOCALES.each do |locale| VALID_LOCALES.each do |locale|
if (title_translations[locale].blank? rescue true) if (title_translations[locale].blank? rescue true)
@ -88,25 +72,25 @@ class WritingConference
end end
end end
end end
def save_writing_conference_files def save_writing_conference_files
self.writing_conference_files.each do |t| self.writing_conference_files.each do |t|
if t.should_destroy if t.should_destroy
t.destroy t.destroy
end end
end end
end end
def create_link def create_link
title = ["\"#{self.paper_title}\""] title = ["\"#{self.paper_title}\""]
title << self.conference_title title << self.conference_title
title << self.sponsor title << self.sponsor
title << self.location title << self.location
title << "#{period_start_date}-#{period_end_date}" title << "#{period_start_date}-#{period_end_date}"
# title << "(#{self.conference_paper_types.collect{|x| x.title}.join(', ')})" # title << "(#{self.conference_paper_types.collect{|x| x.title}.join(', ')})"
title.join(', ') title.join(', ')
end end
protected protected
@ -122,5 +106,5 @@ class WritingConference
self.conference_author_type_ids.delete('') self.conference_author_type_ids.delete('')
self.conference_level_type_ids.delete('') self.conference_level_type_ids.delete('')
end end
end end

View File

@ -40,12 +40,12 @@
<div class="hh2 hp sdm"> <div class="hh2 hp sdm">
<div class="sdm_t hh2">View</div> <div class="sdm_t hh2">View</div>
<div class="admbg sdm_o"> <div class="admbg sdm_o">
<ul id="journal_view_selection"> <ul id="view_selection">
<li><a class="hp hh2 admtxt" href="conference">Conference</a></li> <li><%= link_to "Conference", panel_personal_conference_desktop_conference_pages_path + "?view=conference_title", :class => "hp hh2 admtxt", "ajax-remote" => "get" %></li>
<li><a class="hp hh2 admtxt" href="title">Title</a></li> <li><%= link_to "Title", panel_personal_conference_desktop_conference_pages_path + "?view=paper_title", :class => "hp hh2 admtxt", "ajax-remote" => "get" %></li>
<li><a class="hp hh2 admtxt" href="file">File</a></li> <li><%= link_to "File", panel_personal_conference_desktop_conference_pages_path + "?view=file", :class => "hp hh2 admtxt", "ajax-remote" => "get" %></li>
<li><a class="hp hh2 admtxt" href="keywords">Keywords</a></li> <li><%= link_to "Keywords", panel_personal_conference_desktop_conference_pages_path + "?view=keywords", :class => "hp hh2 admtxt", "ajax-remote" => "get" %></li>
<li><a class="hp hh2 admtxt" href="abstract">Abstract</a></li> <li><%= link_to "Abstract", panel_personal_conference_desktop_conference_pages_path + "?view=abstract", :class => "hp hh2 admtxt", "ajax-remote" => "get" %></li>
</ul> </ul>
</div> </div>
</div> </div>
@ -70,7 +70,7 @@
<div class="viewport"> <div class="viewport">
<div class="overview"> <div class="overview">
<% @writing_conferences.each do |w| %> <% @writing_conferences.each do |w| %>
<%= publication_record w%> <%= publication_record w, @view_by%>
<% end %> <% end %>
</div> </div>
</div> </div>