pettanr_pettan_protected_v01_licenses 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/pettanr_pettan_protected_v01_licenses/attributes_controller.rb +19 -10
- data/app/models/pettanr_pettan_protected_v01_licenses/attribute.rb +26 -2
- data/app/views/pettanr_pettan_protected_v01_licenses/attributes/_credit.html.erb +9 -7
- data/app/views/pettanr_pettan_protected_v01_licenses/attributes/_form.html.erb +14 -20
- data/app/views/pettanr_pettan_protected_v01_licenses/attributes/_full_credit.html.erb +8 -6
- data/lib/pettanr_pettan_protected_v01_licenses.rb +8 -5
- data/lib/pettanr_pettan_protected_v01_licenses/version.rb +1 -1
- metadata +2 -4
- data/app/views/layouts/pettanr_pettan_protected_v01_licenses/application.html.erb +0 -14
- data/app/views/pettanr_pettan_protected_v01_licenses/attributes/new.js.erb +0 -1
@@ -5,28 +5,37 @@ module PettanrPettanProtectedV01Licenses
|
|
5
5
|
before_filter :authenticate_user, :only => [:new, :create]
|
6
6
|
before_filter :authenticate_artist, :only => [:new, :create]
|
7
7
|
|
8
|
+
def self.my_module
|
9
|
+
PettanrPettanProtectedV01Licenses
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.my_model
|
13
|
+
PettanrPettanProtectedV01Licenses::Attribute
|
14
|
+
end
|
15
|
+
|
8
16
|
def new
|
9
17
|
@original_picture, @original_picture_license_group, @license_group =
|
10
|
-
|
11
|
-
@
|
12
|
-
|
18
|
+
self.class.my_model.remember_params params, @operators
|
19
|
+
@attr = @license_group.my_engine.new_attribute {}
|
20
|
+
# rare case !
|
21
|
+
# Attribute need artist name by @operators
|
22
|
+
@attr.supply_default @operators
|
13
23
|
|
14
24
|
respond_to do |format|
|
15
|
-
format.html
|
16
|
-
# format.js
|
25
|
+
format.html
|
17
26
|
end
|
18
27
|
end
|
19
28
|
|
20
29
|
def create
|
21
30
|
@original_picture, @original_picture_license_group, @license_group =
|
22
|
-
|
23
|
-
@
|
24
|
-
@license = License.show @
|
31
|
+
self.class.my_model.remember_params params, @operators
|
32
|
+
@attr = self.class.my_module.new_attribute params[:attributes]
|
33
|
+
@license = License.show @attr.license_id, @operators
|
25
34
|
@resource_picture = @original_picture.resource_picture || ResourcePicture.new
|
26
|
-
@resource_picture.attributes = @
|
35
|
+
@resource_picture.attributes = @attr.resource_picture_attributes @original_picture, @license
|
27
36
|
@resource_picture.overwrite @original_picture
|
28
37
|
respond_to do |format|
|
29
|
-
if @
|
38
|
+
if @attr.valid?
|
30
39
|
format.html { render main_app.new_resource_picture_path }
|
31
40
|
format.json { render json: @resource_picture.to_json(ResourcePicture.show_json_opt), status: :created }
|
32
41
|
else
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module PettanrPettanProtectedV01Licenses
|
2
2
|
class Attribute < ActiveRecord::Base
|
3
|
-
belongs_to :license
|
4
3
|
|
5
4
|
validates :license_id, :presence => true, :numericality => true #, :existence => true
|
6
5
|
validates :artist_name, :presence => true
|
6
|
+
# validates :caption, :presence => true
|
7
|
+
# validates :sources, :presence => true
|
7
8
|
|
8
9
|
def supply_default operators
|
9
10
|
self.artist_name = operators.artist.name
|
@@ -14,11 +15,14 @@ module PettanrPettanProtectedV01Licenses
|
|
14
15
|
:original_picture_id => op.id,
|
15
16
|
:license_id => ls.id,
|
16
17
|
:artist_name => self.artist_name,
|
18
|
+
:system_picture_id => ls.system_picture_id,
|
17
19
|
:license_group_classname => ls.license_group_classname,
|
18
20
|
:license_group_settings => ls.license_group_settings,
|
19
21
|
:credit_picture_settings => ls.credit_picture_settings,
|
20
22
|
:license_settings => {
|
21
|
-
:
|
23
|
+
:license_id => ls.id,
|
24
|
+
# :system_picture_id => ls.system_picture_id, # no save
|
25
|
+
:artist_name => self.artist_name,
|
22
26
|
:caption => self.caption,
|
23
27
|
:sources => self.sources
|
24
28
|
}.to_json
|
@@ -32,5 +36,25 @@ module PettanrPettanProtectedV01Licenses
|
|
32
36
|
[op, oplg, lg]
|
33
37
|
end
|
34
38
|
|
39
|
+
def engine_name
|
40
|
+
"pettanr_pettan_protected_v01_licenses"
|
41
|
+
end
|
42
|
+
|
43
|
+
def form_name
|
44
|
+
self.engine_name + '/attributes'
|
45
|
+
end
|
46
|
+
|
47
|
+
def label_name field_name = nil
|
48
|
+
self.class.to_s + (field_name ? '.' + field_name : '')
|
49
|
+
end
|
50
|
+
|
51
|
+
def trans_name field_name = nil
|
52
|
+
self.engine_name + '.' + field_name
|
53
|
+
end
|
54
|
+
|
55
|
+
def tag_name field_name
|
56
|
+
'attributes[' + field_name + ']'
|
57
|
+
end
|
58
|
+
|
35
59
|
end
|
36
60
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
<table class="no-border">
|
2
2
|
<tr>
|
3
3
|
<td width="1px">
|
4
|
-
<%=
|
5
|
-
tag(:img, :src => picture.
|
6
|
-
picture.
|
4
|
+
<%= content_tag(:a,
|
5
|
+
tag(:img, :src => picture.system_picture.url,
|
6
|
+
:alt => h(picture.alt_name),
|
7
|
+
:width => picture.system_picture.width, :height => picture.system_picture.height),
|
8
|
+
:href => picture.license.url )
|
7
9
|
%>
|
8
10
|
</td>
|
9
11
|
<td>
|
@@ -15,13 +17,13 @@
|
|
15
17
|
<%= h(truncate(picture.attribute_extend.caption, :length => 12)) %>
|
16
18
|
</div>
|
17
19
|
<div class="md5">
|
18
|
-
<%
|
19
|
-
<% source_url_btn = SystemPicture.find(picture.license.credit_picture_extend.source_url_btn_id) %>
|
20
|
+
<% source_url_btn = picture.credit_picture_extend.source_url_btn %>
|
20
21
|
<% urls = picture.attribute_extend.sources.to_s.gsub(/\r/, '').split(/\n/) -%>
|
21
22
|
<% urls[0..2].compact.each do |url| -%>
|
22
23
|
<%= link_to(
|
23
|
-
tag(:img, :src => source_url_btn.url, :alt => 'source url',
|
24
|
-
|
24
|
+
tag(:img, :src => source_url_btn.url, :alt => 'source url',
|
25
|
+
:width => source_url_btn.width, :height => source_url_btn.height
|
26
|
+
), url )
|
25
27
|
%>
|
26
28
|
<% end -%>
|
27
29
|
<%= urls.size > 2 ? '...' : '' -%>
|
@@ -1,36 +1,30 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
@pettan_protected_license = PettanrPettanProtectedV01Licenses::Attribute.new
|
4
|
-
@pettan_protected_license.supply_default @operators
|
5
|
-
end
|
6
|
-
%>
|
7
|
-
<%= form_tag('/pettanr_pettan_protected_v01_licenses/attributes') do %>
|
8
|
-
<%= render 'system/error_explanation', :obj => @pettan_protected_license %>
|
1
|
+
<%= form_tag(@attr.form_name) do %>
|
2
|
+
<%= render 'system/error_explanation', :obj => @attr %>
|
9
3
|
|
10
4
|
<table class="no-border">
|
11
5
|
<tr>
|
12
6
|
<td><%= t_m 'LicenseGroup' -%></td>
|
13
|
-
<td><%= t_m
|
7
|
+
<td><%= t_m @attr.label_name -%></td>
|
14
8
|
<td><%= t('pettanr_pettan_protected_v01_licenses.selected') -%></td>
|
15
9
|
</tr>
|
16
10
|
<tr>
|
17
|
-
<td><%= t_m '
|
18
|
-
<td><%= collection_select :
|
19
|
-
<td><%= t('
|
11
|
+
<td><%= t_m @attr.label_name('license_id') -%></td>
|
12
|
+
<td><%= collection_select :attributes, :license_id, @license_group.licenses.map {|l| [l.caption, l.id] }, :last, :first -%></td>
|
13
|
+
<td><%= t(@attr.trans_name('no_blank')) -%></td>
|
20
14
|
</tr>
|
21
15
|
<tr>
|
22
|
-
<td><%= t_m '
|
23
|
-
<td><%= text_field_tag '
|
24
|
-
<td><%= t('
|
16
|
+
<td><%= t_m @attr.label_name('artist_name') -%></td>
|
17
|
+
<td><%= text_field_tag @attr.tag_name('artist_name'), @attr.artist_name -%></td>
|
18
|
+
<td><%= t(@attr.trans_name('no_blank')) -%></td>
|
25
19
|
</tr>
|
26
20
|
<tr>
|
27
|
-
<td><%= t_m '
|
28
|
-
<td><%= text_field_tag '
|
21
|
+
<td><%= t_m @attr.label_name('caption') -%></td>
|
22
|
+
<td><%= text_field_tag @attr.tag_name('caption'), @attr.caption -%></td>
|
29
23
|
<td></td>
|
30
24
|
</tr>
|
31
25
|
<tr>
|
32
|
-
<td><%= t_m '
|
33
|
-
<td><%= text_area_tag '
|
26
|
+
<td><%= t_m @attr.label_name('sources') -%></td>
|
27
|
+
<td><%= text_area_tag @attr.tag_name('sources'), @attr.sources -%></td>
|
34
28
|
<td></td>
|
35
29
|
</tr>
|
36
30
|
</table>
|
@@ -40,6 +34,6 @@
|
|
40
34
|
<%= hidden_field_tag 'original_picture_license_group[license_group_id]', @original_picture_license_group.license_group_id %>
|
41
35
|
|
42
36
|
<div class="actions">
|
43
|
-
<%= submit_tag
|
37
|
+
<%= submit_tag t(@attr.trans_name('next')) %>
|
44
38
|
</div>
|
45
39
|
<% end %>
|
@@ -2,7 +2,9 @@
|
|
2
2
|
<tr>
|
3
3
|
<td colspan="2">
|
4
4
|
<%= link_to(
|
5
|
-
tag(:img, :src => picture.license.system_picture.url,
|
5
|
+
tag(:img, :src => picture.license.system_picture.url,
|
6
|
+
:alt => h(picture.alt_name),
|
7
|
+
:width => picture.system_picture.width, :height => picture.system_picture.height),
|
6
8
|
picture.license.url )
|
7
9
|
%>
|
8
10
|
</td>
|
@@ -13,23 +15,23 @@
|
|
13
15
|
</td>
|
14
16
|
</tr>
|
15
17
|
<tr>
|
16
|
-
<td><%= t_m
|
18
|
+
<td><%= t_m picture.attribute_extend.label_name() -%></td>
|
17
19
|
<td><%= link_to(h(picture.license.license_group.caption), picture.license.license_group.url) -%></td>
|
18
20
|
</tr>
|
19
21
|
<tr>
|
20
|
-
<td><%= t_m '
|
22
|
+
<td><%= t_m picture.attribute_extend.label_name('license_id') -%></td>
|
21
23
|
<td><%= link_to(h(picture.license.caption), picture.license.url) -%></td>
|
22
24
|
</tr>
|
23
25
|
<tr>
|
24
|
-
<td><%= t_m '
|
26
|
+
<td><%= t_m picture.attribute_extend.label_name('artist_name') -%></td>
|
25
27
|
<td><%= h(picture.artist_name) -%></td>
|
26
28
|
</tr>
|
27
29
|
<tr>
|
28
|
-
<td><%= t_m '
|
30
|
+
<td><%= t_m picture.attribute_extend.label_name('caption') -%></td>
|
29
31
|
<td><%= h picture.attribute_extend.caption -%></td>
|
30
32
|
</tr>
|
31
33
|
<tr>
|
32
|
-
<td><%= t_m '
|
34
|
+
<td><%= t_m picture.attribute_extend.label_name('sources') -%></td>
|
33
35
|
<td>
|
34
36
|
<% picture.attribute_extend.sources.to_s.gsub(/\r/, '').split(/\n/).each do |url| -%>
|
35
37
|
<div><%= link_to(h(url), url) -%></div>
|
@@ -60,15 +60,18 @@ module PettanrPettanProtectedV01Licenses
|
|
60
60
|
|
61
61
|
def attribute_extend= params
|
62
62
|
# load attributes
|
63
|
-
@attribute_extend = PettanrPettanProtectedV01Licenses
|
63
|
+
@attribute_extend = PettanrPettanProtectedV01Licenses.new_attribute params
|
64
64
|
# no supply default params
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
end
|
68
|
+
|
69
|
+
module ModuleMethods
|
70
|
+
def new_attribute params = {}
|
71
|
+
PettanrPettanProtectedV01Licenses::Attribute.new params
|
71
72
|
end
|
72
73
|
|
73
74
|
end
|
75
|
+
|
76
|
+
extend ModuleMethods
|
74
77
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pettanr_pettan_protected_v01_licenses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
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-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -61,9 +61,7 @@ files:
|
|
61
61
|
- app/models/pettanr_pettan_protected_v01_licenses/attribute.rb
|
62
62
|
- app/models/pettanr_pettan_protected_v01_licenses/credit_picture.rb
|
63
63
|
- app/models/pettanr_pettan_protected_v01_licenses/license.rb
|
64
|
-
- app/views/layouts/pettanr_pettan_protected_v01_licenses/application.html.erb
|
65
64
|
- app/views/pettanr_pettan_protected_v01_licenses/attributes/new.html.erb
|
66
|
-
- app/views/pettanr_pettan_protected_v01_licenses/attributes/new.js.erb
|
67
65
|
- app/views/pettanr_pettan_protected_v01_licenses/attributes/_confirm.html.erb
|
68
66
|
- app/views/pettanr_pettan_protected_v01_licenses/attributes/_credit.html.erb
|
69
67
|
- app/views/pettanr_pettan_protected_v01_licenses/attributes/_form.html.erb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>PettanrPettanProtectedV01Licenses</title>
|
5
|
-
<%= stylesheet_link_tag "pettanr_pettan_protected_v01_licenses/application", :media => "all" %>
|
6
|
-
<%= javascript_include_tag "pettanr_pettan_protected_v01_licenses/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
@@ -1 +0,0 @@
|
|
1
|
-
$("#oplg").html("<%= escape_javascript(render('form')) -%>");
|