X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Foriginal_picture_license_groups_controller.rb;h=3f74b0e306cca462419b3b0a1460f61c16fe5081;hb=0bdfae60dc58932c99849c31d36ee5d7715db782;hp=05a2a248cbc9de3164d592b06d1044d0a326bf60;hpb=b7f9906380e4b62096d776fe9ad15ba3c4fd4ba4;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 05a2a248..3f74b0e3 100644 --- a/app/controllers/original_picture_license_groups_controller.rb +++ b/app/controllers/original_picture_license_groups_controller.rb @@ -1,55 +1,50 @@ class OriginalPictureLicenseGroupsController < ApplicationController - layout 'test' if Pettanr::TestLayout - 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] - private - - def authenticate_artist - if @author.artist? - true - else - respond_to do |format| - format.html { redirect_to new_artist_path, :status => :found } - format.js { render "artists/new" } - format.json { - raise ActiveRecord::Forbidden - } - end - false - end - end - - public - - # GET /original_picture_license_groups/new - # GET /original_picture_license_groups/new.js def new - @original_picture = OriginalPicture.show params[:original_picture_id], @artist - @original_picture_license_group = OriginalPictureLicenseGroup.new() - @original_picture_license_group.supply_default @original_picture.id - + @original_picture = OriginalPicture.show params[:original_picture_id], @operators + @item = OriginalPictureLicenseGroup.new() + @item.supply_default @original_picture.id + respond_to do |format| - format.html # new.html.erb - 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 - - # POST /original_picture_license_groups - # POST /original_picture_license_groups.js + def create - @original_picture = OriginalPicture.show params[:original_picture_id], @artist - @original_picture_license_group = OriginalPictureLicenseGroup.new params[:original_picture_license_group] - @license_group = LicenseGroup.show @original_picture_license_group.license_group_id - @ctl = @license_group.classname.tableize - - 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