1 class GroundPicturesController < ApplicationController
2 if Manifest.manifest.magic_numbers['run_mode'] == 0
3 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
4 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
6 before_filter :authenticate_reader, :only => [
7 :index, :show, :by_panel, :by_author, :count, :count_by_panel, :count_by_author
9 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
10 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
29 def show_html_format format
31 @ground_picture = @item
37 respond_to do |format|
38 show_html_format format
39 show_prof_format format
40 show_json_format format
57 raise Pettanr::NotWork unless @operators.author.working_panel
58 @picture = Picture.show params[:picture_id], @operators
59 raise ActiveRecord::Forbidden unless @picture.enable?
60 @panel = Panel.edit(@operators.author.working_panel, @operators)
62 @ground_picture = GroundPicture.new :panel_id => @panel.id, :picture_id => @picture.id
63 @ground_picture.supply_default
65 respond_to do |format|
67 format.json { render :json => @ground_picture.to_json(GroundPicture.show_json_opt) }
72 @ground_picture = GroundPicture.show(params[:id], @operators)
73 @panel = Panel.edit(@ground_picture.panel.id, @operators)
75 respond_to do |format|
81 raise Pettanr::NotWork unless @operators.author.working_panel
82 @panel = Panel.edit(@operators.author.working_panel, @operators)
84 @ground_picture = GroundPicture.new
85 @ground_picture.attributes = params[:ground_picture]
86 @ground_picture.overwrite @panel.id
88 @picture = Picture.show @ground_picture.picture_id, @operators
89 raise ActiveRecord::Forbidden unless @picture.enable?
91 respond_to do |format|
92 if @ground_picture.valid?
93 if @ground_picture.store @operators
94 flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
95 format.html { redirect_to @panel }
96 format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
98 flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundPicture.model_name.human)
99 format.html { render action: "new" }
100 format.json { render json: @panel.errors, status: :unprocessable_entity }
103 flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundPicture.model_name.human)
104 format.html { render action: "new" }
105 format.json { render json: @ground_picture.errors, status: :unprocessable_entity }
111 @ground_picture = GroundPicture.show(params[:id], @operators)
112 @ground_picture.attributes = params[:ground_picture]
113 @panel = Panel.edit(@ground_picture.panel.id, @operators)
114 @ground_picture.overwrite @panel.id
116 @picture = Picture.show @ground_picture.picture_id, @operators
117 raise ActiveRecord::Forbidden unless @picture.enable?
119 respond_to do |format|
120 if @ground_picture.store @operators
121 flash[:notice] = I18n.t('flash.notice.updated', :model => GroundPicture.model_name.human)
122 format.html { redirect_to @ground_picture }
123 format.json { head :ok }
125 flash[:notice] = I18n.t('flash.notice.not_updated', :model => GroundPicture.model_name.human)
126 format.html { render action: "edit" }
127 format.json { render json: @ground_picture.errors, status: :unprocessable_entity }
133 @ground_picture = GroundPicture.show(params[:id], @operators)
134 @panel = Panel.edit(@ground_picture.panel.id, @operators)
136 respond_to do |format|
137 if @ground_picture.remove @operators
138 flash[:notice] = I18n.t('flash.notice.destroyed', :model => GroundPicture.model_name.human)
139 format.html { redirect_to @panel }
140 format.json { head :ok }
142 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => GroundPicture.model_name.human)
143 format.html { redirect_to @ground_picture }
144 format.json { render json: @ground_picture.errors, status: :unprocessable_entity }