X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Foriginal_picture_license_groups_controller.rb;h=3f74b0e306cca462419b3b0a1460f61c16fe5081;hb=6a9125ccbacea489311fc4cc548ac03e7d0b412d;hp=eebd199448ac2f6de9a0e6cb09e961c909174af1;hpb=84a5b0cfc30cd42930ee80551ba389b223643dc3;p=pettanr%2Fpettanr.git diff --git a/app/controllers/original_picture_license_groups_controller.rb b/app/controllers/original_picture_license_groups_controller.rb index eebd1994..3f74b0e3 100644 --- a/app/controllers/original_picture_license_groups_controller.rb +++ b/app/controllers/original_picture_license_groups_controller.rb @@ -1,33 +1,50 @@ class OriginalPictureLicenseGroupsController < ApplicationController - before_filter :authenticate_user, :only => [:new, :create] - before_filter :authenticate_artist, :only => [:new, :create] + before_action :authenticate_user, :only => [:new, :create] + before_action :authenticate_artist, :only => [:new, :create] def new @original_picture = OriginalPicture.show params[:original_picture_id], @operators - @original_picture_license_group = OriginalPictureLicenseGroup.new() - @original_picture_license_group.supply_default @original_picture.id - + @item = OriginalPictureLicenseGroup.new() + @item.supply_default @original_picture.id + respond_to do |format| - format.html - format.js + format.html { + @form = Locmare::Bucket.factory @item.item_name, 'default', @item, true, true, @operators + } + format.json { render json: @item.to_json } end end - + def create - @original_picture = OriginalPicture.show params[:original_picture_id], @operators - @original_picture_license_group = OriginalPictureLicenseGroup.new params[:original_picture_license_group] - @license_group = LicenseGroup.show @original_picture_license_group.license_group_id, @operators - @ctl = @license_group.my_engine_name - @attr = @license_group.my_engine.new_attribute {} - @attr.supply_default @operators - - respond_to do |format| - if @original_picture_license_group.valid? - format.html { render :template => "#{@ctl}/attributes/new" } - format.js { render :template => "#{@ctl}/attributes/new" } - else - format.html { render action: "new" } - format.js { render action: "new" } + @my_model_class = OriginalPictureLicenseGroup + + @item = @my_model_class.new + @my_model_class.fold_extend_settings params[@my_model_class.item_name] + @item.attributes = @item.permit_params params + @item.overwrite + @original_picture = OriginalPicture.show @item.original_picture, @operators + + if @item.valid? + # switch my_model_class + @item = OriginalPictureLicenseGroup.build_original_picture_license @item, nil, @operators + respond_to do |format| + format.html { + @form = Locmare::Bucket.factory @item.item_name, 'default', @item, true, true, @operators + render :template => @item.path_name + '/new' + } + format.json { + render json: @item.to_json(), status: :created, location: @item + } + end + else + respond_to do |format| + format.html { + @form = Locmare::Bucket.factory @item.item_name, 'default', @item, true, true, @operators + render action: "new" + } + format.json { + render json: @item.errors, status: :unprocessable_entity + } end end end