OSDN Git Service

fix license picture
authoryasushiito <yas@pen-chan.jp>
Sat, 21 Jun 2014 01:36:57 +0000 (10:36 +0900)
committeryasushiito <yas@pen-chan.jp>
Sat, 21 Jun 2014 01:36:57 +0000 (10:36 +0900)
35 files changed:
app/assets/javascripts/manifest/work/forms.js.coffee.erb
app/assets/javascripts/manifest/work/items.js.coffee.erb
app/assets/javascripts/manifest/work/models.js.coffee.erb
app/assets/javascripts/manifest/work/profilers.js.coffee.erb
app/controllers/original_picture_license_groups_controller.rb
app/controllers/original_picture_licenses_controller.rb [new file with mode: 0644]
app/controllers/pictures_controller.rb
app/controllers/resource_pictures_controller.rb
app/helpers/original_picture_licenses_helper.rb [new file with mode: 0644]
app/models/license.rb
app/models/original_picture_license.rb [new file with mode: 0644]
app/models/original_picture_license_group.rb
app/models/picture.rb
app/models/resource_picture.rb
app/views/original_picture_license_groups/_allform.html.erb [deleted file]
app/views/original_picture_license_groups/_form.html.erb [deleted file]
app/views/original_picture_license_groups/new.html.erb
app/views/original_picture_license_groups/new.js.erb [deleted file]
app/views/original_picture_licenses/new.html.erb [new file with mode: 0644]
app/views/pictures/_summary.html.erb
app/views/pictures/_tail.html.erb
app/views/resource_pictures/_form.html.erb
app/views/resource_pictures/_summary.html.erb
app/views/resource_pictures/show.html.erb
app/views/templates/r/form/tag/_select.html.erb
config/locales/pettanr.ja.yml
config/routes.rb
db/migrate/20140617081206_create_original_picture_licenses.rb [new file with mode: 0644]
db/migrate/20140620092441_license_on_extend.rb [new file with mode: 0644]
lib/locmare/form/field/tag/select.rb
lib/manifest/model/attribute/source.rb
lib/manifest/model/attribute/source/filter.rb [new file with mode: 0644]
lib/peta/item.rb
public/local_manifest.json
public/manifest.json

index a56b5fb..d76b552 100644 (file)
           type: 'hidden',\r
         },\r
       },\r
+      original_picture_id: {\r
+        label: {\r
+          type: 'none',\r
+        },\r
+        tag: {\r
+          type: 'hidden',\r
+        },\r
+      },\r
+      license_group_id: {\r
+        tag: {\r
+          type: 'select',\r
+        },\r
+      },\r
+    },\r
+    field_names: [\r
+      'id',\r
+      'original_picture_id',\r
+      'license_group_id',\r
+    ]\r
+  },\r
+  original_picture_license: {\r
+    fields: {\r
+      id: {\r
+        label: {\r
+          type: 'none',\r
+        },\r
+        tag: {\r
+          type: 'hidden',\r
+        },\r
+      },\r
+      original_picture_id: {\r
+        label: {\r
+          type: 'none',\r
+        },\r
+        tag: {\r
+          type: 'hidden',\r
+        },\r
+      },\r
       license_group_id: {\r
+        label: {\r
+          type: 'none',\r
+        },\r
+        tag: {\r
+          type: 'hidden',\r
+        },\r
+      },\r
+      license_id: {\r
         tag: {\r
           type: 'select',\r
         },\r
       },\r
+      license_settings: {\r
+        # boost_name: 'license_group',\r
+        row_break: true,\r
+      },\r
+      license_group_module_name: {\r
+        label: {\r
+          type: 'none',\r
+        },\r
+        tag: {\r
+          type: 'hidden',\r
+        },\r
+      },\r
     },\r
     field_names: [\r
       'id',\r
       'original_picture_id',\r
       'license_group_id',\r
+      'license_id',\r
+      'license_settings',\r
+      'license_group_module_name',\r
     ]\r
   },\r
   speech_balloon_template: {\r
       'overlap', \r
     ],\r
   },\r
+  pettanr_creative_commons_v30_licenses_attribute: {\r
+    fields: {\r
+      artist_name: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      caption: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      artist_url: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      source_url: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      more_permission_url: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+    },\r
+    field_names: [\r
+      'artist_name', \r
+      'caption', \r
+      'artist_url', \r
+      'source_url', \r
+      'more_permission_url', \r
+    ],\r
+  },\r
   pettanr_creative_commons_v30_licenses_credit_picture: {\r
     fields: {\r
       source_url_btn_id: {\r
       'overlap', \r
     ],\r
   },\r
+  pettanr_pettan_commons_v01_licenses_attribute: {\r
+    fields: {\r
+      artist_name: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      caption: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      sources: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+    },\r
+    field_names: [\r
+      'artist_name', \r
+      'caption', \r
+      'sources', \r
+    ],\r
+  },\r
   pettanr_pettan_commons_v01_licenses_credit_picture: {\r
     fields: {\r
       source_url_btn_id: {\r
       'trackback', \r
     ],\r
   },\r
+  pettanr_pettan_protected_v01_licenses_attribute: {\r
+    fields: {\r
+      artist_name: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      caption: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      sources: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+    },\r
+    field_names: [\r
+      'artist_name', \r
+      'caption', \r
+      'sources', \r
+    ],\r
+  },\r
   pettanr_pettan_protected_v01_licenses_credit_picture: {\r
     fields: {\r
       source_url_btn_id: {\r
       'trackback', \r
     ],\r
   },\r
+  pettanr_pettan_public_v01_licenses_attribute: {\r
+    fields: {\r
+      artist_name: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      caption: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      sources: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+    },\r
+    field_names: [\r
+      'artist_name', \r
+      'caption', \r
+      'sources', \r
+    ],\r
+  },\r
   pettanr_pettan_public_v01_licenses_credit_picture: {\r
     fields: {\r
       source_url_btn_id: {\r
       'trackback', \r
     ],\r
   },\r
+  pettanr_public_domain_v01_licenses_attribute: {\r
+    fields: {\r
+      artist_name: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      source_url: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      note: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+    },\r
+    field_names: [\r
+      'artist_name', \r
+      'source_url', \r
+      'note', \r
+    ],\r
+  },\r
   pettanr_public_domain_v01_licenses_credit_picture: {\r
     fields: {\r
       source_url_btn_id: {\r
       'trackback', \r
     ],\r
   },\r
+  pettanr_unknown_v01_licenses_attribute: {\r
+    fields: {\r
+      source_url: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+      note: {\r
+        tag: {\r
+          type: 'text',\r
+        },\r
+        row_break: true,\r
+      },\r
+    },\r
+    field_names: [\r
+      'source_url', \r
+      'note', \r
+    ],\r
+  },\r
   pettanr_unknown_v01_licenses_credit_picture: {\r
     fields: {\r
       source_url_btn_id: {\r
index fa0cb4c..34ccc52 100644 (file)
       },\r
     },\r
   },\r
+  original_picture_license_group: {\r
+  },\r
   original_picture_license: {\r
     args: {\r
       boost: {\r
         # expand license_group_settings\r
-        license_group: {\r
+        license: {\r
+          template_name: 'license_group',\r
           extend_model_class_name: 'Attribute',\r
           item_name_for_extend_model: 'attribute',\r
         },\r
-        credit_picture: {\r
-          template_name: 'license_group',\r
-          extend_model_class_name: 'CreditPicture',\r
-          item_name_for_extend_model: 'credit_picture',\r
-        },\r
       },\r
     },\r
   },\r
index f1e496d..b7972b0 100644 (file)
         }, \r
         artist: {\r
         }, \r
+        system_picture: {\r
+        }, \r
       },\r
       has_many: {\r
       },\r
           required: true,\r
         }\r
       },\r
-      artist_name: {\r
-        type: 'text',\r
+      system_picture_id: {\r
+        type: 'number',\r
         rules : {\r
           required: true,\r
+          number: true,\r
         }\r
       },\r
       license_group_settings: {\r
         }, \r
         artist: {\r
         }, \r
+        system_picture: {\r
+        }, \r
       },\r
       has_many: {\r
       },\r
           required: true,\r
         }\r
       },\r
