diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index ce218be..ddc3745 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -171,37 +171,35 @@ class AnnouncementsController < ApplicationController end cats = cats.uniq tags = tags.uniq - tags_translations = tags.map{|tag_id| - if tag_id == "all" - t = I18n.t(:all) - else - t = Tag.find(tag_id).name rescue "" - end - [tag_id,t] - }.to_h - cats_translations = cats.map{|cat_id| - if cat_id == "all" - t = I18n.t(:all) - else - t = Category.find(cat_id).title rescue "" - end - [cat_id,t] - }.to_h + tags_translations = Tag.where(:id.in=>tags).map{|t| [t.id.to_s,t.name]} + if tags.include?("all") + tags_translations = ["all",I18n.t(:all)] + tags_translations + end + tags_translations = tags_translations.to_h + cats_translations = Category.where(:id.in=>cats).map{|c| [c.id.to_s,c.title]} + if cats.include?("all") + cats_translations = ["all",I18n.t(:all)] + cats_translations + end + cats_translations = cats_translations.to_h cats_relations = cats_translations.map{|cat_id,t| if cat_id == "all" t = "all" end [cat_id,t] }.to_h - home_page = Page.first - page = nil + home_page = subpart.page_part.page rescue Page.first + page_url = (subpart.get_read_more_page_url rescue nil) locale = I18n.locale.to_s - if home_page.respond_to?(:find_page) - page = home_page.find_page(:page_id=> subpart.read_more_page_id,:enabled_for=>locale).first rescue nil - page = home_page.find_page(:module=>"announcement",:enabled_for=>locale).first rescue nil if page.nil? - else - page = Page.where(:page_id=> subpart.read_more_page_id,:enabled_for=>locale).first rescue nil - page = Page.where(:module=>"announcement",:enabled_for=>locale).first rescue nil if page.nil? + if page_url.nil? + page = nil + if home_page.respond_to?(:find_page) + page = home_page.find_page(:page_id=> subpart.read_more_page_id,:enabled_for=>locale).first rescue nil + page = home_page.find_page(:module=>"announcement",:enabled_for=>locale).first rescue nil if page.nil? + else + page = Page.where(:page_id=> subpart.read_more_page_id,:enabled_for=>locale).first rescue nil + page = Page.where(:module=>"announcement",:enabled_for=>locale).first rescue nil if page.nil? + end + page_url = page.get_url end all_cats = cats.dup all_cats.delete "all" @@ -219,7 +217,7 @@ class AnnouncementsController < ApplicationController "
" + "