1 class GroundPicturesController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 if MagicNumber['run_mode'] == 0
4 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
5 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
7 before_filter :authenticate_reader, :only => [:index, :show]
8 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
9 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
21 @item = GroundPicture.show(params[:id], @operators)
22 respond_to do |format|
24 @ground_picture = @item
27 format.json { render json: @item.to_json(GroundPicture.show_json_opt) }
32 raise Pettanr::NotWork unless @operators.author.working_panel
33 @picture = Picture.show params[:picture_id], @operators
34 raise ActiveRecord::Forbidden unless @picture.enable?
35 @panel = Panel.edit(@operators.author.working_panel, @operators)
37 @ground_picture = GroundPicture.new :panel_id => @panel.id, :picture_id => @picture.id
38 @ground_picture.supply_default
40 respond_to do |format|
42 format.json { render :json => @ground_picture.to_json(GroundPicture.show_json_opt) }
47 @ground_picture = GroundPicture.show(params[:id], @operators)
48 @panel = Panel.edit(@ground_picture.panel.id, @operators)
50 respond_to do |format|
56 raise Pettanr::NotWork unless @operators.author.working_panel
57 @panel = Panel.edit(@operators.author.working_panel, @operators)
59 @ground_picture = GroundPicture.new
60 @ground_picture.attributes = params[:ground_picture]
61 @ground_picture.overwrite @panel.id
63 @picture = Picture.show @ground_picture.picture_id, @operators
64 raise ActiveRecord::Forbidden unless @picture.enable?
66 respond_to do |format|
67 if @ground_picture.valid?
68 if @ground_picture.store @operators
69 flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
70 format.html { redirect_to @panel }
71 format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
73 flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundPicture.model_name.human)
74 format.html { render action: "new" }
75 format.json { render json: @panel.errors, status: :unprocessable_entity }
78 flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundPicture.model_name.human)
79 format.html { render action: "new" }
80 format.json { render json: @ground_picture.errors, status: :unprocessable_entity }
86 @ground_picture = GroundPicture.show(params[:id], @operators)
87 @ground_picture.attributes = params[:ground_picture]
88 @panel = Panel.edit(@ground_picture.panel.id, @operators)
89 @ground_picture.overwrite @panel.id
91 @picture = Picture.show @ground_picture.picture_id, @operators
92 raise ActiveRecord::Forbidden unless @picture.enable?
94 respond_to do |format|
95 if @ground_picture.store @operators
96 flash[:notice] = I18n.t('flash.notice.updated', :model => GroundPicture.model_name.human)
97 format.html { redirect_to @ground_picture }
98 format.json { head :ok }
100 flash[:notice] = I18n.t('flash.notice.not_updated', :model => GroundPicture.model_name.human)
101 format.html { render action: "edit" }
102 format.json { render json: @ground_picture.errors, status: :unprocessable_entity }
108 @ground_picture = GroundPicture.show(params[:id], @operators)
109 @panel = Panel.edit(@ground_picture.panel.id, @operators)
111 respond_to do |format|
112 if @ground_picture.remove @operators
113 flash[:notice] = I18n.t('flash.notice.destroyed', :model => GroundPicture.model_name.human)
114 format.html { redirect_to @panel }
115 format.json { head :ok }
117 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => GroundPicture.model_name.human)
118 format.html { redirect_to @ground_picture }
119 format.json { render json: @ground_picture.errors, status: :unprocessable_entity }