decidim-proposals 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/forms/decidim/proposals/admin/proposal_form.rb +6 -0
- data/app/forms/decidim/proposals/proposal_form.rb +6 -0
- data/app/models/decidim/proposals/proposal.rb +9 -1
- data/app/views/decidim/proposals/admin/proposals/index.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/_tags.html.erb +2 -2
- data/lib/decidim/proposals/feature.rb +59 -65
- data/lib/decidim/proposals/proposal_serializer.rb +1 -15
- metadata +27 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f5ede39ced3c1e0de38bf979f3a1ef578c6a88d
|
4
|
+
data.tar.gz: 70f31bf53bdcf9808b17924a7873c8a1ba73d913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40a1c20970581db8bf5849b7e1080b1951bb03edc5a8b1c9a2c2cea9b4668563b806645d69788cfd28f678064a461a3affec496a719678ba733b09c65b6e5d18
|
7
|
+
data.tar.gz: 6f6078e4b9a93ed927f510291aaeb84d0543e0b2272232e253785dcc243e48f9aee61c76268128a0fb12606710f89f8a0b95fa26e525ba9e1c7fbb423408769a
|
@@ -22,6 +22,12 @@ module Decidim
|
|
22
22
|
|
23
23
|
delegate :categories, to: :current_feature, prefix: false
|
24
24
|
|
25
|
+
def map_model(model)
|
26
|
+
return unless model.categorization
|
27
|
+
|
28
|
+
self.category_id = model.categorization.decidim_category_id
|
29
|
+
end
|
30
|
+
|
25
31
|
def organization_scopes
|
26
32
|
current_organization.scopes
|
27
33
|
end
|
@@ -26,6 +26,12 @@ module Decidim
|
|
26
26
|
|
27
27
|
delegate :categories, to: :current_feature
|
28
28
|
|
29
|
+
def map_model(model)
|
30
|
+
return unless model.categorization
|
31
|
+
|
32
|
+
self.category_id = model.categorization.decidim_category_id
|
33
|
+
end
|
34
|
+
|
29
35
|
def organization_scopes
|
30
36
|
current_organization.scopes
|
31
37
|
end
|
@@ -33,7 +33,8 @@ module Decidim
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def author_name
|
36
|
-
|
36
|
+
return I18n.t("decidim.proposals.models.proposal.fields.official_proposal") if official?
|
37
|
+
user_group&.name || author.name
|
37
38
|
end
|
38
39
|
|
39
40
|
def author_avatar_url
|
@@ -100,15 +101,22 @@ module Decidim
|
|
100
101
|
ResourceLocatorPresenter.new(self).url
|
101
102
|
end
|
102
103
|
|
104
|
+
# Public: Whether the proposal is official or not.
|
105
|
+
def official?
|
106
|
+
author.nil?
|
107
|
+
end
|
108
|
+
|
103
109
|
# Public: Overrides the `notifiable?` Notifiable concern method.
|
104
110
|
# When a proposal is commented the proposal's author is notified if it is not the same
|
105
111
|
# who has commented the proposal and if the proposal's author has comment notifications enabled.
|
106
112
|
def notifiable?(context)
|
113
|
+
return true if official?
|
107
114
|
context[:author] != author && author.comments_notifications?
|
108
115
|
end
|
109
116
|
|
110
117
|
# Public: Overrides the `users_to_notify` Notifiable concern method.
|
111
118
|
def users_to_notify
|
119
|
+
return Decidim::Admin::ProcessAdmins.for(feature.participatory_process) if official?
|
112
120
|
[author]
|
113
121
|
end
|
114
122
|
end
|
@@ -53,7 +53,7 @@
|
|
53
53
|
<% if can? :update, proposal %>
|
54
54
|
<%= icon_link_to "chat", edit_proposal_proposal_answer_path(proposal_id: proposal.id, id: proposal.id), t("actions.answer", scope: "decidim.proposals"), class: "action-icon--edit-answer" %>
|
55
55
|
<% end %>
|
56
|
-
<%= icon_link_to "eye",
|
56
|
+
<%= icon_link_to "eye", resource_locator(proposal).path, t("actions.preview", scope: "decidim.proposals.admin"), class: "action-icon--preview", target: :blank %>
|
57
57
|
</td>
|
58
58
|
</tr>
|
59
59
|
<% end %>
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<% if proposal.category.present? || proposal.scope.present? %>
|
2
2
|
<ul class="tags tags--proposal" >
|
3
3
|
<% if proposal.category.present? %>
|
4
|
-
<li><%= link_to translated_attribute(proposal.category.name),
|
4
|
+
<li><%= link_to translated_attribute(proposal.category.name), resource_locator(proposal).index(filter: { category_id: proposal.category.id }) %></li>
|
5
5
|
<% end %>
|
6
6
|
<% if proposal.scope.present? && !current_participatory_process.scope %>
|
7
|
-
<li><%= link_to proposal.scope.name,
|
7
|
+
<li><%= link_to proposal.scope.name, resource_locator(proposal).index(filter: { scope_id: [proposal.scope.id] }) %></li>
|
8
8
|
<% end %>
|
9
9
|
</ul>
|
10
10
|
<% end %>
|
@@ -71,75 +71,69 @@ Decidim.register_feature(:proposals) do |feature|
|
|
71
71
|
exports.serializer Decidim::Comments::CommentSerializer
|
72
72
|
end
|
73
73
|
|
74
|
-
feature.seeds do
|
75
|
-
Decidim::
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
74
|
+
feature.seeds do |process|
|
75
|
+
feature = Decidim::Feature.create!(
|
76
|
+
name: Decidim::Features::Namer.new(process.organization.available_locales, :proposals).i18n_name,
|
77
|
+
manifest_name: :proposals,
|
78
|
+
published_at: Time.current,
|
79
|
+
participatory_process: process,
|
80
|
+
settings: {
|
81
|
+
vote_limit: 0
|
82
|
+
},
|
83
|
+
step_settings: {
|
84
|
+
process.active_step.id => { votes_enabled: true, votes_blocked: false, creation_enabled: true }
|
85
|
+
}
|
86
|
+
)
|
87
|
+
# So that we have some with global scope
|
88
|
+
scopes = feature.organization.scopes + [nil]
|
89
|
+
|
90
|
+
20.times do |n|
|
91
|
+
author = Decidim::User.where(organization: feature.organization).all.sample
|
92
|
+
user_group = [true, false].sample ? author.user_groups.verified.sample : nil
|
93
|
+
state, answer = if n > 15
|
94
|
+
["accepted", Decidim::Faker::Localized.sentence(10)]
|
95
|
+
elsif n > 9
|
96
|
+
["rejected", nil]
|
97
|
+
elsif n > 6
|
98
|
+
["evaluating", nil]
|
99
|
+
else
|
100
|
+
[nil, nil]
|
101
|
+
end
|
102
|
+
|
103
|
+
proposal = Decidim::Proposals::Proposal.create!(
|
104
|
+
feature: feature,
|
105
|
+
category: process.categories.sample,
|
106
|
+
scope: scopes.sample,
|
107
|
+
title: Faker::Lorem.sentence(2),
|
108
|
+
body: Faker::Lorem.paragraphs(2).join("\n"),
|
109
|
+
author: author,
|
110
|
+
user_group: user_group,
|
111
|
+
state: state,
|
112
|
+
answer: answer,
|
113
|
+
answered_at: Time.current
|
89
114
|
)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
author = Decidim::User.
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
user_group: user_group
|
115
|
+
|
116
|
+
rand(3).times do |m|
|
117
|
+
email = "vote-author-#{process.id}-#{n}-#{m}@example.org"
|
118
|
+
name = "#{Faker::Name.name} #{process.id} #{n} #{m}"
|
119
|
+
|
120
|
+
author = Decidim::User.find_or_initialize_by(email: email)
|
121
|
+
author.update!(
|
122
|
+
password: "password1234",
|
123
|
+
password_confirmation: "password1234",
|
124
|
+
name: name,
|
125
|
+
organization: feature.organization,
|
126
|
+
tos_agreement: "1",
|
127
|
+
confirmed_at: Time.current,
|
128
|
+
comments_notifications: true,
|
129
|
+
replies_notifications: true
|
106
130
|
)
|
107
131
|
|
108
|
-
|
109
|
-
|
110
|
-
proposal.answered_at = Time.current
|
111
|
-
proposal.save!
|
112
|
-
elsif n > 9
|
113
|
-
proposal.state = "rejected"
|
114
|
-
proposal.answered_at = Time.current
|
115
|
-
proposal.answer = Decidim::Faker::Localized.sentence(10)
|
116
|
-
proposal.save!
|
117
|
-
elsif n > 6
|
118
|
-
proposal.state = "evaluating"
|
119
|
-
proposal.answered_at = Time.current
|
120
|
-
proposal.save!
|
121
|
-
end
|
122
|
-
|
123
|
-
rand(3).times do |m|
|
124
|
-
email = "vote-author-#{process.id}-#{n}-#{m}@example.org"
|
125
|
-
name = "#{Faker::Name.name} #{process.id} #{n} #{m}"
|
126
|
-
|
127
|
-
author = Decidim::User.create!(email: email,
|
128
|
-
password: "password1234",
|
129
|
-
password_confirmation: "password1234",
|
130
|
-
name: name,
|
131
|
-
organization: feature.organization,
|
132
|
-
tos_agreement: "1",
|
133
|
-
confirmed_at: Time.current,
|
134
|
-
comments_notifications: true,
|
135
|
-
replies_notifications: true)
|
136
|
-
|
137
|
-
Decidim::Proposals::ProposalVote.create!(proposal: proposal,
|
138
|
-
author: author)
|
139
|
-
end
|
140
|
-
|
141
|
-
Decidim::Comments::Seed.comments_for(proposal)
|
132
|
+
Decidim::Proposals::ProposalVote.create!(proposal: proposal,
|
133
|
+
author: author)
|
142
134
|
end
|
135
|
+
|
136
|
+
Decidim::Comments::Seed.comments_for(proposal)
|
143
137
|
end
|
144
138
|
end
|
145
139
|
end
|
@@ -5,7 +5,6 @@ module Decidim
|
|
5
5
|
# This class serializes a Proposal so can be exported to CSV, JSON or other
|
6
6
|
# formats.
|
7
7
|
class ProposalSerializer < Decidim::Exporters::Serializer
|
8
|
-
include Rails.application.routes.url_helpers
|
9
8
|
include Decidim::ResourceHelper
|
10
9
|
|
11
10
|
# Public: Initializes the serializer with a proposal.
|
@@ -44,27 +43,14 @@ module Decidim
|
|
44
43
|
proposal.feature
|
45
44
|
end
|
46
45
|
|
47
|
-
def organization
|
48
|
-
feature.organization
|
49
|
-
end
|
50
|
-
|
51
46
|
def meetings
|
52
47
|
@proposal.linked_resources(:meetings, "proposals_from_meeting").map do |meeting|
|
53
48
|
Decidim::ResourceLocatorPresenter.new(meeting).url
|
54
49
|
end
|
55
50
|
end
|
56
51
|
|
57
|
-
def participatory_process
|
58
|
-
feature.participatory_process
|
59
|
-
end
|
60
|
-
|
61
52
|
def url
|
62
|
-
Decidim::
|
63
|
-
proposal,
|
64
|
-
feature_id: feature,
|
65
|
-
participatory_process_id: participatory_process,
|
66
|
-
host: organization.host
|
67
|
-
)
|
53
|
+
Decidim::ResourceLocatorPresenter.new(proposal).url
|
68
54
|
end
|
69
55
|
end
|
70
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-proposals
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -18,28 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.4.
|
21
|
+
version: 0.4.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.4.
|
28
|
+
version: 0.4.4
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: decidim-comments
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.4.
|
35
|
+
version: 0.4.4
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.4.
|
42
|
+
version: 0.4.4
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rectify
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,56 +88,70 @@ dependencies:
|
|
88
88
|
requirements:
|
89
89
|
- - '='
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: 0.4.
|
91
|
+
version: 0.4.4
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
96
|
- - '='
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0.4.
|
98
|
+
version: 0.4.4
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: decidim-admin
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 0.4.4
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 0.4.4
|
99
113
|
- !ruby/object:Gem::Dependency
|
100
114
|
name: decidim-meetings
|
101
115
|
requirement: !ruby/object:Gem::Requirement
|
102
116
|
requirements:
|
103
117
|
- - '='
|
104
118
|
- !ruby/object:Gem::Version
|
105
|
-
version: 0.4.
|
119
|
+
version: 0.4.4
|
106
120
|
type: :development
|
107
121
|
prerelease: false
|
108
122
|
version_requirements: !ruby/object:Gem::Requirement
|
109
123
|
requirements:
|
110
124
|
- - '='
|
111
125
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.4.
|
126
|
+
version: 0.4.4
|
113
127
|
- !ruby/object:Gem::Dependency
|
114
128
|
name: decidim-results
|
115
129
|
requirement: !ruby/object:Gem::Requirement
|
116
130
|
requirements:
|
117
131
|
- - '='
|
118
132
|
- !ruby/object:Gem::Version
|
119
|
-
version: 0.4.
|
133
|
+
version: 0.4.4
|
120
134
|
type: :development
|
121
135
|
prerelease: false
|
122
136
|
version_requirements: !ruby/object:Gem::Requirement
|
123
137
|
requirements:
|
124
138
|
- - '='
|
125
139
|
- !ruby/object:Gem::Version
|
126
|
-
version: 0.4.
|
140
|
+
version: 0.4.4
|
127
141
|
- !ruby/object:Gem::Dependency
|
128
142
|
name: decidim-budgets
|
129
143
|
requirement: !ruby/object:Gem::Requirement
|
130
144
|
requirements:
|
131
145
|
- - '='
|
132
146
|
- !ruby/object:Gem::Version
|
133
|
-
version: 0.4.
|
147
|
+
version: 0.4.4
|
134
148
|
type: :development
|
135
149
|
prerelease: false
|
136
150
|
version_requirements: !ruby/object:Gem::Requirement
|
137
151
|
requirements:
|
138
152
|
- - '='
|
139
153
|
- !ruby/object:Gem::Version
|
140
|
-
version: 0.4.
|
154
|
+
version: 0.4.4
|
141
155
|
description: A proposals component for decidim's participatory processes.
|
142
156
|
email:
|
143
157
|
- josepjaume@gmail.com
|