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]
14 @@controller = Pettanr::ControllerManager.new @@model.item_name, Pettanr.manifest
15 @@filer_manager = Pettanr::FilerManager.new @@model.item_name, Pettanr.manifest
16 @@profiler_manager = Pettanr::ProfilerManager.new @@model.item_name, Pettanr.manifest
17 @@list_manager = Pettanr::ListManager.new @@model.item_name, Pettanr.manifest
21 @c = @@controller.open(params[:action])
22 @list = @c.list.open(@page, @page_size, @operators)
24 respond_to do |format|
26 @filer = @@filer_manager.open(@items, @operators, @list.paginate)
27 render :template => 'system/filer', :locals => {
31 format.json { render json: @items.to_json(@@model.list_json_opt) }
38 @item = Comic.show(params[:id], @operators)
39 respond_to do |format|
44 @profiler = @@profiler_manager.open(@item, @operators)
45 render :template => 'system/prof', :locals => {
46 :profiler => @profiler
49 format.json { render json: @item.to_json(Comic.show_json_opt) }
56 @comic = {:count => Comic.visible_count}
57 respond_to do |format|
58 format.json { render json: @comic.to_json }
65 respond_to do |format|
66 format.html { render layout: 'system' }# index.html.erb
67 format.json { render json: @comics }
72 @comic = Comic.find(params[:id])
74 respond_to do |format|
75 format.html { render layout: 'system' } # show.html.erb
76 format.json { render json: @comic }
83 respond_to do |format|
84 format.html # new.html.erb
86 format.json { render json: @comic.to_json(Comic.show_json_opt) }
91 @comic = Comic.edit(params[:id], @author)
92 respond_to do |format|
100 @comic.supply_default
101 @comic.attributes = params[:comic]
102 @comic.overwrite @author
104 respond_to do |format|
106 flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human)
107 format.html { redirect_to @comic }
108 format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic }
110 flash[:notice] = I18n.t('flash.notice.not_created', :model => Comic.model_name.human)
111 format.html { render action: "new" }
112 format.json { render json: @comic.errors, status: :unprocessable_entity }
118 @comic = Comic.edit(params[:id], @author)
119 @comic.attributes = params[:comic]
120 @comic.overwrite @author
121 respond_to do |format|
123 flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
124 format.html { redirect_to @comic }
125 format.json { head :ok }
127 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Comic.model_name.human)
128 format.html { render action: "edit" }
129 format.json { render json: @comic.errors, status: :unprocessable_entity }
135 @comic = Comic.edit(params[:id], @author)
136 respond_to do |format|
137 if @comic.destroy_with_story
138 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
139 format.html { redirect_to '/home/comics' }
140 format.json { head :ok }
142 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
143 format.html { redirect_to @comic }
144 format.json { render json: @comic.errors, status: :unprocessable_entity }