-
- def create
- raise Pettanr::NotWork unless @author.working_panel
- @panel = Panel.edit(@author.working_panel, @author)
-
- @panel_picture = PanelPicture.new
- @panel_picture.attributes = params[:panel_picture]
- @panel_picture.overwrite @panel.id
-
- @picture = Picture.show @panel_picture.picture_id, @author
- raise ActiveRecord::Forbidden unless @picture.enable?
-
- respond_to do |format|
- if @panel_picture.valid?
- if @panel_picture.store @author
- flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
- format.html { redirect_to @panel }
- format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
- else
- flash[:notice] = I18n.t('flash.notice.not_created', :model => PanelPicture.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 => PanelPicture.model_name.human)
- format.html { render action: "new" }
- format.json { render json: @panel_picture.errors, status: :unprocessable_entity }
- end
- end