before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
end
+ @@model = GroundPicture
def index
- @page = GroundPicture.page params[:page]
- @page_size = GroundPicture.page_size params[:page_size]
- @ground_pictures = GroundPicture.list(@page, @page_size)
+ set_filer
respond_to do |format|
- format.html {
- @paginate = GroundPicture.list_paginate(@page, @page_size)
- }
- format.json { render :json => @ground_pictures.to_json(GroundPicture.list_json_opt) }
+ format_filer format
+ format.json { render json: @items.to_json(@@model.list_json_opt) }
end
end
def show
- @ground_picture = GroundPicture.show(params[:id], [@user, @admin])
+ @item = GroundPicture.show(params[:id], @operators)
respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @ground_picture.to_json(GroundPicture.show_json_opt) }
+ format.html {
+ @ground_picture = @item
+ }
+ format_prof format
+ format.json { render json: @item.to_json(GroundPicture.show_json_opt) }
end
end
def new
- @ground_picture = GroundPicture.new params[:ground_picture]
+ raise Pettanr::NotWork unless @author.working_panel
+ @picture = Picture.show params[:picture_id], @author
+ raise ActiveRecord::Forbidden unless @picture.enable?
+ @panel = Panel.edit(@author.working_panel, @author)
+
+ @ground_picture = GroundPicture.new :panel_id => @panel.id, :picture_id => @picture.id
@ground_picture.supply_default
- @panel = @ground_picture.panel
respond_to do |format|
format.html
end
def create
- @ground_picture = GroundPicture.new params[:ground_picture]
- @ground_picture.supply_default
- @ground_picture.overwrite
- @panel = Panel.edit(@ground_picture.panel.id, @author)
+ raise Pettanr::NotWork unless @author.working_panel
+ @panel = Panel.edit(@author.working_panel, @author)
+
+ @ground_picture = GroundPicture.new
+ @ground_picture.attributes = params[:ground_picture]
+ @ground_picture.overwrite @panel.id
+
+ @picture = Picture.show @ground_picture.picture_id, @author
+ raise ActiveRecord::Forbidden unless @picture.enable?
respond_to do |format|
if @ground_picture.valid?
format.html { redirect_to @panel }
format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
else
- format.html { render action: "panels/new" }
+ flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundPicture.model_name.human)
+ format.html { render action: "new" }
format.json { render json: @panel.errors, status: :unprocessable_entity }
end
else
+ flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundPicture.model_name.human)
format.html { render action: "new" }
format.json { render json: @ground_picture.errors, status: :unprocessable_entity }
end
def update
@ground_picture = GroundPicture.show(params[:id], @author)
@ground_picture.attributes = params[:ground_picture]
- @ground_picture.overwrite
@panel = Panel.edit(@ground_picture.panel.id, @author)
+ @ground_picture.overwrite @panel.id
+
+ @picture = Picture.show @ground_picture.picture_id, @author
+ raise ActiveRecord::Forbidden unless @picture.enable?
respond_to do |format|
if @ground_picture.store @author
format.html { redirect_to @ground_picture }
format.json { head :ok }
else
+ flash[:notice] = I18n.t('flash.notice.not_updated', :model => GroundPicture.model_name.human)
format.html { render action: "edit" }
format.json { render json: @ground_picture.errors, status: :unprocessable_entity }
end