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::Application::manifest.controller_managers[@@model.item_name]
15 @@profiler_manager = Pettanr::Application::manifest.profiler_managers[@@model.item_name]
18 @action = @@controller.open(params, @operators)
19 @items = @action.items
20 respond_to do |format|
22 @filer = @action.filer
23 render :template => 'system/filer', :locals => {
27 format.json { render json: @items.to_json(@@model.list_json_opt) }
34 @item = Comic.show(params[:id], @operators)
35 respond_to do |format|
40 @profiler = @@profiler_manager.open(@item, @operators)
41 render :template => 'system/prof', :locals => {
42 :profiler => @profiler
45 format.json { render json: @item.to_json(Comic.show_json_opt) }
52 @comic = {:count => Comic.visible_count}
53 respond_to do |format|
54 format.json { render json: @comic.to_json }
61 respond_to do |format|
62 format.html { render layout: 'system' }# index.html.erb
63 format.json { render json: @comics }
68 @comic = Comic.find(params[:id])
70 respond_to do |format|
71 format.html { render layout: 'system' } # show.html.erb
72 format.json { render json: @comic }
79 respond_to do |format|
80 format.html # new.html.erb
82 format.json { render json: @comic.to_json(Comic.show_json_opt) }
87 @comic = Comic.edit(params[:id], @author)
88 respond_to do |format|
97 @comic.attributes = params[:comic]
98 @comic.overwrite @author
100 respond_to do |format|
102 flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human)
103 format.html { redirect_to @comic }
104 format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic }
106 flash[:notice] = I18n.t('flash.notice.not_created', :model => Comic.model_name.human)
107 format.html { render action: "new" }
108 format.json { render json: @comic.errors, status: :unprocessable_entity }
114 @comic = Comic.edit(params[:id], @author)
115 @comic.attributes = params[:comic]
116 @comic.overwrite @author
117 respond_to do |format|
119 flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
120 format.html { redirect_to @comic }
121 format.json { head :ok }
123 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Comic.model_name.human)
124 format.html { render action: "edit" }
125 format.json { render json: @comic.errors, status: :unprocessable_entity }
131 @comic = Comic.edit(params[:id], @author)
132 respond_to do |format|
133 if @comic.destroy_with_story
134 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
135 format.html { redirect_to '/home/comics' }
136 format.json { head :ok }
138 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
139 format.html { redirect_to @comic }
140 format.json { render json: @comic.errors, status: :unprocessable_entity }