From 7f4d4ae93f86a1ebeb53e5da5f5b7d3e72933eaf Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Wed, 4 Dec 2013 17:11:09 +0800 Subject: [PATCH] Announcement Categories in Mobile settings --- app/controllers/admin/sites_controller.rb | 11 +++--- app/controllers/mobile_controller.rb | 8 +++- .../admin/sites/responsive_setting.html.erb | 38 ++++++++++++++++++- app/views/mobile/_menu.mobile.erb | 2 - app/views/mobile/index.mobile.erb | 2 - 5 files changed, 49 insertions(+), 12 deletions(-) diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index ecc5535c..0c2be0b6 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -71,12 +71,11 @@ class Admin::SitesController < OrbitBackendController end def responsive_setting - @bulletins = Bulletin.all - @bulletin_categories = [] - @bulletins.each do |bulletin| - @bulletin_categories << bulletin.get_bulletin_category - end - @categories = @bulletin_categories + @module = ModuleApp.where(:key => "announcement").first + # @categories=[] + # @module.categories.each do |c| + # @categories << c + # end end diff --git a/app/controllers/mobile_controller.rb b/app/controllers/mobile_controller.rb index 546000ac..9d3cfeae 100644 --- a/app/controllers/mobile_controller.rb +++ b/app/controllers/mobile_controller.rb @@ -12,9 +12,15 @@ class MobileController < ApplicationController end def announcement + @module = ModuleApp.where(:key => "announcement").first + category=[] + @module.categories.each do |c| + puts category << c.id.to_s + end @page_title = t('mobile.bulletin') date_now = Time.now - @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(15) + bulletin = Bulletin.where(:category_id.in => category).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(15) + # @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(15) end def announcement_content diff --git a/app/views/admin/sites/responsive_setting.html.erb b/app/views/admin/sites/responsive_setting.html.erb index ebec8299..5d9ba8cf 100644 --- a/app/views/admin/sites/responsive_setting.html.erb +++ b/app/views/admin/sites/responsive_setting.html.erb @@ -26,6 +26,16 @@ +
+ +
+ <% @module.categories.each do |category| %> + <%= check_box_tag "site[announcement_category][]", category.id.to_s, @site.announcement_category.include?(category), :class=>"toggle-check", :data => { :title => "#{category.title}", disabled: true }, "data-deploy"=>"inline", :checked => (@site.announcement_category.include?(category.id.to_s)) %> + <% end %> +
+
+ +
@@ -42,4 +52,30 @@
- <%end%> \ No newline at end of file + <%end%> + +<% content_for :page_specific_javascript do %> + +<% end %> \ No newline at end of file diff --git a/app/views/mobile/_menu.mobile.erb b/app/views/mobile/_menu.mobile.erb index 57fbf0c6..ec92ea84 100644 --- a/app/views/mobile/_menu.mobile.erb +++ b/app/views/mobile/_menu.mobile.erb @@ -1,9 +1,7 @@ \ No newline at end of file diff --git a/app/views/mobile/index.mobile.erb b/app/views/mobile/index.mobile.erb index e841b0cf..57c30430 100644 --- a/app/views/mobile/index.mobile.erb +++ b/app/views/mobile/index.mobile.erb @@ -3,7 +3,6 @@ <%= image_tag image.file.url, width: @ad_banner.width, height: @ad_banner.height %> <% end %>
-<% if @site.enable_announcement_mobile %>
<% @bulletins.each do |bulletin| %>
@@ -18,7 +17,6 @@
<% end %>
-<% end %>