pettanr_pettan_commons_v01_licenses 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,8 +2,7 @@ require_dependency "pettanr_pettan_commons_v01_licenses/application_controller"
2
2
 
3
3
  module PettanrPettanCommonsV01Licenses
4
4
  class AttributesController < ApplicationController
5
- layout 'test' if MagicNumber['test_layout']
6
- before_filter :authenticate_user!, :only => [:new, :create]
5
+ before_filter :authenticate_user, :only => [:new, :create]
7
6
  before_filter :authenticate_artist, :only => [:new, :create]
8
7
 
9
8
  def new
@@ -26,7 +25,7 @@ module PettanrPettanCommonsV01Licenses
26
25
  @pettan_commons_license = PettanrPettanCommonsV01Licenses::Attribute.new params[:pettan_commons_license]
27
26
  @license = License.show @pettan_commons_license.license_id, @operators
28
27
  @resource_picture = @original_picture.resource_picture || ResourcePicture.new
29
- @resource_picture.attributes = @pettan_commons_license.resource_picture_attributes @original_picture
28
+ @resource_picture.attributes = @pettan_commons_license.resource_picture_attributes @original_picture, @license
30
29
  @resource_picture.overwrite @original_picture
31
30
  respond_to do |format|
32
31
  if @pettan_commons_license.valid?
@@ -2,18 +2,26 @@ module PettanrPettanCommonsV01Licenses
2
2
  class Attribute < ActiveRecord::Base
3
3
  belongs_to :license
4
4
 
5
- validates :license_id, :presence => true, :numericality => true, :existence => true
5
+ validates :license_id, :presence => true, :numericality => true #, :existence => true
6
6
  validates :artist_name, :presence => true
7
7
 
8
8
  def supply_default operators
9
9
  self.artist_name = operators.artist.name
10
10
  end
11
11
 
12
- def resource_picture_attributes op
12
+ def resource_picture_attributes op, ls
13
13
  {
14
- :original_picture_id => op.id, :license_id => self.license.id,
15
- :artist_name => self.artist_name, :classname => self.license.license_group.classname,
16
- :credit => self.credit, :settings => self.license.settings
14
+ :original_picture_id => op.id,
15
+ :license_id => ls.id,
16
+ :artist_name => self.artist_name,
17
+ :license_group_classname => ls.license_group_classname,
18
+ :license_group_settings => ls.license_group_settings,
19
+ :credit_picture_settings => ls.credit_picture_settings,
20
+ :license_settings => {
21
+ :system_picture_id => ls.system_picture_id,
22
+ :caption => self.caption,
23
+ :sources => self.sources
24
+ }.to_json
17
25
  }
18
26
  end
19
27
 
@@ -24,13 +32,5 @@ module PettanrPettanCommonsV01Licenses
24
32
  [op, oplg, lg]
25
33
  end
26
34
 
27
- def credit
28
- {
29
- :system_picture_id => self.license.system_picture_id,
30
- :caption => self.caption,
31
- :sources => self.sources
32
- }.to_json.to_s
33
- end
34
-
35
35
  end
36
36
  end
@@ -7,16 +7,17 @@
7
7
  %>
8
8
  </td>
9
9
  <td>
10
+ <% picture.boosts 'post' %>
10
11
  <div class="md5">
11
12
  <%= h(truncate(picture.artist_name, :length => 12)) %>
12
13
  </div>
13
14
  <div class="md5">
14
- <%= h(truncate(picture.credit_data['caption'], :length => 12)) %>
15
+ <%= h(truncate(picture.attribute_extend.caption, :length => 12)) %>
15
16
  </div>
16
17
  <div class="md5">
17
18
  <% picture.license.boosts 'read' %>
18
19
  <% source_url_btn = SystemPicture.find(picture.license.credit_picture_extend.source_url_btn_id) %>
