From 127ab3845c917a7d7b9cb356f4fac8693dc3b02e Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 3 May 2013 12:11:48 +0800 Subject: [PATCH] Changes for queries --- app/controllers/default_widget_controller.rb | 13 +----- app/models/asset.rb | 2 +- .../front_end/bulletins_controller.rb | 8 +--- .../widget/bulletins_controller.rb | 18 ++++---- .../widget/bulletins/bulletins_list.html.erb | 2 +- .../front_end/archive_files_controller.rb | 13 ++---- .../widget/archive_files_controller.rb | 3 +- .../panel/faq/front_end/qas_controller.rb | 3 +- vendor/built_in_modules/faq/app/models/qa.rb | 2 +- .../back_end/album_images_controller.rb | 2 +- .../gallery/back_end/albums_controller.rb | 42 +++++++------------ .../gallery/front_end/albums_controller.rb | 28 ++++--------- .../front_end/orbit_galleries_controller.rb | 15 +++---- .../member/widget/web_links_controller.rb | 7 ++-- .../app/models/writing_conference.rb | 2 +- .../personal_diploma/app/models/diploma.rb | 2 +- .../app/models/experience.rb | 2 +- .../personal_honor/app/models/honor.rb | 2 +- .../app/models/writing_journal.rb | 2 +- .../personal_lab/app/models/lab.rb | 2 +- .../app/models/writing_patent.rb | 2 +- .../personal_project/app/models/project.rb | 2 +- .../personal_research/app/models/research.rb | 2 +- .../front_end/web_links_controller.rb | 4 +- .../widget/web_links_controller.rb | 3 +- .../web_resource/app/models/web_link.rb | 2 +- 26 files changed, 63 insertions(+), 122 deletions(-) diff --git a/app/controllers/default_widget_controller.rb b/app/controllers/default_widget_controller.rb index 47505dc1..0e0a0ddf 100644 --- a/app/controllers/default_widget_controller.rb +++ b/app/controllers/default_widget_controller.rb @@ -17,25 +17,16 @@ class DefaultWidgetController< OrbitWidgetController result_objects = nil if !params["tag_id"].blank? - @tags = Tag.find(params["tag_id"]) rescue nil - result_ids = nil - - result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).entries.collect{|t| t.id}} if params["category_id"].blank? #has tag no cate - #nothing + result = ori_class_name.constantize.where(:tagged_ids.in => params["tag_id"]) else #has tag and cate - # result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).where(:#{get_category_field_name(ori_class_name)}.in=>params["category_id"]).available_for_lang(I18n.locale).can_display.collect{|t| t.id}}.flatten - result_ids << eval("#{ori_class_name}.where(:#{get_category_field_name(ori_class_name)}.in=>params['category_id']).entries.collect{|t| t.id}") - result_ids.flatten! - + result = eval("#{ori_class_name}.where(:#{get_category_field_name(ori_class_name)}.in=>params['category_id'], :tagged_ids.in => params['tag_id'])") end - result = eval("#{ori_class_name}.where(:id=>result_ids)") elsif params["category_id"].blank? #no tag no cate result = eval(@default_widget["query"]) else #no tag has cate result = eval("#{ori_class_name}.where(:#{get_category_field_name(ori_class_name)}.in=>params['category_id'])") end - date_now = Time.now result.available_for_lang(I18n.locale).can_display.desc(:is_top, :postdate) end diff --git a/app/models/asset.rb b/app/models/asset.rb index cf6ab0f0..f9f1d4d3 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -25,7 +25,7 @@ class Asset protected def clean_tags - self.tag_ids.delete('') + self.tagged_ids.delete('') end end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index 9866f67f..a0424ab1 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -51,17 +51,13 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController else date_now = Time.now if !params[:category_id].blank? && !params[:tag_id].blank? - @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.available_for_lang(I18n.locale).can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) + @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:bulletin_category_id => params[:category_id], :tagged_ids => params[:tag_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil elsif !params[:category_id].blank? @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil elsif !params[:tag_id].blank? - @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) + @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) else @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num) end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb index a8c016e8..e3ff58d4 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb @@ -34,9 +34,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:bulletin_category_id => @category_id).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) @current_category = BulletinCategory.from_id(@category_id) rescue nil elsif !params[:tag_id].blank? - @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) + @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id])any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) else @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) end @@ -59,11 +57,9 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(@page_num ) @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil elsif !params[:tag_id].blank? - @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(@page_num ) + @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) else - @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(@page_num ) + @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(@page_num ) end get_categorys @@ -71,13 +67,13 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController end def reload_bulletins - @selected_tag = AnnouncementTag.find(params[:tag_id]) - @bulletins = @selected_tag.get_visible_bulletins(:postdate).available_for_lang(I18n.locale).can_display.page(params[:page]).per(5) rescue nil + @selected_tag = Tag.find(params[:tag_id]) + @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort).page(params[:page]).per(5) rescue nil end def reload_web_links - @selected_tag = AnnouncementTag.find(params[:tag_id]) - @web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links(:created_at).available_for_lang(I18n.locale).page(params[:page]).per(5) rescue nil + @selected_tag = Tag.find(params[:tag_id]) + @web_links = WebLink.where(:name => @selected_tag.name).where(:is_hidden => false).desc(:is_top, sort).available_for_lang(I18n.locale).page(params[:page]).per(5) rescue nil end def bulletins_side_bar diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_list.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_list.html.erb index a07d1125..8e36ae8f 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_list.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_list.html.erb @@ -16,7 +16,7 @@
prev
next
diff --git a/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb b/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb index 1b4a9202..80cc6064 100644 --- a/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb +++ b/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb @@ -20,10 +20,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController # @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num) if !params[:category_id].blank? && !params[:tag_id].blank? - @tag = ArchiveTag.find(params[:tag_id]) rescue nil - @tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag - @archive_files = @tag.archive_files.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) - @archive_files = @archive_files.can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) + @archive_files = @archive_files.can_display.where(:archive_file_category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil @@ -31,9 +28,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController @archive_files = ArchiveFile.can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil elsif !params[:tag_id].blank? - @tag = ArchiveTag.find(params[:tag_id]) rescue nil - @tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag - @archive_files = @tag.archive_files.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) + @archive_files = ArchiveFile.can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) else @archive_files = ArchiveFile.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) end @@ -66,9 +61,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController @archive_files = ArchiveFile.can_display.where(:archive_file_category_id => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil elsif !params[:tag_id].blank? - @tag = ArchiveTag.find(params[:tag_id]) rescue nil - @tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag - @archive_files = @tag.archive_files.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) + @archive_files = ArchiveFile.can_display.where(:tagged_ids => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) else @archive_files = ArchiveFile.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) end diff --git a/vendor/built_in_modules/archive/app/controllers/panel/archive/widget/archive_files_controller.rb b/vendor/built_in_modules/archive/app/controllers/panel/archive/widget/archive_files_controller.rb index 3779e1e7..0379a371 100644 --- a/vendor/built_in_modules/archive/app/controllers/panel/archive/widget/archive_files_controller.rb +++ b/vendor/built_in_modules/archive/app/controllers/panel/archive/widget/archive_files_controller.rb @@ -31,8 +31,7 @@ class Panel::Archive::Widget::ArchiveFilesController < OrbitWidgetController @archive_files = ArchiveFile.all.can_display.any_in(:archive_file_category_id => params[:category_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) @archive_file_categorys = ArchiveFileCategory.any_in(:_id => params[:category_id]).excludes('disable' => true) elsif !params[:tag_id].blank? - @tag = ArchiveTag.find(params[:tag_id]) rescue nil - @tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag + @archive_files = ArchiveFile.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) get_categorys else @archive_files = ArchiveFile.all.can_display.merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) diff --git a/vendor/built_in_modules/faq/app/controllers/panel/faq/front_end/qas_controller.rb b/vendor/built_in_modules/faq/app/controllers/panel/faq/front_end/qas_controller.rb index 42140c80..6a89d5f2 100644 --- a/vendor/built_in_modules/faq/app/controllers/panel/faq/front_end/qas_controller.rb +++ b/vendor/built_in_modules/faq/app/controllers/panel/faq/front_end/qas_controller.rb @@ -26,8 +26,7 @@ class Panel::Faq::FrontEnd::QasController < OrbitWidgetController @qas = Qa.all.can_display.any_in(:qa_category_id => params[:category_id]).merge(QaCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) @qa_categorys = QaCategory.any_in(:_id => @item.category).excludes('disable' => true) rescue nil elsif params[:tag_id] !="[]" && !params[:tag_id].blank? - @tag = FaqTag.find(params[:tag_id]) rescue nil - @tag = FaqTag.where(key: params[:tag_id])[0] unless @tag + Qa.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(QaCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) @qas = @tag.archive_files.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) get_categorys else diff --git a/vendor/built_in_modules/faq/app/models/qa.rb b/vendor/built_in_modules/faq/app/models/qa.rb index f677a1b6..5a27d241 100644 --- a/vendor/built_in_modules/faq/app/models/qa.rb +++ b/vendor/built_in_modules/faq/app/models/qa.rb @@ -82,7 +82,7 @@ class Qa self.qa_links.each do |link| link.delete if link.url.blank? && link.title.blank? end - self.tag_ids.delete('') + self.tagged_ids.delete('') end end \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/album_images_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/album_images_controller.rb index 06eee5de..c8504bf4 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/album_images_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/album_images_controller.rb @@ -12,7 +12,7 @@ class Panel::Gallery::BackEnd::AlbumImagesController < OrbitBackendController else @authenticated = false end - @tags = GalleryTag.all + @tags = get_tags @image = GalleryImage.find(params[:id]) @albumid = @image.gallery_album_id @album = GalleryAlbum.find(@albumid) diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb index 56f6f189..177a290b 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb @@ -16,7 +16,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController end @categorylist = GalleryCategory.all @cid = params['cat'] - @tags = GalleryTag.all + @tags = get_tags end def show @@ -26,7 +26,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController @authenticated = false end @album = GalleryAlbum.find(params[:id]) - @tags = GalleryTag.all + @tags = get_tags end def new @@ -55,10 +55,10 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController if @tags if @tags.kind_of?(Array) @tags.each do |tag| - @albums << GalleryAlbum.where(tag_ids: tag) + @albums << GalleryAlbum.where(tagged_ids: tag) end else - @albums << GalleryAlbum.where(tag_ids: @tags) + @albums << GalleryAlbum.where(tagged_ids: @tags) end else @albums << GalleryAlbum.all @@ -69,10 +69,10 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController if @tags if @tags.kind_of?(Array) @tags.each do |tag| - @albums << category.gallery_albums.where(tag_ids: tag) + @albums << category.gallery_albums.where(tagged_ids: tag) end else - @albums << category.gallery_albums.where(tag_ids: @tags) + @albums << category.gallery_albums.where(tagged_ids: @tags) end else @albums << category.gallery_albums.all @@ -83,10 +83,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController @albums.each do |album| @albs = Array.new album.each do |values| - tags = Array.new - values.tag_ids.each do |tag| - tags << GalleryTag.find(tag)[I18n.locale] - end + tags = Tag.find(values.tagged_ids).map{|t| t.name} category = GalleryCategory.find(values.gallery_category_id).name @albs << {"_id"=>values.id,"show_path"=>panel_gallery_back_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags} end @@ -107,7 +104,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController @images = @album.gallery_images.all @album_name = @album.name_translations @cover = @album.cover - @tags = GalleryTag.all + @tags = get_tags end end @@ -123,11 +120,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController output = Array.new albums.each do |album| - tag_names = Array.new - - album.tag_ids.each do |tag| - tag_names << GalleryTag.find(tag)[I18n.locale] - end + tag_names = Tag.find(album.tagged_ids).map{|t| t.name} output << { album_cover_file: "http://#{request.host_with_port}#{album.cover_path}", @@ -146,11 +139,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController output = Array.new images.each do |image| - tags = Array.new - - image.tag_ids.each do |tag| - tags << GalleryTag.find(tag)[I18n.locale] - end + tags = Tag.find(image.tagged_ids).map{|t| t.name} output << { image_title: image.title, @@ -169,10 +158,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController @images = @album.gallery_images.all @output = Array.new @images.each do |values| - tags = Array.new - values.tag_ids.each do |tag| - tags << GalleryTag.find(tag)[I18n.locale] - end + tags = Tag.find(values.tagged_ids).map{|t| t.name} @output << { _id: values.id, theater_link: panel_gallery_back_end_album_image_path(values), description: values.description, @@ -190,8 +176,8 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController if @authenticated render :json=>{"images" => @output, "tags" => @album.tag_ids}.to_json else - @album.tag_ids.each do |tag| - @tag_names << GalleryTag.find(tag)[I18n.locale] + @album.tagged_ids.each do |tag| + @tag_names << Tag.find(tag).name end render :json=>{"images" => @output, "tags" => @album.tag_ids, "tag_names" => @tag_names}.to_json end @@ -235,7 +221,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController if params['delete_cover'] == "true" @album.update_attributes(:cover=>"default") end - @tags = GalleryTag.all + @tags = get_tags render :action => :show end end diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb index 07f85999..3924ab7e 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb @@ -4,10 +4,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController def show @album = GalleryAlbum.find(params[:id]) - @tags = Array.new - @album.tag_ids.each do |tag| - @tags << GalleryTag.find(tag)[I18n.locale] - end + @tags = Tag.find(@album.tagged_ids).map{|t| t.name} end def get_albums @@ -18,10 +15,10 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController if @tags if @tags.kind_of?(Array) @tags.each do |tag| - @albums << GalleryAlbum.where(tag_ids: tag) + @albums << GalleryAlbum.where(tagged_ids: tag) end else - @albums << GalleryAlbum.where(tag_ids: @tags) + @albums << GalleryAlbum.where(tagged_ids: @tags) end else @albums << GalleryAlbum.all @@ -32,10 +29,10 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController if @tags if @tags.kind_of?(Array) @tags.each do |tag| - @albums << category.gallery_albums.where(tag_ids: tag) + @albums << category.gallery_albums.where(tagged_ids: tag) end else - @albums << category.gallery_albums.where(tag_ids: @tags) + @albums << category.gallery_albums.where(tagged_ids: @tags) end else @albums << category.gallery_albums.all @@ -46,10 +43,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController @albums.each do |album| @albs = Array.new album.each do |values| - tags = Array.new - values.tag_ids.each do |tag| - tags << GalleryTag.find(tag)[I18n.locale] - end + tags = Tag.find(values.tagged_ids).map{|t| t.name} category = GalleryCategory.find(values.gallery_category_id).name @albs << {"_id"=>values.id,"show_path"=>panel_gallery_front_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags} end @@ -63,10 +57,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController @images = @album.gallery_images.all @output = Array.new @images.each do |values| - tags = Array.new - values.tag_ids.each do |tag| - tags << GalleryTag.find(tag)[I18n.locale] - end + tags = Tag.find(values.tagged_ids).map{|t| t.name} @output << {:_id => values.id, :theater_link => theater_panel_gallery_front_end_album_path(values), :description => values.description, @@ -95,10 +86,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController @album = GalleryAlbum.find(@albumid) @images = @album.gallery_images.all tags = @album.tag_ids - @tagnames = Array.new - tags.each do |tag| - @tagnames << GalleryTag.find(tag)[I18n.locale] - end + @tagnames = Tag.find(tags.tagged_ids).map{|t| t.name} @back_link = panel_gallery_front_end_album_path(@albumid) end end diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/orbit_galleries_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/orbit_galleries_controller.rb index 8ecc4ba4..af7bf784 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/orbit_galleries_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/orbit_galleries_controller.rb @@ -4,7 +4,7 @@ include AdminHelper @authenticated = false @categorylist = GalleryCategory.all @cid = params['cat'] - @tags = GalleryTag.all + @tags = get_tags end def new_category @@ -62,10 +62,10 @@ include AdminHelper if @tags if @tags.kind_of?(Array) @tags.each do |tag| - @albums << GalleryAlbum.where(tag_ids: tag) + @albums << GalleryAlbum.where(tagged_ids: tag) end else - @albums << GalleryAlbum.where(tag_ids: @tags) + @albums << GalleryAlbum.where(tagged_ids: @tags) end else @albums << GalleryAlbum.all @@ -76,10 +76,10 @@ include AdminHelper if @tags if @tags.kind_of?(Array) @tags.each do |tag| - @albums << category.gallery_albums.where(tag_ids: tag) + @albums << category.gallery_albums.where(tagged_ids: tag) end else - @albums << category.gallery_albums.where(tag_ids: @tags) + @albums << category.gallery_albums.where(tagged_ids: @tags) end else @albums << category.gallery_albums.all @@ -90,10 +90,7 @@ include AdminHelper @albums.each do |album| @albs = Array.new album.each do |values| - tags = Array.new - values.tag_ids.each do |tag| - tags << GalleryTag.find(tag)[I18n.locale] - end + tags = Tag.find(values.tagged_ids).map{|t| t.name} category = GalleryCategory.find(values.gallery_category_id).name @albs << {"_id"=>values.id,"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags} end diff --git a/vendor/built_in_modules/member/app/controllers/panel/member/widget/web_links_controller.rb b/vendor/built_in_modules/member/app/controllers/panel/member/widget/web_links_controller.rb index 3e648dc4..f4b0af43 100644 --- a/vendor/built_in_modules/member/app/controllers/panel/member/widget/web_links_controller.rb +++ b/vendor/built_in_modules/member/app/controllers/panel/member/widget/web_links_controller.rb @@ -34,8 +34,7 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController @web_links = WebLink.all.can_display.available_for_lang(I18n.locale).any_in(:web_link_category => params[:category_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :postdate ).page( params[:page_main] ).per(@page_num) @web_link_categorys = WebLinkCategory.any_in(:_id => params[:category_id]).excludes('disable' => true) elsif !params[:tag_id].blank? - @tag = WebResourceTag.find(params[:tag_id]) rescue nil - @tag = WebResourceTag.where(key: params[:tag_id])[0] unless @tag + @web_links = WebLink.all.can_display.available_for_lang(I18n.locale).any_in(:tagged_ids => params[:tag_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :postdate ).page( params[:page_main] ).per(@page_num) get_categorys else @web_links = WebLink.all.can_display.available_for_lang(I18n.locale).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :postdate ).page( params[:page_main] ).per(@page_num) @@ -58,7 +57,7 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController # get_categorys module_app = ModuleApp.first(:conditions => {:key => 'web_resource'}) - @tags = Tag.all(:conditions => {:module_app_id => module_app.id}) + @tags = module_app.tags end @@ -75,7 +74,7 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController def get_tags module_app = ModuleApp.first(:conditions => {:key => 'web_resource'}) - @tags = Tag.all(:conditions => {:module_app_id => module_app.id}) rescue [] + @tags = module_app.tags end end 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 36ac25b2..c23b7553 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 @@ -121,7 +121,7 @@ class WritingConference end def clean_checkboxs - self.tag_ids.delete('') + self.tagged_ids.delete('') self.conference_author_type_ids.delete('') self.conference_level_type_ids.delete('') end 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 6f2cc3b8..3cd944b7 100644 --- a/vendor/built_in_modules/personal_diploma/app/models/diploma.rb +++ b/vendor/built_in_modules/personal_diploma/app/models/diploma.rb @@ -73,7 +73,7 @@ class Diploma end def clean_checkboxs - self.tag_ids.delete('') + self.tagged_ids.delete('') end end \ No newline at end of file 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 61335b25..8523a0f3 100644 --- a/vendor/built_in_modules/personal_experience/app/models/experience.rb +++ b/vendor/built_in_modules/personal_experience/app/models/experience.rb @@ -87,7 +87,7 @@ class Experience end def clean_checkboxs - self.tag_ids.delete('') + self.tagged_ids.delete('') end end \ No newline at end of file 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 fe33fa6a..b8d5d26c 100644 --- a/vendor/built_in_modules/personal_honor/app/models/honor.rb +++ b/vendor/built_in_modules/personal_honor/app/models/honor.rb @@ -84,7 +84,7 @@ class Honor end def clean_checkboxs - self.tag_ids.delete('') + self.tagged_ids.delete('') end end \ No newline at end of file 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 ece4a126..c4739f6b 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 @@ -121,7 +121,7 @@ class WritingJournal end def clean_checkboxs - self.tag_ids.delete('') + self.tagged_ids.delete('') self.journal_author_type_ids.delete('') self.journal_level_type_ids.delete('') end 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 20b0a8c1..8b7bfa90 100644 --- a/vendor/built_in_modules/personal_lab/app/models/lab.rb +++ b/vendor/built_in_modules/personal_lab/app/models/lab.rb @@ -101,7 +101,7 @@ class Lab end def clean_checkboxs - self.tag_ids.delete('') + self.tagged_ids.delete('') end end \ No newline at end of file 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 2fad9f5b..04abc6eb 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 @@ -101,7 +101,7 @@ class WritingPatent end def clean_checkboxs - self.tag_ids.delete('') + self.tagged_ids.delete('') end end \ No newline at end of file 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 f40e815e..e14a37c0 100644 --- a/vendor/built_in_modules/personal_project/app/models/project.rb +++ b/vendor/built_in_modules/personal_project/app/models/project.rb @@ -103,7 +103,7 @@ class Project end def clean_checkboxs - self.tag_ids.delete('') + self.tagged_ids.delete('') end end \ No newline at end of file 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 c83ac738..4c7181d0 100644 --- a/vendor/built_in_modules/personal_research/app/models/research.rb +++ b/vendor/built_in_modules/personal_research/app/models/research.rb @@ -98,7 +98,7 @@ class Research end def clean_checkboxs - self.tag_ids.delete('') + self.tagged_ids.delete('') end end \ No newline at end of file diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb index f803e9c7..ce972346 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb @@ -28,9 +28,7 @@ class Panel::WebResource::FrontEnd::WebLinksController < OrbitWidgetController @web_links = WebLink.all.can_display.any_in(:web_link_category_id => params[:category_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) @web_link_categorys = WebLinkCategory.any_in(:_id => params[:category_id]).excludes('disable' => true) elsif !params[:tag_id].blank? - @tag = WebResourceTag.find(params[:tag_id]) rescue nil - @tag = WebResourceTag.where(key: params[:tag_id])[0] unless @tag - @web_links = @tag.web_links.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) + @web_links = WebLink.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) get_categorys else diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb index 0693d305..648c65d9 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb @@ -33,8 +33,7 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController @web_links = WebLink.all.can_display.any_in(:web_link_category_id => params[:category_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) @web_link_categorys = WebLinkCategory.any_in(:_id => params[:category_id]).excludes('disable' => true) elsif !params[:tag_id].blank? - @tag = WebResourceTag.find(params[:tag_id]) rescue nil - @tag = WebResourceTag.where(key: params[:tag_id])[0] unless @tag + @web_links = WebLink.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) get_categorys else @web_links = WebLink.all.can_display.merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) 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 50dfe09d..69180c1c 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 @@ -77,7 +77,7 @@ class WebLink end def clean_tags - self.tag_ids.delete('') + self.tagged_ids.delete('') end end \ No newline at end of file