1 class ComicsController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 if MagicNumber['run_mode'] == 0
4 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
5 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
7 before_filter :authenticate_reader, :only => [:top, :index, :show]
8 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
9 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
11 before_filter :authenticate_admin!, :only => [:list, :browse]
17 Pettanr::Application::manifest.controller_managers[self.model.item_name]
19 def self.profiler_manager
20 Pettanr::Application::manifest.profiler_managers[self.model.item_name]
24 action_name = params[:action]
25 @action = self.class.controller.open(action_name, params, @operators)
26 @items = @action.items
27 respond_to do |format|
29 @filer = @action.filer
30 render :template => 'system/filer', :locals => {
34 format.json { render json: @items.to_json(self.class.model.list_json_opt) }
41 @item = Comic.show(params[:id], @operators)
42 respond_to do |format|
47 @profiler = @@profiler_manager.open(@item, @operators)
48 render :template => 'system/prof', :locals => {
49 :profiler => @profiler
52 format.json { render json: @item.to_json(Comic.show_json_opt) }
59 @comic = {:count => Comic.visible_count}
60 respond_to do |format|
61 format.json { render json: @comic.to_json }
68 respond_to do |format|
69 format.html { render layout: 'system' }# index.html.erb
70 format.json { render json: @comics }
75 @comic = Comic.find(params[:id])
77 respond_to do |format|
78 format.html { render layout: 'system' } # show.html.erb
79 format.json { render json: @comic }
86 respond_to do |format|
87 format.html # new.html.erb
89 format.json { render json: @comic.to_json(Comic.show_json_opt) }
94 @comic = Comic.edit(params[:id], @author)
95 respond_to do |format|
103 @comic.supply_default
104 @comic.attributes = params[:comic]
105 @comic.overwrite @author
107 respond_to do |format|
109 flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human)
110 format.html { redirect_to @comic }
111 format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic }
113 flash[:notice] = I18n.t('flash.notice.not_created', :model => Comic.model_name.human)
114 format.html { render action: "new" }
115 format.json { render json: @comic.errors, status: :unprocessable_entity }
121 @comic = Comic.edit(params[:id], @author)
122 @comic.attributes = params[:comic]
123 @comic.overwrite @author
124 respond_to do |format|
126 flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
127 format.html { redirect_to @comic }
128 format.json { head :ok }
130 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Comic.model_name.human)
131 format.html { render action: "edit" }
132 format.json { render json: @comic.errors, status: :unprocessable_entity }
138 @comic = Comic.edit(params[:id], @author)
139 respond_to do |format|
140 if @comic.destroy_with_story
141 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
142 format.html { redirect_to '/home/comics' }
143 format.json { head :ok }
145 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
146 format.html { redirect_to @comic }
147 format.json { render json: @comic.errors, status: :unprocessable_entity }