added authorizable to announcement, announcements controller with setup variables

This commit is contained in:
Saurabh Bhatia 2014-05-02 12:09:44 +08:00
parent 02cbd322d8
commit 804caaa091
3 changed files with 17 additions and 10 deletions

View File

@ -1,6 +1,13 @@
# encoding: utf-8
class Admin::AnnouncementsController < OrbitAdminController
before_filter :setup_vars
before_action ->(module_app = @app_title) { set_variables module_app }
before_action :set_bulletin, only: [:edit, :destroy]
def initialize
super
@app_title = "announcement"
end
def index
@tags = @module_app.tags
@ -40,6 +47,7 @@ class Admin::AnnouncementsController < OrbitAdminController
@sort
end
def new
@tags =@module_app.tags
@categories = @module_app.categories
@ -59,7 +67,6 @@ class Admin::AnnouncementsController < OrbitAdminController
@tags =@module_app.tags
@categories = @module_app.categories
@statuses = []
@bulletin = Bulletin.find(params[:id])
end
def update
@ -72,8 +79,7 @@ class Admin::AnnouncementsController < OrbitAdminController
end
def destroy
bulletin = Bulletin.find(params[:id])
bulletin.destroy
@bulletin.destroy
redirect_to "/admin/announcements"
end
@ -86,12 +92,11 @@ class Admin::AnnouncementsController < OrbitAdminController
private
def set_bulletin
@bulletin = Bulletin.find(params[:id])
end
def bulletin_params
params.require(:bulletin).permit!
end
def setup_vars
@module_app = ModuleApp.where(:key=>"announcement").first
end
end

View File

@ -7,9 +7,11 @@ module Announcement
widget_methods ["widget"]
taggable "Bulletin"
categorizable
authorizable
side_bar do
head_label_i18n 'announcement.announcement', icon_class: "icons-megaphone"
available_for [:admin,:manager,:sub_manager]
active_for_controllers ({:private=>['announcements']})
head_link_path "admin_announcements_path"