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]
29 @item = Comic.show(params[:id], @operators)
30 respond_to do |format|
34 format.json { render json: @item.to_json(Comic.show_json_opt) }
41 @comic = {:count => Comic.visible_count}
42 respond_to do |format|
43 format.json { render json: @comic.to_json }
50 respond_to do |format|
53 format.json { render json: @comic.to_json(Comic.show_json_opt) }
58 @comic = Comic.edit(params[:id], @operators)
59 respond_to do |format|
68 @comic.attributes = params[:comic]
69 @comic.overwrite @operators
71 respond_to do |format|
73 flash[:notice] = I18n.t('flash.notice.created', :model => Comic.model_name.human)
74 format.html { redirect_to @comic }
75 format.json { render json: @comic.to_json(Comic.show_json_opt), status: :created, location: @comic }
77 flash[:notice] = I18n.t('flash.notice.not_created', :model => Comic.model_name.human)
78 format.html { render action: "new" }
79 format.json { render json: @comic.errors, status: :unprocessable_entity }
85 @comic = Comic.edit(params[:id], @operators)
86 @comic.attributes = params[:comic]
87 @comic.overwrite @operators
88 respond_to do |format|
90 flash[:notice] = I18n.t('flash.notice.updated', :model => Comic.model_name.human)
91 format.html { redirect_to @comic }
92 format.json { head :ok }
94 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Comic.model_name.human)
95 format.html { render action: "edit" }
96 format.json { render json: @comic.errors, status: :unprocessable_entity }
102 @comic = Comic.edit(params[:id], @operators)
103 respond_to do |format|
104 if @comic.destroy_with_story
105 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
106 format.html { redirect_to '/home/comics' }
107 format.json { head :ok }
109 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
110 format.html { redirect_to @comic }
111 format.json { render json: @comic.errors, status: :unprocessable_entity }