pettanr_unknown_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_unknown_v01_licenses/application_controller"
2
2
 
3
3
  module PettanrUnknownV01Licenses
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
@@ -24,7 +23,7 @@ module PettanrUnknownV01Licenses
24
23
  @unknown_license = PettanrUnknownV01Licenses::Attribute.new params[:unknown_license]
25
24
  @license = License.show @unknown_license.license_id, @operators
26
25
  @resource_picture = @original_picture.resource_picture || ResourcePicture.new
27
- @resource_picture.attributes = @unknown_license.resource_picture_attributes @original_picture
26
+ @resource_picture.attributes = @unknown_license.resource_picture_attributes @original_picture, @license
28
27
  @resource_picture.overwrite @original_picture
29
28
  respond_to do |format|
30
29
  if @unknown_license.valid?
@@ -2,18 +2,26 @@ module PettanrUnknownV01Licenses
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
+ :source_url => self.source_url,
23
+ :note => self.note
24
+ }.to_json
17
25
  }
18
26
  end
19
27
 
@@ -24,13 +32,5 @@ module PettanrUnknownV01Licenses
24
32
  [op, oplg, lg]
25
33
  end
26
34
 
27
- def credit
28
- {
29
- :system_picture_id => self.license.system_picture_id,
30
- :source_url => self.source_url,
31
- :note => self.note
32
- }.to_json.to_s
33
- end
34
-
35
35
  end
36
36
  end
@@ -7,9 +7,10 @@
7
7
  %>
8
8
  </td>
9
9
  <td>
10
+ <% picture.boosts 'post' %>
10
11
  <div class="md5">
11
12
  <% picture.license.boosts 'read' %>
12
- <% if picture.credit_data['source_url'].blank? %>
13
+ <% if picture.attribute_extend.source_url.blank? %>
13
14
  <% source_url_off_btn = SystemPicture.find(picture.license.credit_picture_extend.source_url_off_btn_id) %>
14
15
  <%=
15
16
  tag(:img, :src => source_url_off_btn.url, :alt => 'no source', :width => source_url_off_btn.width, :height => source_url_off_btn.height)
@@ -18,12 +19,12 @@
18
19
  <% source_url_btn = SystemPicture.find(picture.license.credit_picture_extend.source_url_btn_id) %>
19
20
  <%= link_to(
20
21
  tag(:img, :src => source_url_btn.url, :alt => 'source url', :width => source_url_btn.width, :height => source_url_btn.height),
21
- picture.credit_data['source_url'] )
22
+ picture.attribute_extend.source_url)
22
23
  %>
23
24
  <% end %>
24
25
  </div>
25
26
  <div class="md5">
26
- <%= h(truncate(picture.credit_data['note'], :length => 12)) %>
27
+ <%= h(truncate(picture.attribute_extend.note, :length => 12)) %>
27
28
  </div>
28
29
  </td>
29
30
  </tr>
@@ -23,14 +23,14 @@
23
23
  <tr>
24
24
  <td><%= t_m 'PettanrUnknownV01Licenses::Attribute.source_url' -%></td>
25
25
  <td>
26
- <% if picture.credit_data['source_url'].blank? %>
26
+ <% if picture.attribute_extend.source_url.blank? %>
27
27
  <% else %>
28
- <%= link_to(h(picture.credit_data['source_url']), picture.credit_data['source_url']) -%></td>
28
+ <%= link_to(h(picture.attribute_extend.source_url), picture.attribute_extend.source_url) -%></td>
29
29
  <% end %>
30
30
  </td>
31
31
  </tr>
32
32
  <tr>
33
33
  <td><%= t_m 'PettanrUnknownV01Licenses::Attribute.note' -%></td>
34
- <td><%= h picture.credit_data['note'] -%></td>
34
+ <td><%= h picture.attribute_extend.note -%></td>
35
35
  </tr>
36
36
  </table>
@@ -0,0 +1,8 @@
1
+ class FixPettanrUnknownV01LicensesAttributesSystemPictureId < ActiveRecord::Migration
2
+ def up
3
+ add_column :pettanr_unknown_v01_licenses_attributes, :system_picture_id, :integer, :null => false, :default => 0
4
+ end
5
+
6
+ def down
7
+ end
8
+ end
@@ -53,21 +53,21 @@ module PettanrUnknownV01Licenses
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 ||= PettanrUnknownV01Licenses::Attribute.new
56
+ def attribute_extend
57
+ self.new_attribute unless @attribute_extend
58
+ @attribute_extend ||= PettanrUnknownV01Licenses::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 = PettanrUnknownV01Licenses::Attribute.new params
63
+ @attribute_extend = PettanrUnknownV01Licenses::Attribute.new params
64
64
  # no supply default params
65
65
  end
66
66
 
67
- def new_resource_picture params = {}
68
- @resource_picture_extend = PettanrUnknownV01Licenses::Attribute.new params
67
+ def new_attribute params = {}
68
+ @attribute_extend = PettanrUnknownV01Licenses::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
@@ -1,3 +1,3 @@
1
1
  module PettanrUnknownV01Licenses
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pettanr_unknown_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
@@ -74,6 +74,7 @@ files:
74
74
  - db/migrate/20121007054509_create_pettanr_unknown_v01_licenses_attributes.rb
75
75
  - db/migrate/20140408085355_create_pettanr_unknown_v01_licenses_licenses.rb
76
76
  - db/migrate/20140408085413_create_pettanr_unknown_v01_licenses_credit_pictures.rb
77
+ - db/migrate/20140414094414_fix_pettanr_unknown_v01_licenses_attributes_system_picture_id.rb
77
78
  - db/pettanr_unknown_v01_license.json
78
79
  - db/pettanr_unknown_v01_license.yml
79
80
  - db/Unknown.png