19
- <% urls = picture.credit_data['sources'].to_s.gsub(/\r/, '').split(/\n/) -%>
20
+ <% urls = picture.attribute_extend.sources.to_s.gsub(/\r/, '').split(/\n/) -%>
20
21
  <% urls[0..2].compact.each do |url| -%>
21
22
  <%= link_to(
22
23
  tag(:img, :src => source_url_btn.url, :alt => 'source url', :width => source_url_btn.width, :height => source_url_btn.height),
@@ -26,12 +26,12 @@
26
26
  </tr>
27
27
  <tr>
28
28
  <td><%= t_m 'PettanrPettanCommonsV01Licenses::Attribute.caption' -%></td>
29
- <td><%= h picture.credit_data['caption'] -%></td>
29
+ <td><%= h picture.attribute_extend.caption -%></td>
30
30
  </tr>
31
31
  <tr>
32
32
  <td><%= t_m 'PettanrPettanCommonsV01Licenses::Attribute.sources' -%></td>
33
33
  <td>
34
- <% picture.credit_data['sources'].to_s.gsub(/\r/, '').split(/\n/).each do |url| -%>
34
+ <% picture.attribute_extend.sources.to_s.gsub(/\r/, '').split(/\n/).each do |url| -%>
35
35
  <div><%= link_to(h(url), url) -%></div>
36
36
  <% end -%>
37
37
  </td>
@@ -0,0 +1,8 @@
1
+ class FixPettanrPettanCommonsV01LicensesAttributesSystemPictureId < ActiveRecord::Migration
2
+ def up
3
+ add_column :pettanr_pettan_commons_v01_licenses_attributes, :system_picture_id, :integer, :null => false, :default => 0
4
+ end
5
+
6
+ def down
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module PettanrPettanCommonsV01Licenses
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -53,21 +53,21 @@ module PettanrPettanCommonsV01Licenses
53
53
  super
54
54
  end
55
55
 
56
- def resource_picture_extend
57
- self.new_resource_picture unless @resource_picture_extend
58
- @resource_picture_extend ||= PettanrPettanCommonsV01Licenses::Attribute.new
56
+ def attribute_extend
57
+ self.new_attribute unless @attribute_extend
58
+ @attribute_extend ||= PettanrPettanCommonsV01Licenses::Attribute.new
59
59
  end
60
60
 
61
- def resource_picture_extend= params
61
+ def attribute_extend= params
62
62
  # load attributes
63
- @resource_picture_extend = PettanrPettanCommonsV01Licenses::Attribute.new params
63
+ @attribute_extend = PettanrPettanCommonsV01Licenses::Attribute.new params
64
64
  # no supply default params
65
65
  end
66
66
 
67
- def new_resource_picture params = {}
68
- @resource_picture_extend = PettanrPettanCommonsV01Licenses::Attribute.new params
67
+ def new_attribute params = {}
68
+ @attribute_extend = PettanrPettanCommonsV01Licenses::Attribute.new params
69
69
  # Attribute's supply_default need operators
70
- # @resource_picture_extend.supply_default operators
70
+ # @attribute_extend.supply_default operators
71
71
  end
72
72
 
73
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pettanr_pettan_commons_v01_licenses
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-09 00:00:00.000000000 Z
12
+ date: 2014-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -76,6 +76,7 @@ files:
76
76
  - db/migrate/20121008030508_create_pettanr_pettan_commons_v01_licenses_attributes.rb
77
77
  - db/migrate/20140401102950_create_pettanr_pettan_commons_v01_licenses_licenses.rb
78
78
  - db/migrate/20140401234553_create_pettanr_pettan_commons_v01_licenses_credit_pictures.rb
79
+ - db/migrate/20140414094025_fix_pettanr_pettan_commons_v01_licenses_attributes_system_picture_id.rb
79
80
  - db/PetaCommon_BY.png
80
81
  - db/PetaCommon_BY_NC.png
81
82
  - db/PetaCommon_BY_NC_ND.png