decidim-proposals 0.26.1 → 0.26.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/commands/decidim/proposals/admin/answer_proposal.rb +7 -2
- data/app/commands/decidim/proposals/admin/create_proposal.rb +1 -1
- data/app/commands/decidim/proposals/admin/update_proposal.rb +1 -1
- data/app/commands/decidim/proposals/hashtags_methods.rb +1 -1
- data/app/events/decidim/proposals/collaborative_draft_withdrawn_event.rb +5 -1
- data/app/events/decidim/proposals/publish_proposal_event.rb +8 -0
- data/app/forms/decidim/proposals/admin/proposal_answer_form.rb +1 -1
- data/app/helpers/decidim/proposals/application_helper.rb +1 -1
- data/app/jobs/decidim/proposals/notify_proposals_mentioned_job.rb +1 -1
- data/app/models/decidim/proposals/proposal.rb +6 -0
- data/app/permissions/decidim/proposals/admin/permissions.rb +3 -0
- data/app/views/decidim/proposals/admin/proposal_answers/_form.html.erb +1 -1
- data/app/views/decidim/proposals/proposals/_proposal_similar.html.erb +1 -1
- data/config/locales/ar.yml +3 -13
- data/config/locales/bg.yml +0 -12
- data/config/locales/ca.yml +18 -14
- data/config/locales/cs.yml +33 -29
- data/config/locales/de.yml +45 -13
- data/config/locales/el.yml +0 -13
- data/config/locales/en.yml +17 -13
- data/config/locales/es-MX.yml +16 -12
- data/config/locales/es-PY.yml +16 -12
- data/config/locales/es.yml +17 -13
- data/config/locales/eu.yml +0 -13
- data/config/locales/fi-plain.yml +16 -12
- data/config/locales/fi.yml +17 -13
- data/config/locales/fr-CA.yml +16 -12
- data/config/locales/fr.yml +31 -27
- data/config/locales/gl.yml +0 -13
- data/config/locales/hu.yml +4 -13
- data/config/locales/id-ID.yml +0 -13
- data/config/locales/is-IS.yml +0 -1
- data/config/locales/it.yml +0 -13
- data/config/locales/ja.yml +51 -47
- data/config/locales/lt.yml +993 -0
- data/config/locales/lv.yml +0 -13
- data/config/locales/nl.yml +0 -13
- data/config/locales/no.yml +0 -13
- data/config/locales/oc-FR.yml +1 -0
- data/config/locales/pl.yml +0 -13
- data/config/locales/pt-BR.yml +0 -13
- data/config/locales/pt.yml +0 -13
- data/config/locales/ro-RO.yml +0 -13
- data/config/locales/ru.yml +0 -1
- data/config/locales/sk.yml +0 -13
- data/config/locales/sv.yml +3 -16
- data/config/locales/tr-TR.yml +0 -13
- data/config/locales/uk.yml +0 -1
- data/config/locales/zh-CN.yml +0 -12
- data/lib/decidim/content_parsers/proposal_parser.rb +7 -63
- data/lib/decidim/content_renderers/proposal_renderer.rb +3 -19
- data/lib/decidim/proposals/component.rb +8 -8
- data/lib/decidim/proposals/version.rb +1 -1
- metadata +19 -18
@@ -12,89 +12,33 @@ module Decidim
|
|
12
12
|
# Also fills a `Metadata#linked_proposals` attribute.
|
13
13
|
#
|
14
14
|
# @see BaseParser Examples of how to use a content parser
|
15
|
-
class ProposalParser <
|
15
|
+
class ProposalParser < ResourceParser
|
16
16
|
# Class used as a container for metadata
|
17
17
|
#
|
18
18
|
# @!attribute linked_proposals
|
19
19
|
# @return [Array] an array of Decidim::Proposals::Proposal mentioned in content
|
20
20
|
Metadata = Struct.new(:linked_proposals)
|
21
21
|
|
22
|
-
# Matches a URL
|
23
|
-
URL_REGEX_SCHEME = '(?:http(s)?:\/\/)'
|
24
|
-
URL_REGEX_CONTENT = '[\w.-]+[\w\-\._~:\/?#\[\]@!\$&\'\(\)\*\+,;=.]+'
|
25
|
-
URL_REGEX_END_CHAR = '[\d]'
|
26
|
-
URL_REGEX = %r{#{URL_REGEX_SCHEME}#{URL_REGEX_CONTENT}/proposals/#{URL_REGEX_END_CHAR}+}i.freeze
|
27
|
-
# Matches a mentioned Proposal ID (~(d)+ expression)
|
28
|
-
ID_REGEX = /~(\d+)/.freeze
|
29
|
-
|
30
22
|
def initialize(content, context)
|
31
23
|
super
|
32
24
|
@metadata = Metadata.new([])
|
33
25
|
end
|
34
26
|
|
35
|
-
# Replaces found mentions matching an existing
|
36
|
-
# Proposal with a global id for that Proposal. Other mentions found that doesn't
|
37
|
-
# match an existing Proposal are returned as they are.
|
38
|
-
#
|
39
|
-
# @return [String] the content with the valid mentions replaced by a global id.
|
40
|
-
def rewrite
|
41
|
-
rewrited_content = parse_for_urls(content)
|
42
|
-
parse_for_ids(rewrited_content)
|
43
|
-
end
|
44
|
-
|
45
27
|
# (see BaseParser#metadata)
|
46
28
|
attr_reader :metadata
|
47
29
|
|
48
30
|
private
|
49
31
|
|
50
|
-
def
|
51
|
-
|
52
|
-
proposal = proposal_from_url_match(match)
|
53
|
-
if proposal
|
54
|
-
@metadata.linked_proposals << proposal.id
|
55
|
-
proposal.to_global_id
|
56
|
-
else
|
57
|
-
match
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def parse_for_ids(content)
|
63
|
-
content.gsub(ID_REGEX) do |match|
|
64
|
-
proposal = proposal_from_id_match(Regexp.last_match(1))
|
65
|
-
if proposal
|
66
|
-
@metadata.linked_proposals << proposal.id
|
67
|
-
proposal.to_global_id
|
68
|
-
else
|
69
|
-
match
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def proposal_from_url_match(match)
|
75
|
-
uri = URI.parse(match)
|
76
|
-
return if uri.path.blank?
|
77
|
-
|
78
|
-
proposal_id = uri.path.split("/").last
|
79
|
-
find_proposal_by_id(proposal_id)
|
80
|
-
rescue URI::InvalidURIError
|
81
|
-
Rails.logger.error("#{e.message}=>#{e.backtrace}")
|
82
|
-
nil
|
32
|
+
def url_regex
|
33
|
+
%r{#{URL_REGEX_SCHEME}#{URL_REGEX_CONTENT}/proposals/#{URL_REGEX_END_CHAR}+}i
|
83
34
|
end
|
84
35
|
|
85
|
-
def
|
86
|
-
|
87
|
-
find_proposal_by_id(proposal_id)
|
36
|
+
def model_class
|
37
|
+
"Decidim::Proposals::Proposal"
|
88
38
|
end
|
89
39
|
|
90
|
-
def
|
91
|
-
|
92
|
-
spaces = Decidim.participatory_space_manifests.flat_map do |manifest|
|
93
|
-
manifest.participatory_spaces.call(context[:current_organization]).public_spaces
|
94
|
-
end
|
95
|
-
components = Component.where(participatory_space: spaces).published
|
96
|
-
Decidim::Proposals::Proposal.where(component: components).find_by(id: id)
|
97
|
-
end
|
40
|
+
def update_metadata(resource)
|
41
|
+
@metadata.linked_proposals << resource.id
|
98
42
|
end
|
99
43
|
end
|
100
44
|
end
|
@@ -8,25 +8,9 @@ module Decidim
|
|
8
8
|
# e.g. gid://<APP_NAME>/Decidim::Proposals::Proposal/1
|
9
9
|
#
|
10
10
|
# @see BaseRenderer Examples of how to use a content renderer
|
11
|
-
class ProposalRenderer <
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# Replaces found Global IDs matching an existing proposal with
|
16
|
-
# a link to its show page. The Global IDs representing an
|
17
|
-
# invalid Decidim::Proposals::Proposal are replaced with '???' string.
|
18
|
-
#
|
19
|
-
# @return [String] the content ready to display (contains HTML)
|
20
|
-
def render(_options = nil)
|
21
|
-
return content unless content.respond_to?(:gsub)
|
22
|
-
|
23
|
-
content.gsub(GLOBAL_ID_REGEX) do |proposal_gid|
|
24
|
-
proposal = GlobalID::Locator.locate(proposal_gid)
|
25
|
-
Decidim::Proposals::ProposalPresenter.new(proposal).display_mention
|
26
|
-
rescue ActiveRecord::RecordNotFound
|
27
|
-
proposal_id = proposal_gid.split("/").last
|
28
|
-
"~#{proposal_id}"
|
29
|
-
end
|
11
|
+
class ProposalRenderer < ResourceRenderer
|
12
|
+
def regex
|
13
|
+
%r{gid://([\w-]*/Decidim::Proposals::Proposal/(\d+))}i
|
30
14
|
end
|
31
15
|
end
|
32
16
|
end
|
@@ -66,11 +66,11 @@ Decidim.register_component(:proposals) do |component|
|
|
66
66
|
settings.attribute :votes_blocked, type: :boolean
|
67
67
|
settings.attribute :votes_hidden, type: :boolean, default: false
|
68
68
|
settings.attribute :comments_blocked, type: :boolean, default: false
|
69
|
-
settings.attribute :creation_enabled, type: :boolean
|
69
|
+
settings.attribute :creation_enabled, type: :boolean, readonly: ->(context) { context[:component].settings[:participatory_texts_enabled] }
|
70
70
|
settings.attribute :proposal_answering_enabled, type: :boolean, default: true
|
71
|
-
settings.attribute :default_sort_order, type: :select, include_blank: true, choices: -> { POSSIBLE_SORT_ORDERS }
|
72
71
|
settings.attribute :publish_answers_immediately, type: :boolean, default: true
|
73
72
|
settings.attribute :answers_with_costs, type: :boolean, default: false
|
73
|
+
settings.attribute :default_sort_order, type: :select, include_blank: true, choices: -> { POSSIBLE_SORT_ORDERS }
|
74
74
|
settings.attribute :amendment_creation_enabled, type: :boolean, default: true
|
75
75
|
settings.attribute :amendment_reaction_enabled, type: :boolean, default: true
|
76
76
|
settings.attribute :amendment_promotion_enabled, type: :boolean, default: true
|
@@ -284,8 +284,8 @@ Decidim.register_component(:proposals) do |component|
|
|
284
284
|
|
285
285
|
author = Decidim::User.find_or_initialize_by(email: email)
|
286
286
|
author.update!(
|
287
|
-
password: "
|
288
|
-
password_confirmation: "
|
287
|
+
password: "decidim123456",
|
288
|
+
password_confirmation: "decidim123456",
|
289
289
|
name: name,
|
290
290
|
nickname: Faker::Twitter.unique.screen_name,
|
291
291
|
organization: component.organization,
|
@@ -350,8 +350,8 @@ Decidim.register_component(:proposals) do |component|
|
|
350
350
|
|
351
351
|
author = Decidim::User.find_or_initialize_by(email: email)
|
352
352
|
author.update!(
|
353
|
-
password: "
|
354
|
-
password_confirmation: "
|
353
|
+
password: "decidim123456",
|
354
|
+
password_confirmation: "decidim123456",
|
355
355
|
name: name,
|
356
356
|
nickname: Faker::Twitter.unique.screen_name,
|
357
357
|
organization: component.organization,
|
@@ -372,8 +372,8 @@ Decidim.register_component(:proposals) do |component|
|
|
372
372
|
|
373
373
|
author = Decidim::User.find_or_initialize_by(email: email)
|
374
374
|
author.update!(
|
375
|
-
password: "
|
376
|
-
password_confirmation: "
|
375
|
+
password: "decidim123456",
|
376
|
+
password_confirmation: "decidim123456",
|
377
377
|
name: name,
|
378
378
|
nickname: Faker::Twitter.unique.screen_name,
|
379
379
|
organization: component.organization,
|
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.26.
|
4
|
+
version: 0.26.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-09-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: decidim-comments
|
@@ -18,28 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.26.
|
21
|
+
version: 0.26.3
|
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.26.
|
28
|
+
version: 0.26.3
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: decidim-core
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.26.
|
35
|
+
version: 0.26.3
|
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.26.
|
42
|
+
version: 0.26.3
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: doc2text
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,84 +80,84 @@ dependencies:
|
|
80
80
|
requirements:
|
81
81
|
- - '='
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 0.26.
|
83
|
+
version: 0.26.3
|
84
84
|
type: :development
|
85
85
|
prerelease: false
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - '='
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.26.
|
90
|
+
version: 0.26.3
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: decidim-assemblies
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - '='
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.26.
|
97
|
+
version: 0.26.3
|
98
98
|
type: :development
|
99
99
|
prerelease: false
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - '='
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0.26.
|
104
|
+
version: 0.26.3
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: decidim-budgets
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - '='
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: 0.26.
|
111
|
+
version: 0.26.3
|
112
112
|
type: :development
|
113
113
|
prerelease: false
|
114
114
|
version_requirements: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - '='
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: 0.26.
|
118
|
+
version: 0.26.3
|
119
119
|
- !ruby/object:Gem::Dependency
|
120
120
|
name: decidim-dev
|
121
121
|
requirement: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
123
|
- - '='
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.26.
|
125
|
+
version: 0.26.3
|
126
126
|
type: :development
|
127
127
|
prerelease: false
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
130
|
- - '='
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 0.26.
|
132
|
+
version: 0.26.3
|
133
133
|
- !ruby/object:Gem::Dependency
|
134
134
|
name: decidim-meetings
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - '='
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 0.26.
|
139
|
+
version: 0.26.3
|
140
140
|
type: :development
|
141
141
|
prerelease: false
|
142
142
|
version_requirements: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
144
|
- - '='
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: 0.26.
|
146
|
+
version: 0.26.3
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
148
|
name: decidim-participatory_processes
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
151
|
- - '='
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version: 0.26.
|
153
|
+
version: 0.26.3
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
156
|
version_requirements: !ruby/object:Gem::Requirement
|
157
157
|
requirements:
|
158
158
|
- - '='
|
159
159
|
- !ruby/object:Gem::Version
|
160
|
-
version: 0.26.
|
160
|
+
version: 0.26.3
|
161
161
|
description: A proposals component for decidim's participatory spaces.
|
162
162
|
email:
|
163
163
|
- josepjaume@gmail.com
|
@@ -496,6 +496,7 @@ files:
|
|
496
496
|
- config/locales/mt.yml
|
497
497
|
- config/locales/nl.yml
|
498
498
|
- config/locales/no.yml
|
499
|
+
- config/locales/oc-FR.yml
|
499
500
|
- config/locales/om-ET.yml
|
500
501
|
- config/locales/pl.yml
|
501
502
|
- config/locales/pt-BR.yml
|