From 977d3a619179997e238c8a8e182d8fb5e21e2fdb Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 1 Dec 2014 18:05:55 +0800 Subject: [PATCH] added categories for authorizations --- app/controllers/admin/ad_banners_controller.rb | 1 + app/models/banner.rb | 1 + app/views/admin/ad_banners/_form.html.erb | 3 +++ lib/ad_banner/engine.rb | 8 ++++++++ 4 files changed, 13 insertions(+) diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index 8652ff6..7504d27 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -3,6 +3,7 @@ class Admin::AdBannersController < OrbitAdminController def index @banners = Banner.all + @categories = @module_app.categories.collect{|c|[c.title, c.id]} end def show diff --git a/app/models/banner.rb b/app/models/banner.rb index af0cd63..1eb75ff 100644 --- a/app/models/banner.rb +++ b/app/models/banner.rb @@ -2,6 +2,7 @@ class Banner include Mongoid::Document include Mongoid::Timestamps include OrbitTag::Taggable + include OrbitCategory::Categorizable field :ad_fx, type: String field :height, type: Integer diff --git a/app/views/admin/ad_banners/_form.html.erb b/app/views/admin/ad_banners/_form.html.erb index faf0a6a..fe56c0e 100644 --- a/app/views/admin/ad_banners/_form.html.erb +++ b/app/views/admin/ad_banners/_form.html.erb @@ -19,6 +19,9 @@ <%= f.number_field :height, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'height' %> +<%= f.label :category_id, t('ad_banner.categories') %> +<%= f.select :category_id, @categories, {} %> + <%= f.label :ad_fx, t('ad_banner.effect') %> <%= f.select :ad_fx, Banner::FX_TYPES, {}, {class: 'ad_banner_ad_fx', id: 'ad_fx'} %>

<%= t('ad_banner.no_ie_10_effect_support') %>

diff --git a/lib/ad_banner/engine.rb b/lib/ad_banner/engine.rb index 6f9b098..cfc045f 100644 --- a/lib/ad_banner/engine.rb +++ b/lib/ad_banner/engine.rb @@ -21,6 +21,14 @@ module AdBanner :priority=>1, :active_for_action=>{'admin/ad_banners'=>"index"}, :available_for => 'users' + + context_link 'categories', + :link_path=>"admin_module_app_categories_path" , + :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'ad_banner').id}", + :priority=>3, + :active_for_action=>{'admin/ad_banners'=>'categories'}, + :active_for_category => 'AdBanner', + :available_for => 'managers' end end end