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, :stories, :by_author]
8 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
9 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
17 @action = self.class.controller.open(action_name, params, @operators)
18 @action.cook params, operators
31 @item = Comic.show(params[:id], @operators)
32 respond_to do |format|
36 format.json { render json: @item.to_json(Comic.show_json_opt) }
43 @comic = {:count => Comic.visible_count}
44 respond_to do |format|
45 format.json { render json: @comic.to_json }
52 respond_to do |format|
55 format.json { render json: @comic.to_json(Comic.show_json_opt) }
60 @comic = Comic.edit(params[:id], @operators)
61 respond_to do |format|
70 @comic.attributes = params[:comic]
71 @comic.overwrite @operators
73 respond_to do |format|
75 flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human)
76 format.html { redirect_to @comic }
77 format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic }
79 flash[:notice] = I18n.t('flash.notice.not_created', :model => Comic.model_name.human)
80 format.html { render action: "new" }
81 format.json { render json: @comic.errors, status: :unprocessable_entity }
87 @comic = Comic.edit(params[:id], @operators)
88 @comic.attributes = params[:comic]
89 @comic.overwrite @operators
90 respond_to do |format|
92 flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
93 format.html { redirect_to @comic }
94 format.json { head :ok }
96 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Comic.model_name.human)
97 format.html { render action: "edit" }
98 format.json { render json: @comic.errors, status: :unprocessable_entity }
104 @comic = Comic.edit(params[:id], @operators)
105 respond_to do |format|
106 if @comic.destroy_with_story
107 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
108 format.html { redirect_to '/home/comics' }
109 format.json { head :ok }
111 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
112 format.html { redirect_to @comic }
113 format.json { render json: @comic.errors, status: :unprocessable_entity }