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 @@list_manager = Pettanr::Application::manifest.list_managers[@@model.item_name]
16 @@filer_manager = Pettanr::Application::manifest.filer_managers[@@model.item_name]
17 @@profiler_manager = Pettanr::Application::manifest.profiler_managers[@@model.item_name]
20 @c = @@controller.open(params[:action])
21 @list = @@list_manager.open(@page, @page_size, @operators)
23 respond_to do |format|
25 @filer = @@filer_manager.open(@items, @operators, @list.paginate)
26 render :template => 'system/filer', :locals => {
30 format.json { render json: @items.to_json(@@model.list_json_opt) }
37 @item = Comic.show(params[:id], @operators)
38 respond_to do |format|
43 @profiler = @@profiler_manager.open(@item, @operators)
44 render :template => 'system/prof', :locals => {
45 :profiler => @profiler
48 format.json { render json: @item.to_json(Comic.show_json_opt) }
55 @comic = {:count => Comic.visible_count}
56 respond_to do |format|
57 format.json { render json: @comic.to_json }
64 respond_to do |format|
65 format.html { render layout: 'system' }# index.html.erb
66 format.json { render json: @comics }
71 @comic = Comic.find(params[:id])
73 respond_to do |format|
74 format.html { render layout: 'system' } # show.html.erb
75 format.json { render json: @comic }
82 respond_to do |format|
83 format.html # new.html.erb
85 format.json { render json: @comic.to_json(Comic.show_json_opt) }
90 @comic = Comic.edit(params[:id], @author)
91 respond_to do |format|
100 @comic.attributes = params[:comic]
101 @comic.overwrite @author
103 respond_to do |format|
105 flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human)
106 format.html { redirect_to @comic }
107 format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic }
109 flash[:notice] = I18n.t('flash.notice.not_created', :model => Comic.model_name.human)
110 format.html { render action: "new" }
111 format.json { render json: @comic.errors, status: :unprocessable_entity }
117 @comic = Comic.edit(params[:id], @author)
118 @comic.attributes = params[:comic]
119 @comic.overwrite @author
120 respond_to do |format|
122 flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
123 format.html { redirect_to @comic }
124 format.json { head :ok }
126 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Comic.model_name.human)
127 format.html { render action: "edit" }
128 format.json { render json: @comic.errors, status: :unprocessable_entity }
134 @comic = Comic.edit(params[:id], @author)
135 respond_to do |format|
136 if @comic.destroy_with_story
137 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
138 format.html { redirect_to '/home/comics' }
139 format.json { head :ok }
141 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
142 format.html { redirect_to @comic }
143 format.json { render json: @comic.errors, status: :unprocessable_entity }