-      artist_name: {\r
-        type: 'text',\r
+      system_picture_id: {\r
+        type: 'number',\r
+        rules : {\r
+          required: true,\r
+          number: true,\r
+        }\r
+      },\r
+      license_group_id: {\r
+        type: 'number',\r
         rules : {\r
           required: true,\r
+          number: true,\r
         }\r
       },\r
       license_group_settings: {\r
       },\r
     },\r
   },\r
+  original_picture_license: {\r
+    associations: {\r
+      belongs_to: {\r
+        original_picture: {\r
+        }, \r
+        license: {\r
+        }, \r
+        system_picture: {\r
+        }, \r
+      },\r
+      has_many: {\r
+      },\r
+      has_one: {\r
+      },\r
+    },\r
+    attributes: {\r
+      original_picture_id: {\r
+        type: 'number',\r
+        rules : {\r
+          required: true,\r
+          number: true,\r
+        }\r
+      },\r
+      license_group_id: {\r
+        type: 'number',\r
+        source: {\r
+          type: 'model',\r
+        },\r
+        rules : {\r
+          required: true,\r
+          number: true,\r
+        }\r
+      },\r
+      license_id: {\r
+        type: 'number',\r
+        source: {\r
+          type: 'filter',\r
+          args: {\r
+            resource_list_name: 'by_license_group',\r
+            filter_column_name: 'license_group_id',\r
+          },\r
+        },\r
+        rules : {\r
+          required: true,\r
+          number: true,\r
+        }\r
+      },\r
+      license_settings: {\r
+        type: 'text',\r
+        rules : {\r
+        }\r
+      },\r
+      license_group_module_name: {\r
+        type: 'text',\r
+        rules : {\r
+          required: true,\r
+        }\r
+      },\r
+    },\r
+  },\r
   speech_balloon_template: {\r
     associations: {\r
       belongs_to: {\r
   },\r
   pettanr_creative_commons_v30_licenses_attribute: {\r
     attributes: {\r
-      license_id: {\r
-        type: 'number',\r
-        rules : {\r
-          required: true,\r
-          number: true,\r
-        }\r
-      },\r
       artist_name: {\r
         type: 'text',\r
         rules : {\r
   },\r
   pettanr_pettan_commons_v01_licenses_attribute: {\r
     attributes: {\r
-      license_id: {\r
-        type: 'number',\r
-        rules : {\r
-          required: true,\r
-          number: true,\r
-        }\r
-      },\r
       artist_name: {\r
         type: 'text',\r
         rules : {\r
   },\r
   pettanr_pettan_protected_v01_licenses_attribute: {\r
     attributes: {\r
-      license_id: {\r
-        type: 'number',\r
-        rules : {\r
-          required: true,\r
-          number: true,\r
-        }\r
-      },\r
       artist_name: {\r
         type: 'text',\r
         rules : {\r
   },\r
   pettanr_pettan_public_v01_licenses_attribute: {\r
     attributes: {\r
-      license_id: {\r
-        type: 'number',\r
-        rules : {\r
-          required: true,\r
-          number: true,\r
-        }\r
-      },\r
       artist_name: {\r
         type: 'text',\r
         rules : {\r
   },\r
   pettanr_public_domain_v01_licenses_attribute: {\r
     attributes: {\r
-      license_id: {\r
-        type: 'number',\r
-        rules : {\r
-          required: true,\r
-          number: true,\r
-        }\r
-      },\r
       artist_name: {\r
         type: 'text',\r
         rules : {\r
   },\r
   pettanr_unknown_v01_licenses_attribute: {\r
     attributes: {\r
-      license_id: {\r
-        type: 'number',\r
-        rules : {\r
-          required: true,\r
-          number: true,\r
-        }\r
-      },\r
-      system_picture_id: {\r
-        type: 'number',\r
-        rules : {\r
-          required: true,\r
-          number: true,\r
-        }\r
-      },\r
       source_url: {\r
         type: 'text',\r
         rules : {\r
index f06b26e..53b1244 100644 (file)
       'artist_id', \r
       'license_id', \r
       'md5', \r
-      'artist_name', \r
+      'system_picture_id', \r
       'license_group_settings', \r
       'credit_picture_settings', \r
       'license_settings', \r
       'height', \r
       'filesize', \r
       'artist_id', \r
+      'license_group_id', \r
       'license_id', \r
       'md5', \r
-      'artist_name', \r
+      'system_picture_id', \r
       'license_group_settings', \r
       'credit_picture_settings', \r
       'license_settings', \r
index 1d3cfc7..457c5a4 100644 (file)
@@ -4,30 +4,47 @@ class OriginalPictureLicenseGroupsController < ApplicationController
   
   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, @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.template_path_name
-    @attr = @license_group.template_module.new_attribute {}
-    @attr.supply_default @operators
+    @my_model_class = OriginalPictureLicenseGroup
     
-    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" }
+    @item = @my_model_class.new
+    @my_model_class.fold_extend_settings params[@my_model_class.item_name]
+    @item.attributes = params[@my_model_class.item_name]
+    @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, @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, @item, true, true, @operators
+          render action: "new"
+        }
+        format.json {
+          render json: @item.errors, status: :unprocessable_entity
+        }
       end
     end
   end
diff --git a/app/controllers/original_picture_licenses_controller.rb b/app/controllers/original_picture_licenses_controller.rb
new file mode 100644 (file)
index 0000000..9df8b19
--- /dev/null
@@ -0,0 +1,44 @@
+class OriginalPictureLicensesController < ApplicationController
+  before_filter :authenticate_user, :only => [:new, :create]
+  before_filter :authenticate_artist, :only => [:new, :create]
+  
+  def new
+    # use @item, @original_picture, @form
+    
+    respond_to do |format|
+      format.html
+    end
+  end
+  
+  def create
+    @my_model_class = OriginalPictureLicense
+    
+    @item = @my_model_class.new
+    @my_model_class.fold_extend_settings params[@my_model_class.item_name]
+    @item.attributes = params[@my_model_class.item_name]
+    @item.overwrite 
+    @item.boosts 'post'
+    @original_picture = OriginalPicture.show @item.original_picture, @operators
+    
+    if @item.valid?
+      # switch my_model_class
+      @item = OriginalPictureLicense.build_resource_picture @item, @original_picture, params[@my_model_class.item_name]
+      respond_to do |format|
+        format.html {
+          render main_app.new_resource_picture_path
+        }
+        format.json { render json: @item.to_json, status: :created }
+      end
+    else
+      respond_to do |format|
+        format.html {
+          @form = Locmare::Bucket.factory @item.item_name, @item, true, true, @operators
+          render action: "new"
+        }
+        format.json {
+          render json: @item.errors, status: :unprocessable_entity
+        }
+      end
+    end
+  end
+end
index 69456b6..0847917 100644 (file)
@@ -37,6 +37,7 @@ class PicturesController < ApplicationController
       format.jpeg { send_data(@item.restore(params[:subdir]), opt ) }
       show_html_format format
       show_json_format format
+      show_prof_format format
     end
   end
   
index e6b36f5..644e735 100644 (file)
@@ -66,47 +66,36 @@ class ResourcePicturesController < ApplicationController
   end
   
   def new
-    @original_picture = OriginalPicture.edit params[:original_picture_id], @operators
-    @imager = PettanImager.load @original_picture.restore
-    @original_picture_license_group = OriginalPictureLicenseGroup.new params[:original_picture_license_group]
-    @license_group = LicenseGroup.show @original_picture_license_group.license_group_id
-    @resource_picture = @original_picture.resource_picture
-    unless @resource_picture
-      @resource_picture = ResourcePicture.new
-      @resource_picture.supply_default
-    end
-    @resource_picture.attributes = params[:resource_picture]
-    @resource_picture.overwrite @original_picture
-    @license = @resource_picture.license
-    
+    # use @item, @original_picture
     respond_to do |format|
-      format.html # new.html.erb
-      format.js
+      format.html
     end
   end
   
   def create
     @original_picture = OriginalPicture.edit params[:original_picture_id], @operators
     @imager = PettanImager.load @original_picture.restore
-    @original_picture_license_group = OriginalPictureLicenseGroup.new params[:original_picture_license_group]
-    @license_group = LicenseGroup.show @original_picture_license_group.license_group_id, @operators
-    @resource_picture = @original_picture.resource_picture
-    unless @resource_picture
-      @resource_picture = ResourcePicture.new
-      @resource_picture.supply_default
+    jsn = nil
+    if params[:json]
+      jsn = JSON.parse_no_except(params[:json])
     end
-    @resource_picture.attributes = params[:resource_picture]
-    @resource_picture.overwrite @original_picture
-    @resource_picture.boosts 'post'
-    @license = @resource_picture.license
-
+    @prm = if params[:resource_picture] == nil or params[:resource_picture].empty?
+       jsn
+    else
+       params[:resource_picture]
+    end
+    @item = @original_picture.resource_picture || ResourcePicture.new
+    @item.attributes = @prm
+    @item.overwrite @original_picture
+    @item.boosts 'post'
+    
     respond_to do |format|
-      if @resource_picture.store(@imager)
-        format.html { redirect_to @resource_picture }
-        format.json { render json: @resource_picture.to_json(ResourcePicture.show_json_opt), status: :created, location: @resource_picture }
+      if @item.store(@imager)
+        format.html { redirect_to @item }
+        format.json { render json: @item.to_json, status: :created, location: @item }
       else
         format.html { render action: "new" }
-        format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
+        format.json { render json: @item.errors, status: :unprocessable_entity }
       end
     end
   end
diff --git a/app/helpers/original_picture_licenses_helper.rb b/app/helpers/original_picture_licenses_helper.rb
new file mode 100644 (file)
index 0000000..6ae2065
--- /dev/null
@@ -0,0 +1,2 @@
+module OriginalPictureLicensesHelper
+end
index a46c94c..7bfc26c 100644 (file)
@@ -11,6 +11,8 @@ class License < Peta::SystemResource
   validates :caption, :presence => true, :length => {:maximum => 30}
   validates :url, :presence => true, :length => {:maximum => 200}, :uniqueness => {:scope => :name}, :url => {:message => I18n.t('errors.messages.url')} #{:allow_blank => true}
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
+  validates :license_group_settings, :boost => {:boost_name => :license_group}
+  validates :credit_picture_settings, :boost => {:boost_name => :credit_picture}
   
   def overwrite 
   end
diff --git a/app/models/original_picture_license.rb b/app/models/original_picture_license.rb
new file mode 100644 (file)
index 0000000..933d3c3
--- /dev/null
@@ -0,0 +1,36 @@
+class OriginalPictureLicense < Peta::Item
+  load_manifest
+  belongs_to :original_picture
+  belongs_to :license_group
+  belongs_to :license
+  
+  validates :original_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
+  validates :license_group_id, :presence => true, :numericality => true, :existence => {:both => false}
+  validates :license_id, :presence => true, :numericality => true, :existence => {:both => false}
+  validates :license_group_module_name, :presence => true, :length => {:maximum => 50}
+  validates :license_settings, :boost => {:boost_name => :license}
+  
+  def supply_default oid
+    self.original_picture_id = oid
+    self.license_group_id = nil
+    self.license_id = nil
+  end
+  
+  def self.build_resource_picture opl, original_picture, params
+    my_model_class = ResourcePicture
+    
+    attr = params.merge(
+      :license_group_id => opl.license_group_id,
+      :system_picture_id => opl.license.system_picture_id,
+      :license_group_module_name => opl.license_group.module_name,
+      :license_group_settings => opl.license.license_group_settings,
+      :credit_picture_settings => opl.license.credit_picture_settings
+    )
+    resource_picture = my_model_class.new 
+    resource_picture.attributes = attr
+    resource_picture.overwrite original_picture
+    resource_picture.boosts 'post'
+    resource_picture
+  end
+  
+end
index a1a1cb2..f040b62 100644 (file)
@@ -1,4 +1,5 @@
 class OriginalPictureLicenseGroup < Peta::Item
+  load_manifest
   belongs_to :original_picture
   belongs_to :license_group
   
@@ -7,6 +8,29 @@ class OriginalPictureLicenseGroup < Peta::Item
   
   def supply_default oid
     self.original_picture_id = oid
+    self.license_group_id = nil
+  end
+  
+  def self.build_original_picture_license oplg, license_id, operators
+    my_model_class = OriginalPictureLicense
+    
+    original_picture = OriginalPicture.show oplg.original_picture_id, operators
+    license_group = LicenseGroup.show oplg.license_group_id
+    attr = {
+      :original_picture_id => original_picture.id,
+      :license_group_id => license_group.id,
+      :license_id => license_id,
+      :license_group_module_name => license_group.module_name
+    }
+    opl = my_model_class.new 
+    opl.attributes = attr
+    opl.boosts 'post'
+    # rare case of supply_default
+    # Attribute need artist name by @operators  
+    opl.boosters.each do |boost_name, booster|
+      booster.extend_item.supply_default operators
+    end
+    opl
   end
   
 end
index a2c8f49..24bf392 100644 (file)
@@ -17,7 +17,6 @@ class Picture < Peta::Content
   validates :license_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :artist_id, :presence => true, :numericality => true, :existence => {:both => false}
-  validates :artist_name, :presence => true
   validates :license_group_module_name, :presence => true, :length => {:maximum => 50}
   
   def supply_default
@@ -27,7 +26,7 @@ class Picture < Peta::Content
     attr = {:width => rp.width, :height => rp.height, :ext => rp.ext, :filesize => rp.filesize, 
       :original_picture_id => rp.original_picture_id, :license_id => rp.license_id, 
       :system_picture_id => rp.system_picture_id, :artist_id => rp.artist_id, 
-      :md5 => rp.md5, :artist_name => rp.artist_name, 
+      :md5 => rp.md5, 
       :license_group_module_name => rp.license_group_module_name, 
       :license_group_settings => rp.license_group_settings, 
       :credit_picture_settings => rp.credit_picture_settings,
index 4c02cc1..773c4c3 100644 (file)
@@ -16,16 +16,19 @@ class ResourcePicture < Peta::Content
   validates :license_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :original_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
-  validates :artist_name, :presence => true
   validates :license_group_module_name, :presence => true, :length => {:maximum => 50}
   validates :picture_id, :presence => true, :numericality => true, :existence => {:both => false}
+  validates :license_settings, :boost => {:boost_name => :license}
+  validates :license_group_settings, :boost => {:boost_name => :license_group}
+  validates :credit_picture_settings, :boost => {:boost_name => :credit_picture}
   
   def supply_default
   end
   
   def overwrite op
     attr = {:width => op.width, :height => op.height, :ext => op.ext, :filesize => op.filesize, 
-      :original_picture_id => op.id, :artist_id => op.artist_id, :md5 => op.md5
+      :original_picture_id => op.id, :artist_id => op.artist_id, :md5 => op.md5,
+      :created_at => Time.now, :updated_at => Time.now
     }
     self.attributes = attr
   end
diff --git a/app/views/original_picture_license_groups/_allform.html.erb b/app/views/original_picture_license_groups/_allform.html.erb
deleted file mode 100644 (file)
index 5c6ec22..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<%= form_for(@original_picture_license_group) do |f| %>
-  <%= render 'system/error_explanation', :obj => @original_picture_license_group %>
-
-  <div class="field">
-    <%= f.label :license_group_id %><br />
-    <%= f.collection_select :license_group_id, LicenseGroup.enable_list().map {|l| [l.caption, l.id] }, :last, :first %>
-    <%= f.hidden_field :original_picture_id %>
-  </div>
-  <%= hidden_field_tag :original_picture_id, @original_picture.id %>
-
-  <div class="actions">
-    <%= f.submit %>
-  </div>
-<% end %>
diff --git a/app/views/original_picture_license_groups/_form.html.erb b/app/views/original_picture_license_groups/_form.html.erb
deleted file mode 100644 (file)
index 732e615..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<%= form_for(@original_picture_license_group) do |f| %>
-  <%= render 'system/error_explanation', :obj => @original_picture_license_group %>
-
-  <table class="no-border">
-    <tr>
-      <td><%= t_m 'OriginalPictureLicenseGroup.license_group_id' -%></td>
-      <td><%= f.collection_select :license_group_id, LicenseGroup.enable_list().map {|l| [l.caption, l.id] }, :last, :first %></td>
-      <td><%= t 'original_picture_license_groups.new.no_blank' %></td>
-    </tr>
-  </table>
-  <%= f.hidden_field :original_picture_id %>
-  <%= hidden_field_tag :original_picture_id, @original_picture.id %>
-
-  <div class="actions">
-    <%= f.submit t 'original_picture_license_groups.new.next' %>
-  </div>
-<% end %>
index 0d2297b..8f3202c 100644 (file)
@@ -1,3 +1,3 @@
 <h1><%= t '.title' -%></h1>
 <img src="<%= @original_picture.url -%>">
-<%= render 'form' %>
+<%= render @form.template_name, :form => @form %>
diff --git a/app/views/original_picture_license_groups/new.js.erb b/app/views/original_picture_license_groups/new.js.erb
deleted file mode 100644 (file)
index ed93c2b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-$("#oplg").html("<%= escape_javascript(render('form')) -%>");
diff --git a/app/views/original_picture_licenses/new.html.erb b/app/views/original_picture_licenses/new.html.erb
new file mode 100644 (file)
index 0000000..92ca5c7
--- /dev/null
@@ -0,0 +1,4 @@
+<h1><%= t('pettanr_pettan_commons_v01_licenses.title') %></h1>
+<% @page_title = t('pettanr_pettan_commons_v01_licenses.title') %>
+<%= tag(:img, @original_picture.opt_img_tag) -%>
+<%= render @form.template_name, :form => @form %>
index fcc9da7..5a2fea8 100644 (file)
@@ -1,4 +1,4 @@
 <div>
-  <%= link_to h(truncate(item.artist.name, :length => 12)), artist_path(item.artist) %>
+  <%# link_to h(truncate(item.artist.name, :length => 12)), artist_path(item.artist) %>
   <%= render item.credit_template, :picture => item %>
 </div>
index c12759a..c9a8081 100644 (file)
       <div>
         <%= t_m 'Picture.md5' -%>:<%= picture.md5 %>
       </div>
-      <div>
-        <%= t_m 'Picture.artist_id' -%>:<%= link_to h(picture.artist.name), artist_path(picture.artist) %>
-      </div>
-      <div>
-        <%= t_m 'Picture.license_id' -%>:<%= link_to h(picture.license.caption), license_path(picture.license) %>
-      </div>
-      <div>
-        <%= t_m 'Picture.artist_name' -%>:<%= h picture.artist_name %>
-      </div>
     </td>
   </tr>
 </table>
index ab9eedc..17a6816 100644 (file)
@@ -1,21 +1,17 @@
 <img src="<%= @original_picture.url -%>">
-<%= form_for(@resource_picture, :url => '/resource_pictures', :method => :post) do |f| %>
+<%= form_for(@item, :url => '/resource_pictures', :method => :post) do |f| %>
 
   <%= hidden_field_tag :original_picture_id, @original_picture.id %>
+  <%= hidden_field_tag :json, @item.to_json %>
   
-  <%= hidden_field_tag 'original_picture_license_group[original_picture_id]', @original_picture_license_group.original_picture_id %>
-  <%= hidden_field_tag 'original_picture_license_group[license_group_id]', @original_picture_license_group.license_group_id %>
-
-  <%= f.hidden_field :original_picture_id %>
-  <%= f.hidden_field :license_id %>
-  <%= f.hidden_field :system_picture_id %>
-  <%= f.hidden_field :artist_name %>
-  <%= f.hidden_field :license_group_module_name %>
-  <%= f.hidden_field :license_group_settings %>
-  <%= f.hidden_field :credit_picture_settings %>
-  <%= f.hidden_field :license_settings %>
-
-  <%= render  :partial => @resource_picture.license_group_module_name.tableize + '/attributes/confirm' %>
+  <div>
+    <h2><%= t('credit.full') -%></h2>
+    <%= render @item.full_credit_template, :picture => @item %>
+  </div>
+  <div>
+    <h2><%= t('credit.digest') -%></h2>
+    <%= render @item.credit_template, :picture => @item %>
+  </div>
 
   <div class="actions">
     <%= f.submit t 'resource_pictures.new.publish'  %>
index fcc9da7..93b8679 100644 (file)
@@ -1,4 +1,4 @@
 <div>
-  <%= link_to h(truncate(item.artist.name, :length => 12)), artist_path(item.artist) %>
+  <%# link_to icon_tag('Artist'), artist_path(item.artist) %>
   <%= render item.credit_template, :picture => item %>
 </div>
index 9b6c9fc..d6720fe 100644 (file)
@@ -39,6 +39,7 @@
   
   <p>
     <%= link_to t('original_pictures.show.replace'), edit_original_picture_path(@item.original_picture) %>
+    <%= link_to t('show'), original_picture_path(@item.original_picture) %>
     <%= link_to t('original_pictures.index.stop'), resource_picture_path(@item), :method => :delete %>
   </p>
 <% end -%>
index 65bb2cb..fcec3a3 100644 (file)
@@ -1 +1,4 @@
-<%= select_tag tag.form_field_name, options_for_select(t_select_items(tag.items), :selected => tag.value.to_s), tag.options %>
+<%= select_tag tag.form_field_name, 
+  options_for_select(tag.source_by_model? ? tag.items : t_select_items(tag.items), :selected => tag.value.to_s), 
+  tag.options 
+%>
index 2f63906..d49c465 100644 (file)
@@ -37,6 +37,8 @@ ja:
       original_picture: 原画
       picture: 実素材
       resource_picture: 素材
+      original_picture_license_group: ライセンスグループ選択
+      original_picture_license: ライセンス選択
       speech_balloon_template: フキダシテンプレート
       writing_format: 記法
       license_group: ライセンスグループ
@@ -260,6 +262,7 @@ ja:
         md5: MD5
         artist_id: 絵師
         license_id: ライセンス
+        system_picture_id: ライセンスマーク
         artist_name: 著作者名
         license_group_settings: ライセンスフラグ
         credit_picture_settings: クレジット拡張データ
@@ -275,7 +278,9 @@ ja:
         filesize: ファイルサイズ
         md5: MD5
         artist_id: 絵師
+        license_group_id: ライセンス
         license_id: ライセンス
+        system_picture_id: ライセンスマーク
         artist_name: 著作者名
         license_group_settings: ライセンスフラグ
         credit_picture_settings: クレジット拡張データ
@@ -289,6 +294,14 @@ ja:
         license_group_id: ライセンスグループ
         created_at: 作成
         updated_at: 更新
+      original_picture_license:
+        original_picture_id: 原画
+        license_group_id: ライセンスグループ
+        license_id: ライセンス
+        license_settings: ライセンス拡張データ
+        license_group_module_name: ライセンスモジュール名
+        created_at: 作成
+        updated_at: 更新
       speech_balloon_template:
         name: 管理名
         module_name: モジュール名
@@ -394,131 +407,232 @@ ja:
       provider_original_picture:
         created_at: 作成
         updated_at: 更新
+      pettanr_creative_commons_v30_licenses_license:
+        open: クローズドな利用
+        commercial: 商用利用
+        official: 公式ライセンス
+        attribution: クレジットの表示
+        derive: 改変
+        thumbnail: サムネイルの作成
+        gif_convert: GIFフォーマットへの変換
+        reverse: 反転
+        sync_vh: 縦横比の改変
+        overlap: 重ね合わせ
+      pettanr_creative_commons_v30_licenses_credit_picture:
+        source_url_btn_id: URLボタン
+        source_url_off_btn_id: URLはないボタン
+      pettanr_creative_commons_v30_licenses_attribute:
+        artist_name: 著作者名
+        caption: 作品の名前
+        artist_url: 作者のホームページURL
+        source_url: 参考にした画像のURL
+        more_permission_url: 追加的許諾のURL
+      pettanr_pettan_commons_v01_licenses_license:
+        open: クローズドな利用
+        commercial: 商用利用
+        official: 公式ライセンス
+        attribution: クレジットの表示
+        derive: 改変
+        thumbnail: サムネイルの作成
+        gif_convert: GIFフォーマットへの変換
+        reverse: 反転
+        sync_vh: 縦横比の改変
+        overlap: 重ね合わせ
+      pettanr_pettan_commons_v01_licenses_credit_picture:
+        source_url_btn_id: URLボタン
+        source_url_off_btn_id: URLはないボタン
+      pettanr_pettan_commons_v01_licenses_attribute:
+        artist_name: 著作者名
+        caption: 作品の名前
+        sources: 参考にした画像のURL
+      pettanr_pettan_protected_v01_licenses_license:
+        open: クローズドな利用
+        commercial: 商用利用
+        official: 公式ライセンス
+        attribution: クレジットの表示
+        derive: 改変
+        thumbnail: サムネイルの作成
+        gif_convert: GIFフォーマットへの変換
+        reverse: 反転
+        sync_vh: 縦横比の改変
+        overlap: 重ね合わせ
+        trackback: トラックバック
+      pettanr_pettan_protected_v01_licenses_credit_picture:
+        source_url_btn_id: URLボタン
+        source_url_off_btn_id: URLはないボタン
+      pettanr_pettan_protected_v01_licenses_attribute:
+        artist_name: 著作者名
+        caption: 作品の名前
+        sources: 参考にした画像のURL
+      pettanr_pettan_public_v01_licenses_license:
+        open: クローズドな利用
+        commercial: 商用利用
+        official: 公式ライセンス
+        attribution: クレジットの表示
+        derive: 改変
+        thumbnail: サムネイルの作成
+        gif_convert: GIFフォーマットへの変換
+        reverse: 反転
+        sync_vh: 縦横比の改変
+        overlap: 重ね合わせ
+        trackback: トラックバック
+      pettanr_pettan_public_v01_licenses_credit_picture:
+        source_url_btn_id: URLボタン
+      pettanr_pettan_public_v01_licenses_attribute:
+        artist_name: 著作者名
+        caption: 作品の名前
+        sources: 参考にした画像のURL
+      pettanr_public_domain_v01_licenses_license:
+        open: クローズドな利用
+        commercial: 商用利用
+        official: 公式ライセンス
+        attribution: クレジットの表示
+        derive: 改変
+        thumbnail: サムネイルの作成
+        gif_convert: GIFフォーマットへの変換
+        reverse: 反転
+        sync_vh: 縦横比の改変
+        overlap: 重ね合わせ
+        trackback: トラックバック
+      pettanr_public_domain_v01_licenses_credit_picture:
+        source_url_btn_id: URLボタン
+        source_url_off_btn_id: URLはないボタン
+      pettanr_public_domain_v01_licenses_attribute:
+        artist_name: 著作者名
+        caption: 作品の名前
+        source_url: 参考にした画像のURL
+        note: 備考
+      pettanr_unknown_v01_licenses_license:
+        open: クローズドな利用
+        commercial: 商用利用
+        official: 公式ライセンス
+        attribution: クレジットの表示
+        derive: 改変
+        thumbnail: サムネイルの作成
+        gif_convert: GIFフォーマットへの変換
+        reverse: 反転
+        sync_vh: 縦横比の改変
+        overlap: 重ね合わせ
+        trackback: トラックバック
+      pettanr_unknown_v01_licenses_credit_picture:
+        source_url_btn_id: URLボタン
+        source_url_off_btn_id: URLはないボタン
+      pettanr_unknown_v01_licenses_attribute:
+        source_url: 参考にした画像のURL
+        note: 備考
       pettanr_creative_commons_v30_licenses/license:
-          open: クローズドな利用
-          commercial: 商用利用
-          official: 公式ライセンス
-          attribution: クレジットの表示
-          derive: 改変
-          thumbnail: サムネイルの作成
-          gif_convert: GIFフォーマットへの変換
-          reverse: 反転
-          sync_vh: 縦横比の改変
-          overlap: 重ね合わせ
+        open: クローズドな利用
+        commercial: 商用利用
+        official: 公式ライセンス
+        attribution: クレジットの表示
+        derive: 改変
+        thumbnail: サムネイルの作成
+        gif_convert: GIFフォーマットへの変換
+        reverse: 反転
+        sync_vh: 縦横比の改変
+        overlap: 重ね合わせ
       pettanr_creative_commons_v30_licenses/credit_picture:
-          source_url_btn_id: URLボタン
-          source_url_off_btn_id: URLはないボタン
+        source_url_btn_id: URLボタン
+        source_url_off_btn_id: URLはないボタン
       pettanr_creative_commons_v30_licenses/attribute:
-          license_id: ライセンスID
-          system_picture_id: マーク画像ID
-          artist_name: 著作者名
-          caption: 作品の名前
-          artist_url: 作者のホームページURL
-          source_url: 参考にした画像のURL
-          more_permission_url: 追加的許諾のURL
+        artist_name: 著作者名
+        caption: 作品の名前
+        artist_url: 作者のホームページURL
+        source_url: 参考にした画像のURL
+        more_permission_url: 追加的許諾のURL
       pettanr_pettan_commons_v01_licenses/license:
-          open: クローズドな利用
-          commercial: 商用利用
-          official: 公式ライセンス
-          attribution: クレジットの表示
-          derive: 改変
-          thumbnail: サムネイルの作成
-          gif_convert: GIFフォーマットへの変換
-          reverse: 反転
-          sync_vh: 縦横比の改変
-          overlap: 重ね合わせ
+        open: クローズドな利用
+        commercial: 商用利用
+        official: 公式ライセンス
+        attribution: クレジットの表示
+        derive: 改変
+        thumbnail: サムネイルの作成
+        gif_convert: GIFフォーマットへの変換
+        reverse: 反転
+        sync_vh: 縦横比の改変
+        overlap: 重ね合わせ
       pettanr_pettan_commons_v01_licenses/credit_picture:
-          source_url_btn_id: URLボタン
-          source_url_off_btn_id: URLはないボタン
+        source_url_btn_id: URLボタン
+        source_url_off_btn_id: URLはないボタン
       pettanr_pettan_commons_v01_licenses/attribute:
-          license_id: ライセンスID
-          system_picture_id: マーク画像ID
-          artist_name: 著作者名
-          caption: 作品の名前
-          sources: 参考にした画像のURL
+        artist_name: 著作者名
+        caption: 作品の名前
+        sources: 参考にした画像のURL
       pettanr_pettan_protected_v01_licenses/license:
-          open: クローズドな利用
-          commercial: 商用利用
-          official: 公式ライセンス
-          attribution: クレジットの表示
-          derive: 改変
-          thumbnail: サムネイルの作成
-          gif_convert: GIFフォーマットへの変換
-          reverse: 反転
-          sync_vh: 縦横比の改変
-          overlap: 重ね合わせ
-          trackback: トラックバック
+        open: クローズドな利用
+        commercial: 商用利用
+        official: 公式ライセンス
+        attribution: クレジットの表示
+        derive: 改変
+        thumbnail: サムネイルの作成
+        gif_convert: GIFフォーマットへの変換
+        reverse: 反転
+        sync_vh: 縦横比の改変
+        overlap: 重ね合わせ
+        trackback: トラックバック
       pettanr_pettan_protected_v01_licenses/credit_picture:
-          source_url_btn_id: URLボタン
-          source_url_off_btn_id: URLはないボタン
+        source_url_btn_id: URLボタン
+        source_url_off_btn_id: URLはないボタン
       pettanr_pettan_protected_v01_licenses/attribute:
-          license_id: ライセンスID
-          system_picture_id: マーク画像ID
-          artist_name: 著作者名
-          caption: 作品の名前
-          sources: 参考にした画像のURL
+        artist_name: 著作者名
+        caption: 作品の名前
+        sources: 参考にした画像のURL
       pettanr_pettan_public_v01_licenses/license:
-          open: クローズドな利用
-          commercial: 商用利用
-          official: 公式ライセンス
-          attribution: クレジットの表示
-          derive: 改変
-          thumbnail: サムネイルの作成
-          gif_convert: GIFフォーマットへの変換
-          reverse: 反転
-          sync_vh: 縦横比の改変
-          overlap: 重ね合わせ
-          trackback: トラックバック
+        open: クローズドな利用
+        commercial: 商用利用
+        official: 公式ライセンス
+        attribution: クレジットの表示
+        derive: 改変
+        thumbnail: サムネイルの作成
+        gif_convert: GIFフォーマットへの変換
+        reverse: 反転
+        sync_vh: 縦横比の改変
+        overlap: 重ね合わせ
+        trackback: トラックバック
       pettanr_pettan_public_v01_licenses/credit_picture:
-          source_url_btn_id: URLボタン
+        source_url_btn_id: URLボタン
       pettanr_pettan_public_v01_licenses/attribute:
-          license_id: ライセンスID
-          system_picture_id: マーク画像ID
-          artist_name: 著作者名
-          caption: 作品の名前
-          sources: 参考にした画像のURL
+        artist_name: 著作者名
+        caption: 作品の名前
+        sources: 参考にした画像のURL
       pettanr_public_domain_v01_licenses/license:
-          open: クローズドな利用
-          commercial: 商用利用
-          official: 公式ライセンス
-          attribution: クレジットの表示
-          derive: 改変
-          thumbnail: サムネイルの作成
-          gif_convert: GIFフォーマットへの変換
-          reverse: 反転
-          sync_vh: 縦横比の改変
-          overlap: 重ね合わせ
-          trackback: トラックバック
+        open: クローズドな利用
+        commercial: 商用利用
+        official: 公式ライセンス
+        attribution: クレジットの表示
+        derive: 改変
+        thumbnail: サムネイルの作成
+        gif_convert: GIFフォーマットへの変換
+        reverse: 反転
+        sync_vh: 縦横比の改変
+        overlap: 重ね合わせ
+        trackback: トラックバック
       pettanr_public_domain_v01_licenses/credit_picture:
-          source_url_btn_id: URLボタン
-          source_url_off_btn_id: URLはないボタン
+        source_url_btn_id: URLボタン
+        source_url_off_btn_id: URLはないボタン
       pettanr_public_domain_v01_licenses/attribute:
-          license_id: ライセンスID
-          system_picture_id: マーク画像ID
-          artist_name: 著作者名
-          caption: 作品の名前
-          source_url: 参考にした画像のURL
-          note: 備考
+        artist_name: 著作者名
+        caption: 作品の名前
+        source_url: 参考にした画像のURL
+        note: 備考
       pettanr_unknown_v01_licenses/license:
-          open: クローズドな利用
-          commercial: 商用利用
-          official: 公式ライセンス
-          attribution: クレジットの表示
-          derive: 改変
-          thumbnail: サムネイルの作成
-          gif_convert: GIFフォーマットへの変換
-          reverse: 反転
-          sync_vh: 縦横比の改変
-          overlap: 重ね合わせ
-          trackback: トラックバック
+        open: クローズドな利用
+        commercial: 商用利用
+        official: 公式ライセンス
+        attribution: クレジットの表示
+        derive: 改変
+        thumbnail: サムネイルの作成
+        gif_convert: GIFフォーマットへの変換
+        reverse: 反転
+        sync_vh: 縦横比の改変
+        overlap: 重ね合わせ
+        trackback: トラックバック
       pettanr_unknown_v01_licenses/credit_picture:
-          source_url_btn_id: URLボタン
-          source_url_off_btn_id: URLはないボタン
+        source_url_btn_id: URLボタン
+        source_url_off_btn_id: URLはないボタン
       pettanr_unknown_v01_licenses/attribute:
-          license_id: ライセンスID
-          system_picture_id: マーク画像ID
-          source_url: 参考にした画像のURL
-          note: 備考
+        source_url: 参考にした画像のURL
+        note: 備考
   picture_io:
     error: 画像保管庫との手続きで異常が発生しました。
   select_items:
@@ -1186,10 +1300,19 @@ ja:
   original_picture_license_groups:
     new:
       title: 画像の公開(ライセンスグループの選択)
-      next: 次へ
       no_blank: 必須項目
     create:
       title: 画像の公開(ライセンスグループの選択)
+    submit:
+      new: 次へ
+  original_picture_licenses:
+    new:
+      title: 画像の公開(ライセンスの選択)
+      no_blank: 必須項目
+    create:
+      title: 画像の公開(ライセンスの選択)
+    submit:
+      new: 次へ
   speech_balloon_templates:
     index:
       title: フキダシテンプレート一覧
@@ -1507,6 +1630,9 @@ ja:
     marker: ■
     catch: 掴む
   editor: 編集メニュー
+  credit:
+    digest: 簡易クレジット
+    full: クレジット
   tab:
     creator:
       home: 作る・見せる
index 698ec18..42f8b46 100644 (file)
@@ -510,6 +510,14 @@ Pettanr::Application.routes.draw do
       post :create
     end
   end
+  resources :original_picture_licenses do
+    new do
+      post :new
+    end
+    collection do
+      post :create
+    end
+  end
   resources :provider_sources do
     collection do
       get :index
diff --git a/db/migrate/20140617081206_create_original_picture_licenses.rb b/db/migrate/20140617081206_create_original_picture_licenses.rb
new file mode 100644 (file)
index 0000000..9675173
--- /dev/null
@@ -0,0 +1,13 @@
+class CreateOriginalPictureLicenses < ActiveRecord::Migration
+  def change
+    create_table :original_picture_licenses do |t|
+      t.integer :original_picture_id, :null => false, :default => 0
+      t.integer :license_group_id, :null => false, :default => 0
+      t.integer :license_id, :null => false, :default => 0
+      t.text :license_settings
+      t.text :license_group_module_name, :null => false, :limit => 50, :default => "StandardLicense"
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/migrate/20140620092441_license_on_extend.rb b/db/migrate/20140620092441_license_on_extend.rb
new file mode 100644 (file)
index 0000000..fc06f76
--- /dev/null
@@ -0,0 +1,9 @@
+class LicenseOnExtend < ActiveRecord::Migration
+  def up
+    remove_column :resource_pictures, :artist_name
+    remove_column :pictures, :artist_name
+  end
+
+  def down
+  end
+end
index 3da48a0..42700d4 100644 (file)
@@ -7,14 +7,42 @@ module Locmare
             'select'
           end
           
+          def model_manifest
+            ::Manifest.manifest.models[@field.field_manifest.model_name]
+          end
+          
+          def model_attribute_manifest
+            self.model_manifest.attributes[@field.field_manifest.column_name]
+          end
+          
           def select_item_name
-            model = ::Manifest.manifest.models[@field.field_manifest.model_name]
-            attr = model.attributes[@field.field_manifest.column_name]
-            attr.source.select_item_name
+            self.model_attribute_manifest.source.select_item_name
           end
           
           def items
-            ::Manifest.manifest.system_resources.select_items[self.select_item_name]
+            if self.model_attribute_manifest.source.type == 'model'
+              ::Manifest.manifest.system_resources.select_items[self.select_item_name]
+            else
+              resource_model_name = self.model_attribute_manifest.source.resource_model_name
+              resource_list_name = self.model_attribute_manifest.source.resource_list_name
+              filter_column_name = self.model_attribute_manifest.source.filter_column_name
+              filter_id = self.form.item.attributes[filter_column_name]
+              list = Locmare::ListGroup.list resource_model_name, resource_list_name
+              list.items(nil, {:id => filter_id}, 
+                0, -1 # no limit
+              ).map {|i| [i.caption, i.id] }
+            end
+          end
+          
+          def source_by_model?
+            case self.model_attribute_manifest.source.type
+            when 'model', 'filter'
+              true
+            when 'magic_number'
+              false
+            else
+              nil
+            end
           end
           
         end
index 34926f3..a16f736 100644 (file)
@@ -1,5 +1,5 @@
 ManifestBase.require_modules "manifest/model/attribute/source/", 
-  %w|base model magic_number|
+  %w|base model filter magic_number|
 
 module Manifest
   module ModelModule
@@ -9,7 +9,7 @@ module Manifest
           
           def self.types
             {
-              'model' => ModelSource, 'magic_number' => MagicNumberSource
+              'model' => ModelSource, 'filter' => FilterSource, 'magic_number' => MagicNumberSource
             }
           end
           
diff --git a/lib/manifest/model/attribute/source/filter.rb b/lib/manifest/model/attribute/source/filter.rb
new file mode 100644 (file)
index 0000000..89f8f09
--- /dev/null
@@ -0,0 +1,22 @@
+module Manifest
+  module ModelModule
+    module AttributeModule
+      module SourceModule
+        class FilterSource < ModelSource
+          attr :filter_column_name
+          
+          def set_default
+            super
+          end
+          
+          def init
+            super
+            @filter_column_name = @args['filter_column_name']
+          end
+          
+        end
+        
+      end
+    end
+  end
+end
index 3063b30..138b68a 100644 (file)
@@ -111,12 +111,12 @@ module Peta
       {}
     end
     
-    def self.show item_id, operators
+    def self.show item_id, operators = nil
       opt = {}
       opt.merge!(self.show_opt)
       item = self.find(item_id, opt)
       item.boosts 'read'
-      raise ActiveRecord::Forbidden if item.visible?(operators) == false
+      raise ActiveRecord::Forbidden if operators and item.visible?(operators) == false
       item
     end
     
index ef33ae8..9e781fe 100644 (file)
         "artist_id",\r
         "license_id",\r
         "md5",\r
-        "artist_name",\r
+        "system_picture_id",\r
         "license_group_settings",\r
         "credit_picture_settings",\r
         "license_settings",\r
         "height",\r
         "filesize",\r
         "artist_id",\r
+        "license_group_id",\r
         "license_id",\r
         "md5",\r
-        "artist_name",\r
+        "system_picture_id",\r
         "license_group_settings",\r
         "credit_picture_settings",\r
         "license_settings",\r
         "t"\r
       ]\r
     },\r
+    "original_picture_license_group": {\r
+      "fields": {\r
+        "id": {\r
+          "label": {\r
+            "type": "none"\r
+          },\r
+          "tag": {\r
+            "type": "hidden"\r
+          }\r
+        },\r
+        "original_picture_id": {\r
+          "label": {\r
+            "type": "none"\r
+          },\r
+          "tag": {\r
+            "type": "hidden"\r
+          }\r
+        },\r
+        "license_group_id": {\r
+          "tag": {\r
+            "type": "select"\r
+          }\r
+        }\r
+      },\r
+      "field_names": [\r
+        "id",\r
+        "original_picture_id",\r
+        "license_group_id"\r
+      ]\r
+    },\r
+    "original_picture_license": {\r
+      "fields": {\r
+        "id": {\r
+          "label": {\r
+            "type": "none"\r
+          },\r
+          "tag": {\r
+            "type": "hidden"\r
+          }\r
+        },\r
+        "original_picture_id": {\r
+          "label": {\r
+            "type": "none"\r
+          },\r
+          "tag": {\r
+            "type": "hidden"\r
+          }\r
+        },\r
+        "license_group_id": {\r
+          "label": {\r
+            "type": "none"\r
+          },\r
+          "tag": {\r
+            "type": "hidden"\r
+          }\r
+        },\r
+        "license_id": {\r
+          "tag": {\r
+            "type": "select"\r
+          }\r
+        },\r
+        "license_settings": {\r
+          "row_break": true\r
+        },\r
+        "license_group_module_name": {\r
+          "label": {\r
+            "type": "none"\r
+          },\r
+          "tag": {\r
+            "type": "hidden"\r
+          }\r
+        }\r
+      },\r
+      "field_names": [\r
+        "id",\r
+        "original_picture_id",\r
+        "license_group_id",\r
+        "license_id",\r
+        "license_settings",\r
+        "license_group_module_name"\r
+      ]\r
+    },\r
     "speech_balloon_template": {\r
       "fields": {\r
         "id": {\r
         "overlap"\r
       ]\r
     },\r
+    "pettanr_creative_commons_v30_licenses_attribute": {\r
+      "fields": {\r
+        "artist_name": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "caption": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "artist_url": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "source_url": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "more_permission_url": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        }\r
+      },\r
+      "field_names": [\r
+        "artist_name",\r
+        "caption",\r
+        "artist_url",\r
+        "source_url",\r
+        "more_permission_url"\r
+      ]\r
+    },\r
     "pettanr_creative_commons_v30_licenses_credit_picture": {\r
       "fields": {\r
         "source_url_btn_id": {\r
         "overlap"\r
       ]\r
     },\r
+    "pettanr_pettan_commons_v01_licenses_attribute": {\r
+      "fields": {\r
+        "artist_name": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "caption": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "sources": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        }\r
+      },\r
+      "field_names": [\r
+        "artist_name",\r
+        "caption",\r
+        "sources"\r
+      ]\r
+    },\r
     "pettanr_pettan_commons_v01_licenses_credit_picture": {\r
       "fields": {\r
         "source_url_btn_id": {\r
         "trackback"\r
       ]\r
     },\r
+    "pettanr_pettan_protected_v01_licenses_attribute": {\r
+      "fields": {\r
+        "artist_name": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "caption": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "sources": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        }\r
+      },\r
+      "field_names": [\r
+        "artist_name",\r
+        "caption",\r
+        "sources"\r
+      ]\r
+    },\r
     "pettanr_pettan_protected_v01_licenses_credit_picture": {\r
       "fields": {\r
         "source_url_btn_id": {\r
         "trackback"\r
       ]\r
     },\r
+    "pettanr_pettan_public_v01_licenses_attribute": {\r
+      "fields": {\r
+        "artist_name": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "caption": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "sources": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        }\r
+      },\r
+      "field_names": [\r
+        "artist_name",\r
+        "caption",\r
+        "sources"\r
+      ]\r
+    },\r
     "pettanr_pettan_public_v01_licenses_credit_picture": {\r
       "fields": {\r
         "source_url_btn_id": {\r
         "trackback"\r
       ]\r
     },\r
+    "pettanr_public_domain_v01_licenses_attribute": {\r
+      "fields": {\r
+        "artist_name": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "source_url": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "note": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        }\r
+      },\r
+      "field_names": [\r
+        "artist_name",\r
+        "source_url",\r
+        "note"\r
+      ]\r
+    },\r
     "pettanr_public_domain_v01_licenses_credit_picture": {\r
       "fields": {\r
         "source_url_btn_id": {\r
         "trackback"\r
       ]\r
     },\r
+    "pettanr_unknown_v01_licenses_attribute": {\r
+      "fields": {\r
+        "source_url": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        },\r
+        "note": {\r
+          "tag": {\r
+            "type": "text"\r
+          },\r
+          "row_break": true\r
+        }\r
+      },\r
+      "field_names": [\r
+        "source_url",\r
+        "note"\r
+      ]\r
+    },\r
     "pettanr_unknown_v01_licenses_credit_picture": {\r
       "fields": {\r
         "source_url_btn_id": {\r
     "original_picture": {},\r
     "picture": {},\r
     "resource_picture": {},\r
+    "original_picture_license_group": {},\r
     "speech_balloon_template": {},\r
     "writing_format": {},\r
     "license_group": {},\r
index ea5ca53..bd2e6ec 100644 (file)
         }\r
       }\r
     },\r
-    "original_picture_license_group": {\r
+    "original_picture_license_group": {},\r
+    "original_picture_license": {\r
       "args": {\r
         "boost": {\r
-          "license_group": {\r
+          "license": {\r
+            "template_name": "license_group",\r
             "extend_model_class_name": "Attribute",\r
             "item_name_for_extend_model": "attribute"\r
-          },\r
-          "credit_picture": {\r
-            "template_name": "license_group",\r
-            "extend_model_class_name": "CreditPicture",\r
-            "item_name_for_extend_model": "credit_picture"\r
           }\r
         }\r
       }\r
       "associations": {\r
         "belongs_to": {\r
           "license": {},\r
-          "artist": {}\r
+          "artist": {},\r
+          "system_picture": {}\r
         },\r
         "has_many": {},\r
         "has_one": {}\r
             "required": true\r
           }\r
         },\r
-        "artist_name": {\r
-          "type": "text",\r
+        "system_picture_id": {\r
+          "type": "number",\r
           "rules": {\r
-            "required": true\r
+            "required": true,\r
+            "number": true\r
           }\r
         },\r
         "license_group_settings": {\r
         "belongs_to": {\r
           "original_picture": {},\r
           "license": {},\r
-          "artist": {}\r
+          "artist": {},\r
+          "system_picture": {}\r
         },\r
         "has_many": {},\r
         "has_one": {}\r
             "required": true\r
           }\r
         },\r
-        "artist_name": {\r
-          "type": "text",\r
+        "system_picture_id": {\r
+          "type": "number",\r
           "rules": {\r
-            "required": true\r
+            "required": true,\r
+            "number": true\r
+          }\r
+        },\r
+        "license_group_id": {\r
+          "type": "number",\r
+          "rules": {\r
+            "required": true,\r
+            "number": true\r
           }\r
         },\r
         "license_group_settings": {\r
       }\r
     },\r
     "original_picture_license_group": {\r
-      "attributes": {}\r
+      "associations": {\r
+        "belongs_to": {\r
+          "original_picture": {},\r
+          "license_group": {}\r
+        },\r
+        "has_many": {},\r
+        "has_one": {}\r
+      },\r
+      "attributes": {\r
+        "original_picture_id": {\r
+          "type": "number",\r
+          "rules": {\r
+            "required": true,\r
+            "number": true\r
+          }\r
+        },\r
+        "license_group_id": {\r
+          "type": "number",\r
+          "rules": {\r
+            "required": true,\r
+            "number": true\r
+          },\r
+          "source": {\r
+            "type": "model"\r
+          }\r
+        }\r
+      }\r
+    },\r
+    "original_picture_license": {\r
+      "associations": {\r
+        "belongs_to": {\r
+          "original_picture": {},\r
+          "license": {},\r
+          "system_picture": {}\r
+        },\r
+        "has_many": {},\r
+        "has_one": {}\r
+      },\r
+      "attributes": {\r
+        "original_picture_id": {\r
+          "type": "number",\r
+          "rules": {\r
+            "required": true,\r
+            "number": true\r
+          }\r
+        },\r
+        "license_group_id": {\r
+          "type": "number",\r
+          "source": {\r
+            "type": "model"\r
+          },\r
+          "rules": {\r
+            "required": true,\r
+            "number": true\r
+          }\r
+        },\r
+        "license_id": {\r
+          "type": "number",\r
+          "source": {\r
+            "type": "filter",\r
+            "args": {\r
+              "resource_list_name": "by_license_group",\r
+              "filter_column_name": "license_group_id"\r
+            }\r
+          },\r
+          "rules": {\r
+            "required": true,\r
+            "number": true\r
+          }\r
+        },\r
+        "license_settings": {\r
+          "type": "text",\r
+          "rules": {}\r
+        },\r
+        "license_group_module_name": {\r
+          "type": "text",\r
+          "rules": {\r
+            "required": true\r
+          }\r
+        }\r
+      }\r
     },\r
     "speech_balloon_template": {\r
       "associations": {\r
     },\r
     "pettanr_creative_commons_v30_licenses_attribute": {\r
       "attributes": {\r
-        "license_id": {\r
-          "type": "number",\r
-          "rules": {\r
-            "required": true,\r
-            "number": true\r
-          }\r
-        },\r
         "artist_name": {\r
           "type": "text",\r
           "rules": {\r
     },\r
     "pettanr_pettan_commons_v01_licenses_attribute": {\r
       "attributes": {\r
-        "license_id": {\r
-          "type": "number",\r
-          "rules": {\r
-            "required": true,\r
-            "number": true\r
-          }\r
-        },\r
         "artist_name": {\r
           "type": "text",\r
           "rules": {\r
     },\r
     "pettanr_pettan_protected_v01_licenses_attribute": {\r
       "attributes": {\r
-        "license_id": {\r
-          "type": "number",\r
-          "rules": {\r
-            "required": true,\r
-            "number": true\r
-          }\r
-        },\r
         "artist_name": {\r
           "type": "text",\r
           "rules": {\r
     },\r
     "pettanr_pettan_public_v01_licenses_attribute": {\r
       "attributes": {\r
-        "license_id": {\r
-          "type": "number",\r
-          "rules": {\r
-            "required": true,\r
-            "number": true\r
-          }\r
-        },\r
         "artist_name": {\r
           "type": "text",\r
           "rules": {\r
     },\r
     "pettanr_public_domain_v01_licenses_attribute": {\r
       "attributes": {\r
-        "license_id": {\r
-          "type": "number",\r
-          "rules": {\r
-            "required": true,\r
-            "number": true\r
-          }\r
-        },\r
         "artist_name": {\r
           "type": "text",\r
           "rules": {\r
     },\r
     "pettanr_unknown_v01_licenses_attribute": {\r
       "attributes": {\r
-        "license_id": {\r
-          "type": "number",\r
-          "rules": {\r
-            "required": true,\r
-            "number": true\r
-          }\r
-        },\r
-        "system_picture_id": {\r
-          "type": "number",\r
-          "rules": {\r
-            "required": true,\r
-            "number": true\r
-          }\r
-        },\r
         "source_url": {\r
           "type": "text",\r
           "rules": {\r