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.
- data/app/controllers/pettanr_pettan_commons_v01_licenses/attributes_controller.rb +2 -3
- data/app/models/pettanr_pettan_commons_v01_licenses/attribute.rb +13 -13
- data/app/views/pettanr_pettan_commons_v01_licenses/attributes/_credit.html.erb +3 -2
- data/app/views/pettanr_pettan_commons_v01_licenses/attributes/_full_credit.html.erb +2 -2
- data/db/migrate/20140414094025_fix_pettanr_pettan_commons_v01_licenses_attributes_system_picture_id.rb +8 -0
- data/lib/pettanr_pettan_commons_v01_licenses/version.rb +1 -1
- data/lib/pettanr_pettan_commons_v01_licenses.rb +8 -8
- metadata +3 -2
@@ -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
|
-
|
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
|
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,
|
15
|
-
:
|
16
|
-
:
|
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.
|
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.
|
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.
|
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.
|
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>
|
@@ -53,21 +53,21 @@ module PettanrPettanCommonsV01Licenses
|
|
53
53
|
super
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
self.
|
58
|
-
@
|
56
|
+
def attribute_extend
|
57
|
+
self.new_attribute unless @attribute_extend
|
58
|
+
@attribute_extend ||= PettanrPettanCommonsV01Licenses::Attribute.new
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
61
|
+
def attribute_extend= params
|
62
62
|
# load attributes
|
63
|
-
@
|
63
|
+
@attribute_extend = PettanrPettanCommonsV01Licenses::Attribute.new params
|
64
64
|
# no supply default params
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
68
|
-
@
|
67
|
+
def new_attribute params = {}
|
68
|
+
@attribute_extend = PettanrPettanCommonsV01Licenses::Attribute.new params
|
69
69
|
# Attribute's supply_default need operators
|
70
|
-
# @
|
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
|
+
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-
|
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
|