From 167a71272abd2d06b5de5781b925c2e5487064b0 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 29 Apr 2013 14:59:08 +0800 Subject: [PATCH] queries need to be rethink --- app/models/asset.rb | 9 +++------ .../panel/announcement/back_end/tags_controller.rb | 8 -------- .../announcement/app/models/bulletin.rb | 6 ------ .../archive/app/models/archive_file.rb | 5 ----- vendor/built_in_modules/faq/app/models/qa.rb | 5 ----- .../gallery/app/models/gallery_image.rb | 14 ++++++++------ .../personal_book/app/models/writing_book.rb | 9 +++------ .../app/models/writing_conference.rb | 10 ++++------ .../personal_diploma/app/models/diploma.rb | 10 ++++------ .../personal_experience/app/models/experience.rb | 10 ++++------ .../personal_honor/app/models/honor.rb | 10 ++++------ .../personal_journal/app/models/writing_journal.rb | 10 ++++------ .../personal_lab/app/models/lab.rb | 10 ++++------ .../personal_patent/app/models/writing_patent.rb | 10 ++++------ .../personal_project/app/models/project.rb | 10 ++++------ .../personal_research/app/models/research.rb | 10 ++++------ .../web_resource/app/models/web_link.rb | 5 ----- 17 files changed, 50 insertions(+), 101 deletions(-) delete mode 100644 vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/tags_controller.rb diff --git a/app/models/asset.rb b/app/models/asset.rb index e2b4df83..cf6ab0f0 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -2,6 +2,8 @@ class Asset include Mongoid::Document include Mongoid::Timestamps + include OrbitTag::Taggable + taggable mount_uploader :data, FileAssetUploader @@ -16,15 +18,10 @@ class Asset belongs_to :asset_category belongs_to :assetable, polymorphic: true - has_and_belongs_to_many :tags, :class_name => "AssetTag" + # has_and_belongs_to_many :tags, :class_name => "AssetTag" before_save :clean_tags - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags - end - protected def clean_tags diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/tags_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/tags_controller.rb deleted file mode 100644 index 808d6cc8..00000000 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/tags_controller.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Panel::Announcement::BackEnd::TagsController < Admin::TagsController - - def initialize - super - @app_title = 'announcement' - 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 73033ce8..e84b020f 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -199,12 +199,6 @@ class Bulletin return nil end - # def sorted_tags - # #tags.order_by(I18n.locale, :asc) - # tags - # end - - def to_preview preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_announcement_front_end_bulletin_path",:object_class_type=>"Bulletin") diff --git a/vendor/built_in_modules/archive/app/models/archive_file.rb b/vendor/built_in_modules/archive/app/models/archive_file.rb index 75b133e7..1329125e 100644 --- a/vendor/built_in_modules/archive/app/models/archive_file.rb +++ b/vendor/built_in_modules/archive/app/models/archive_file.rb @@ -61,11 +61,6 @@ class ArchiveFile self.is_top end - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags - end - def get_file_icon( file_data ) file_icon = "#{file_data.split('.')[-1]}".html_safe diff --git a/vendor/built_in_modules/faq/app/models/qa.rb b/vendor/built_in_modules/faq/app/models/qa.rb index 91f221c3..f677a1b6 100644 --- a/vendor/built_in_modules/faq/app/models/qa.rb +++ b/vendor/built_in_modules/faq/app/models/qa.rb @@ -60,11 +60,6 @@ class Qa def is_top? self.is_top - end - - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags end def update_avliable_language diff --git a/vendor/built_in_modules/gallery/app/models/gallery_image.rb b/vendor/built_in_modules/gallery/app/models/gallery_image.rb index 8b958ddd..f0504db2 100644 --- a/vendor/built_in_modules/gallery/app/models/gallery_image.rb +++ b/vendor/built_in_modules/gallery/app/models/gallery_image.rb @@ -1,14 +1,16 @@ class GalleryImage include Mongoid::Document - include Mongoid::Timestamps + include Mongoid::Timestamps + include OrbitTag::Taggable + taggable - mount_uploader :file, GalleryUploader + mount_uploader :file, GalleryUploader - field :title - field :description, localize: true + field :title + field :description, localize: true - has_and_belongs_to_many :tags, :class_name => "GalleryTag" + # has_and_belongs_to_many :tags, :class_name => "GalleryTag" - belongs_to :gallery_album + belongs_to :gallery_album end \ No newline at end of file diff --git a/vendor/built_in_modules/personal_book/app/models/writing_book.rb b/vendor/built_in_modules/personal_book/app/models/writing_book.rb index 4fea1d7e..aceb16fc 100644 --- a/vendor/built_in_modules/personal_book/app/models/writing_book.rb +++ b/vendor/built_in_modules/personal_book/app/models/writing_book.rb @@ -4,6 +4,8 @@ class WritingBook include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + include OrbitTag::Taggable + taggable # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } @@ -17,7 +19,7 @@ class WritingBook field :publisher, localize: true field :editor, localize: true - has_and_belongs_to_many :tags, :class_name => "PersonalBookTag" + # has_and_belongs_to_many :tags, :class_name => "PersonalBookTag" has_and_belongs_to_many :book_author_types @@ -76,11 +78,6 @@ class WritingBook def is_top? self.is_top - end - - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags end def update_avliable_language 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 f5f751cf..36ac25b2 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 @@ -3,6 +3,9 @@ class WritingConference include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + include OrbitTag::Taggable + taggable + # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } LANGUAGE_TYPES = [ "English", "Chinese" ] @@ -13,7 +16,7 @@ class WritingConference field :location, 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_paper_types has_and_belongs_to_many :conference_co_authors @@ -79,11 +82,6 @@ class WritingConference self.is_top end - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags - end - def update_avliable_language VALID_LOCALES.each do |locale| if (title_translations[locale].blank? rescue true) diff --git a/vendor/built_in_modules/personal_diploma/app/models/diploma.rb b/vendor/built_in_modules/personal_diploma/app/models/diploma.rb index f7532162..6f2cc3b8 100644 --- a/vendor/built_in_modules/personal_diploma/app/models/diploma.rb +++ b/vendor/built_in_modules/personal_diploma/app/models/diploma.rb @@ -4,6 +4,9 @@ class Diploma include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + + include OrbitTag::Taggable + taggable # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } @@ -15,7 +18,7 @@ class Diploma field :department, localize: true field :degree, localize: true - has_and_belongs_to_many :tags, :class_name => "PersonalDiplomaTag" + # has_and_belongs_to_many :tags, :class_name => "PersonalDiplomaTag" field :year field :language @@ -49,11 +52,6 @@ class Diploma def is_top? self.is_top - end - - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags end def update_avliable_language diff --git a/vendor/built_in_modules/personal_experience/app/models/experience.rb b/vendor/built_in_modules/personal_experience/app/models/experience.rb index 5ff56f9b..61335b25 100644 --- a/vendor/built_in_modules/personal_experience/app/models/experience.rb +++ b/vendor/built_in_modules/personal_experience/app/models/experience.rb @@ -4,6 +4,9 @@ class Experience include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + + include OrbitTag::Taggable + taggable # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } @@ -14,7 +17,7 @@ class Experience field :department, localize: true field :job_title, localize: true - has_and_belongs_to_many :tags, :class_name => "PersonalExperienceTag" + # has_and_belongs_to_many :tags, :class_name => "PersonalExperienceTag" belongs_to :experience_category @@ -63,11 +66,6 @@ class Experience def is_top? self.is_top - end - - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags end def update_avliable_language diff --git a/vendor/built_in_modules/personal_honor/app/models/honor.rb b/vendor/built_in_modules/personal_honor/app/models/honor.rb index 4020cc9e..fe33fa6a 100644 --- a/vendor/built_in_modules/personal_honor/app/models/honor.rb +++ b/vendor/built_in_modules/personal_honor/app/models/honor.rb @@ -4,6 +4,9 @@ class Honor include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + + include OrbitTag::Taggable + taggable # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } @@ -11,7 +14,7 @@ class Honor - has_and_belongs_to_many :tags, :class_name => "PersonalHonorTag" + # has_and_belongs_to_many :tags, :class_name => "PersonalHonorTag" belongs_to :honor_category @@ -60,11 +63,6 @@ class Honor def is_top? self.is_top - end - - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags end def update_avliable_language diff --git a/vendor/built_in_modules/personal_journal/app/models/writing_journal.rb b/vendor/built_in_modules/personal_journal/app/models/writing_journal.rb index 686afa74..ece4a126 100644 --- a/vendor/built_in_modules/personal_journal/app/models/writing_journal.rb +++ b/vendor/built_in_modules/personal_journal/app/models/writing_journal.rb @@ -3,13 +3,16 @@ class WritingJournal include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + include OrbitTag::Taggable + taggable + LANGUAGE_TYPES = [ "English", "Chinese" ] field :paper_title, localize: true field :journal_title, localize: true field :authors, localize: true - has_and_belongs_to_many :tags, :class_name => "PersonalJournalTag" + # has_and_belongs_to_many :tags, :class_name => "PersonalJournalTag" has_and_belongs_to_many :journal_author_types has_and_belongs_to_many :journal_level_types has_and_belongs_to_many :journal_co_authors @@ -80,11 +83,6 @@ class WritingJournal self.is_top end - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags - end - def update_avliable_language VALID_LOCALES.each do |locale| if (title_translations[locale].blank? rescue true) diff --git a/vendor/built_in_modules/personal_lab/app/models/lab.rb b/vendor/built_in_modules/personal_lab/app/models/lab.rb index af661e4b..20b0a8c1 100644 --- a/vendor/built_in_modules/personal_lab/app/models/lab.rb +++ b/vendor/built_in_modules/personal_lab/app/models/lab.rb @@ -4,6 +4,9 @@ class Lab include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + + include OrbitTag::Taggable + taggable # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } @@ -15,7 +18,7 @@ class Lab field :participating_professor, localize: true field :participating_student, localize: true - has_and_belongs_to_many :tags, :class_name => "PersonalLabTag" + # has_and_belongs_to_many :tags, :class_name => "PersonalLabTag" field :year field :language @@ -69,11 +72,6 @@ class Lab def is_top? self.is_top - end - - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags end def update_avliable_language diff --git a/vendor/built_in_modules/personal_patent/app/models/writing_patent.rb b/vendor/built_in_modules/personal_patent/app/models/writing_patent.rb index 8798c79d..2fad9f5b 100644 --- a/vendor/built_in_modules/personal_patent/app/models/writing_patent.rb +++ b/vendor/built_in_modules/personal_patent/app/models/writing_patent.rb @@ -4,6 +4,9 @@ class WritingPatent include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + + include OrbitTag::Taggable + taggable # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } @@ -13,7 +16,7 @@ class WritingPatent field :patent_title, localize: true field :authors, localize: true - has_and_belongs_to_many :tags, :class_name => "PersonalPatentTag" + # has_and_belongs_to_many :tags, :class_name => "PersonalPatentTag" belongs_to :writing_patent_category @@ -69,11 +72,6 @@ class WritingPatent def is_top? self.is_top - end - - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags end def update_avliable_language diff --git a/vendor/built_in_modules/personal_project/app/models/project.rb b/vendor/built_in_modules/personal_project/app/models/project.rb index ffcbaaab..f40e815e 100644 --- a/vendor/built_in_modules/personal_project/app/models/project.rb +++ b/vendor/built_in_modules/personal_project/app/models/project.rb @@ -4,6 +4,9 @@ class Project include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + + include OrbitTag::Taggable + taggable # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } @@ -15,7 +18,7 @@ class Project field :participator, localize: true field :unit, localize: true - has_and_belongs_to_many :tags, :class_name => "PersonalProjectTag" + # has_and_belongs_to_many :tags, :class_name => "PersonalProjectTag" belongs_to :project_category @@ -71,11 +74,6 @@ class Project def is_top? self.is_top - end - - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags end def update_avliable_language diff --git a/vendor/built_in_modules/personal_research/app/models/research.rb b/vendor/built_in_modules/personal_research/app/models/research.rb index 4908304d..c83ac738 100644 --- a/vendor/built_in_modules/personal_research/app/models/research.rb +++ b/vendor/built_in_modules/personal_research/app/models/research.rb @@ -4,6 +4,9 @@ class Research include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + + include OrbitTag::Taggable + taggable # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } @@ -14,7 +17,7 @@ class Research field :authors, localize: true field :extracted_chapters, localize: true - has_and_belongs_to_many :tags, :class_name => "PersonalResearchTag" + # has_and_belongs_to_many :tags, :class_name => "PersonalResearchTag" field :year field :language @@ -66,11 +69,6 @@ class Research def is_top? self.is_top - end - - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags end def update_avliable_language diff --git a/vendor/built_in_modules/web_resource/app/models/web_link.rb b/vendor/built_in_modules/web_resource/app/models/web_link.rb index 2fb54e99..50dfe09d 100644 --- a/vendor/built_in_modules/web_resource/app/models/web_link.rb +++ b/vendor/built_in_modules/web_resource/app/models/web_link.rb @@ -56,11 +56,6 @@ class WebLink def is_top? self.is_top - end - - def sorted_tags - #tags.order_by(I18n.locale, :asc) - tags end def update_avliable_language