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]
13 @page = GroundPicture.page params[:page]
14 @page_size = GroundPicture.page_size params[:page_size]
15 @ground_pictures = GroundPicture.list(@page, @page_size)
17 respond_to do |format|
19 @paginate = GroundPicture.list_paginate(@page, @page_size)
21 format.json { render :json => @ground_pictures.to_json(GroundPicture.list_json_opt) }
26 @ground_picture = GroundPicture.show(params[:id], [@user, @admin])
27 respond_to do |format|
28 format.html # show.html.erb
29 format.json { render json: @ground_picture.to_json(GroundPicture.show_json_opt) }
34 @picture = Picture.show params[:picture_id], @author
35 raise ActiveRecord::Forbidden unless @picture.enable?
36 @panel = Panel.edit(@author.working_panel, @author)
38 @ground_picture = GroundPicture.new :panel_id => @panel.id, :picture_id => @picture.id
39 @ground_picture.supply_default
41 respond_to do |format|
43 format.json { render :json => @ground_picture.to_json(GroundPicture.show_json_opt) }
48 @ground_picture = GroundPicture.show(params[:id], @author)
49 @panel = Panel.edit(@ground_picture.panel.id, @author)
51 respond_to do |format|
57 @panel = Panel.edit(@author.working_panel, @author)
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, @author
64 raise ActiveRecord::Forbidden unless @picture.enable?
66 respond_to do |format|
67 if @ground_picture.valid?
68 if @ground_picture.store @author
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], @author)
87 @ground_picture.attributes = params[:ground_picture]
88 @panel = Panel.edit(@ground_picture.panel.id, @author)
89 @ground_picture.overwrite @panel.id
91 @picture = Picture.show @ground_picture.picture_id, @author
92 raise ActiveRecord::Forbidden unless @picture.enable?
94 respond_to do |format|
95 if @ground_picture.store @author
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], @author)
109 @panel = Panel.edit(@ground_picture.panel.id, @author)
111 respond_to do |format|
112 if @ground_picture.remove @author
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 }