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

View File

@ -92,4 +92,4 @@
end end
%> %>
<%= render 'layouts/delete_modal', delete_options: @delete_options %> <%= render 'layouts/delete_modal', delete_options: @delete_options %>

View File

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