decidim-sortitions 0.11.2 → 0.12.0.pre
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/cells/decidim/sortitions/sortition_cell.rb +21 -0
- data/app/cells/decidim/sortitions/sortition_m/data.erb +15 -0
- data/app/cells/decidim/sortitions/sortition_m/footer.erb +13 -0
- data/app/cells/decidim/sortitions/sortition_m_cell.rb +53 -0
- data/app/controllers/decidim/sortitions/admin/sortitions_controller.rb +13 -11
- data/app/models/decidim/sortitions/sortition.rb +1 -1
- data/app/permissions/decidim/sortitions/admin/permissions.rb +34 -0
- data/app/permissions/decidim/sortitions/permissions.rb +15 -0
- data/app/views/decidim/sortitions/admin/sortitions/index.html.erb +4 -4
- data/app/views/decidim/sortitions/sortitions/_linked_sortitions.html.erb +0 -1
- data/app/views/decidim/sortitions/sortitions/_proposal.html.erb +1 -24
- data/app/views/decidim/sortitions/sortitions/_sortition.html.erb +1 -25
- data/app/views/decidim/sortitions/sortitions/show.html.erb +1 -1
- data/config/locales/ca.yml +15 -9
- data/config/locales/en.yml +17 -11
- data/config/locales/es.yml +16 -10
- data/config/locales/eu.yml +16 -10
- data/config/locales/fi.yml +16 -10
- data/config/locales/fr.yml +16 -10
- data/config/locales/gl.yml +15 -9
- data/config/locales/it.yml +16 -10
- data/config/locales/nl.yml +15 -9
- data/config/locales/pl.yml +19 -11
- data/config/locales/pt-BR.yml +16 -10
- data/config/locales/pt.yml +16 -10
- data/config/locales/ru.yml +53 -0
- data/config/locales/sv.yml +16 -10
- data/config/locales/uk.yml +24 -17
- data/lib/decidim/sortitions/admin_engine.rb +0 -9
- data/lib/decidim/sortitions/component.rb +3 -1
- data/lib/decidim/sortitions/engine.rb +5 -0
- data/lib/decidim/sortitions/version.rb +1 -1
- metadata +20 -16
- data/app/models/decidim/sortitions/abilities/admin/admin_ability.rb +0 -23
- data/app/models/decidim/sortitions/abilities/admin/process_admin_ability.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2072e34e4976e77facfc3467d970c431218b6b6f7cc61d0cbdabc63b6a1bc0d2
|
4
|
+
data.tar.gz: 3a18c0e5d4ee513109409fc85f4cd38092f81e1ef73f1f6d056034b202ed0f07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 217933b8292b8ea8be3b600ee059dbbab9a11e05cce58377ae0fd5135097fe900aee6b1c3f7a97cff7c18b4eede4852053feb22aaaeadb1a60f7b14c9a238d02
|
7
|
+
data.tar.gz: cc3eb7c079941f66df0e3ef077a59678120bbb44280236bd78a2108cd2daf11675b6a0b910fa36b552d6173f4dbbbf0edf9e63452f510dbcc2ce1f6fccc35b74
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cell/partial"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Sortitions
|
7
|
+
# This cell renders the card for an instance of a Sortition
|
8
|
+
# the default size is the Medium Card (:m)
|
9
|
+
class SortitionCell < Decidim::ViewModel
|
10
|
+
def show
|
11
|
+
cell card_size, model, @options
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def card_size
|
17
|
+
"decidim/sortitions/sortition_m"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<div class="card__icondata">
|
2
|
+
<ul class="card-data">
|
3
|
+
<li class="card-data__item">
|
4
|
+
<%= icon "random-seed", class: "icon--big" %>
|
5
|
+
</li>
|
6
|
+
<li class="card-data__item">
|
7
|
+
<div class="text-left text-uppercase">
|
8
|
+
<strong class="heading4">
|
9
|
+
<%= model.seed %>
|
10
|
+
</strong>
|
11
|
+
<small><%= t("decidim.sortitions.sortitions.sortition.random_seed") %></small>
|
12
|
+
</div>
|
13
|
+
</li>
|
14
|
+
</ul>
|
15
|
+
</div>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="card__footer">
|
2
|
+
<div class="card__support">
|
3
|
+
<div class="text-uppercase">
|
4
|
+
<strong class="text-large">
|
5
|
+
<%= proposals_count %>
|
6
|
+
</strong>
|
7
|
+
<small class="text-medium">
|
8
|
+
<%= t("decidim.sortitions.sortitions.sortition.selected_proposals", count: proposals_count) %>
|
9
|
+
</small>
|
10
|
+
</div>
|
11
|
+
<%= link_to t("decidim.sortitions.sortitions.sortition.view"), resource_path, class: "card__button button--sc button small secondary light" %>
|
12
|
+
</div>
|
13
|
+
</div>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cell/partial"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Sortitions
|
7
|
+
# This cell renders a sortition with its M-size card.
|
8
|
+
class SortitionMCell < Decidim::CardMCell
|
9
|
+
include Decidim::Sortitions::Engine.routes.url_helpers
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def has_author?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def has_state?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
# Even though we need to render the badge, we can't do it in the normal
|
22
|
+
# way, because the paragraph comes from a user input and contains HTML.
|
23
|
+
# This causes the badge and the paragraph to appear in different lines.
|
24
|
+
# In order to fix it, check the `description` method.
|
25
|
+
def has_badge?
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
def badge_name
|
30
|
+
return t("filters.cancelled", scope: "decidim.sortitions.sortitions") if model.cancelled?
|
31
|
+
t("filters.active", scope: "decidim.sortitions.sortitions")
|
32
|
+
end
|
33
|
+
|
34
|
+
def state_classes
|
35
|
+
return ["muted"] if model.cancelled?
|
36
|
+
["success"]
|
37
|
+
end
|
38
|
+
|
39
|
+
def proposals_count
|
40
|
+
@proposals_count = model.proposals.count
|
41
|
+
end
|
42
|
+
|
43
|
+
# In order to render the badge inline with the paragraph text we need to
|
44
|
+
# find the opening `<p>` tag and include the badge right after it. This
|
45
|
+
# makes the layout look good.
|
46
|
+
def description
|
47
|
+
text = decidim_sanitize(translated_attribute(model.additional_info))
|
48
|
+
text.gsub!(/^<p>/, "<p>#{render :badge}")
|
49
|
+
html_truncate(text, length: 100)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -11,16 +11,18 @@ module Decidim
|
|
11
11
|
def index; end
|
12
12
|
|
13
13
|
def show
|
14
|
-
|
14
|
+
enforce_permission_to :read, :sortition, sortition: sortition
|
15
15
|
end
|
16
16
|
|
17
17
|
def edit
|
18
|
-
|
18
|
+
enforce_permission_to :update, :sortition, sortition: sortition
|
19
|
+
|
19
20
|
@form = edit_sortition_form.from_model(sortition, current_participatory_space: current_participatory_space)
|
20
21
|
end
|
21
22
|
|
22
23
|
def update
|
23
|
-
|
24
|
+
enforce_permission_to :update, :sortition, sortition: sortition
|
25
|
+
|
24
26
|
@form = edit_sortition_form.from_params(params, current_participatory_space: current_participatory_space)
|
25
27
|
UpdateSortition.call(@form) do
|
26
28
|
on(:ok) do |_sortition|
|
@@ -36,12 +38,14 @@ module Decidim
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def new
|
39
|
-
|
41
|
+
enforce_permission_to :create, :sortition
|
42
|
+
|
40
43
|
@form = sortition_form.instance(current_participatory_space: current_participatory_space)
|
41
44
|
end
|
42
45
|
|
43
46
|
def create
|
44
|
-
|
47
|
+
enforce_permission_to :create, :sortition
|
48
|
+
|
45
49
|
@form = sortition_form.from_params(params, current_participatory_space: current_participatory_space)
|
46
50
|
CreateSortition.call(@form) do
|
47
51
|
on(:ok) do |sortition|
|
@@ -57,12 +61,14 @@ module Decidim
|
|
57
61
|
end
|
58
62
|
|
59
63
|
def confirm_destroy
|
60
|
-
|
64
|
+
enforce_permission_to :destroy, :sortition, sortition: sortition
|
65
|
+
|
61
66
|
@form = destroy_sortition_form.from_model(sortition, current_participatory_space: current_participatory_space)
|
62
67
|
end
|
63
68
|
|
64
69
|
def destroy
|
65
|
-
|
70
|
+
enforce_permission_to :destroy, :sortition, sortition: sortition
|
71
|
+
|
66
72
|
@form = destroy_sortition_form.from_params(params, current_participatory_space: current_participatory_space)
|
67
73
|
DestroySortition.call(@form) do
|
68
74
|
on(:ok) do |_sortition|
|
@@ -94,10 +100,6 @@ module Decidim
|
|
94
100
|
def proposal_components
|
95
101
|
ParticipatorySpaceProposalComponents.for(current_participatory_space)
|
96
102
|
end
|
97
|
-
|
98
|
-
def ability_context
|
99
|
-
super.merge(current_participatory_space: current_participatory_space)
|
100
|
-
end
|
101
103
|
end
|
102
104
|
end
|
103
105
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Sortitions
|
5
|
+
module Admin
|
6
|
+
class Permissions < Decidim::DefaultPermissions
|
7
|
+
def permissions
|
8
|
+
return permission_action unless user
|
9
|
+
|
10
|
+
return permission_action if permission_action.scope != :admin
|
11
|
+
|
12
|
+
return permission_action if permission_action.subject != :sortition
|
13
|
+
|
14
|
+
case permission_action.action
|
15
|
+
when :destroy
|
16
|
+
permission_action.allow! if sortition.present? && !sortition.cancelled?
|
17
|
+
when :update
|
18
|
+
permission_action.allow! if sortition.present?
|
19
|
+
when :create, :read
|
20
|
+
permission_action.allow!
|
21
|
+
end
|
22
|
+
|
23
|
+
permission_action
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def sortition
|
29
|
+
@sortition ||= context.fetch(:sortition, nil)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Sortitions
|
5
|
+
class Permissions < Decidim::DefaultPermissions
|
6
|
+
def permissions
|
7
|
+
return permission_action unless user
|
8
|
+
|
9
|
+
return Decidim::Sortitions::Admin::Permissions.new(user, permission_action, context).permissions if permission_action.scope == :admin
|
10
|
+
|
11
|
+
permission_action
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
<h2 class="card-title">
|
4
4
|
<%= t(".title") %>
|
5
5
|
<div class="button--title">
|
6
|
-
<% if
|
7
|
-
<%= link_to t("actions.new", scope: "decidim.sortitions.admin", name: t("models.sortition.name", scope: "decidim.sortitions.admin")), new_sortition_path, class: "button tiny button--simple"
|
6
|
+
<% if allowed_to? :create, :sortition %>
|
7
|
+
<%= link_to t("actions.new", scope: "decidim.sortitions.admin", name: t("models.sortition.name", scope: "decidim.sortitions.admin")), new_sortition_path, class: "button tiny button--simple" %>
|
8
8
|
<% end %>
|
9
9
|
</div>
|
10
10
|
</h2>
|
@@ -33,14 +33,14 @@
|
|
33
33
|
t("actions.show", scope: "decidim.sortitions.admin"),
|
34
34
|
class: "action-icon--preview" %>
|
35
35
|
|
36
|
-
<% if
|
36
|
+
<% if allowed_to? :update, :sortition, sortition: sortition %>
|
37
37
|
<%= icon_link_to "pencil",
|
38
38
|
edit_sortition_path(sortition),
|
39
39
|
t("actions.edit", scope: "decidim.sortitions.admin"),
|
40
40
|
class: "action-icon--edit" %>
|
41
41
|
<% end %>
|
42
42
|
|
43
|
-
<% if
|
43
|
+
<% if allowed_to? :destroy, :sortition, sortition: sortition %>
|
44
44
|
<%= icon_link_to "circle-x",
|
45
45
|
confirm_destroy_sortition_path(sortition),
|
46
46
|
t("actions.destroy", scope: "decidim.sortitions.admin"),
|
@@ -1,24 +1 @@
|
|
1
|
-
|
2
|
-
<article class="card card--proposal">
|
3
|
-
<div class="card__content">
|
4
|
-
<div class="card__header">
|
5
|
-
<%= link_to proposal_path(proposal) do %>
|
6
|
-
<h5 class="card__title"><%= proposal.title %></h5>
|
7
|
-
<% end %>
|
8
|
-
<div class="card__author author-data author-data--small">
|
9
|
-
<%= render partial: "decidim/shared/author_reference", locals: { author: present(proposal).author } %>
|
10
|
-
</div>
|
11
|
-
<%= resource_reference(proposal, class: "reference--text-left") %>
|
12
|
-
</div>
|
13
|
-
<%= render partial: "proposal_badge", locals: { proposal: proposal } %>
|
14
|
-
<p><%= truncate(proposal.body, length: 100) %></p>
|
15
|
-
<%= render partial: "decidim/shared/tags", locals: { resource: proposal, tags_class_extra: "tags--proposal" } %>
|
16
|
-
</div>
|
17
|
-
<div class="card__footer">
|
18
|
-
<div class="card__support">
|
19
|
-
<div class="card__support__data"></div>
|
20
|
-
<%= link_to t(".view_proposal"), proposal_path(proposal), class: "card__button button small secondary" %>
|
21
|
-
</div>
|
22
|
-
</div>
|
23
|
-
</article>
|
24
|
-
</div>
|
1
|
+
<%= card_for proposal %>
|
@@ -1,25 +1 @@
|
|
1
|
-
|
2
|
-
<article class="card card--sortition">
|
3
|
-
<div class="card__content">
|
4
|
-
<div class="card__header">
|
5
|
-
<%= link_to sortition do %>
|
6
|
-
<h5 class="card__title"><%= translated_attribute sortition.title %></h5>
|
7
|
-
<% end %>
|
8
|
-
<div class="card__author author-data author-data--small">
|
9
|
-
<%= render partial: "sortition_author", locals: { sortition: sortition } %>
|
10
|
-
</div>
|
11
|
-
<%= resource_reference(sortition, class: "reference--text-left") %>
|
12
|
-
</div>
|
13
|
-
<p class="card__desc">
|
14
|
-
<%= decidim_sanitize html_truncate(translated_attribute(sortition.additional_info), length: 100, separator: "...") %>
|
15
|
-
</p>
|
16
|
-
<%= render partial: "tags", locals: { sortition: sortition } %>
|
17
|
-
</div>
|
18
|
-
<div class="card__footer">
|
19
|
-
<div class="card__support">
|
20
|
-
<div class="card__support__data"><%= t ".selected_proposals", count: sortition.selected_proposals.count %></div>
|
21
|
-
<%= link_to t(".view_sortition"), sortition, class: "card__button button small secondary" %>
|
22
|
-
</div>
|
23
|
-
</div>
|
24
|
-
</article>
|
25
|
-
</div>
|
1
|
+
<%= card_for sortition %>
|
@@ -70,7 +70,7 @@
|
|
70
70
|
</div>
|
71
71
|
<div class="row">
|
72
72
|
<div id="proposals" class="columns mediumlarge-12 large-12">
|
73
|
-
<div class="row small-up-1 medium-up-2 card-grid">
|
73
|
+
<div class="row small-up-1 medium-up-2 large-up-3 card-grid">
|
74
74
|
<%= render partial: "proposal", collection: sortition.proposals %>
|
75
75
|
</div>
|
76
76
|
</div>
|
data/config/locales/ca.yml
CHANGED
@@ -5,10 +5,17 @@ ca:
|
|
5
5
|
additional_info: Informació sobre el sorteig
|
6
6
|
decidim_category_id: Categories del conjunt de propostes en què voleu aplicar el sorteig
|
7
7
|
decidim_proposals_component_id: Propostes establertes
|
8
|
-
dice: Resultat de la tirada de daus
|
8
|
+
dice: Resultat de la tirada de daus. Tira un dau de sis cares o busca alguna altra manera de generar un número de 1 a 6 i introdueix-lo aquí, a diferència de ser testimoni del resultat. Això contribueix en la qualitat de l'aleatorietat
|
9
9
|
target_items: Nombre de propostes a seleccionar (indica el nombre de propostes que voleu seleccionar mitjançant el sorteig del grup de propostes que hàgiu triat prèviament)
|
10
10
|
title: Títol
|
11
11
|
witnesses: Testimonis
|
12
|
+
models:
|
13
|
+
decidim/sortitions/create_sortition_event: Sorteig
|
14
|
+
activerecord:
|
15
|
+
models:
|
16
|
+
decidim/sortitions/sortition:
|
17
|
+
one: Sorteig
|
18
|
+
other: Sortejos
|
12
19
|
decidim:
|
13
20
|
components:
|
14
21
|
sortitions:
|
@@ -23,6 +30,10 @@ ca:
|
|
23
30
|
email_outro: Has rebut aquesta notificació perquè estàs seguint "%{participatory_space_title}". Pots deixar de seguir-lo des de l'enllaç anterior.
|
24
31
|
email_subject: S'ha afegit un nou sorteig a %{participatory_space_title}
|
25
32
|
notification_title: El sorteig <a href="%{resource_path}">%{resource_title}</a> s'ha afegit a %{participatory_space_title}
|
33
|
+
pages:
|
34
|
+
home:
|
35
|
+
statistics:
|
36
|
+
sortitions_count: Sortejos
|
26
37
|
participatory_processes:
|
27
38
|
statistics:
|
28
39
|
sortitions_count: Sortejos
|
@@ -106,8 +117,6 @@ ca:
|
|
106
117
|
label: 'Ordeneu els sortejos per:'
|
107
118
|
random: Aleatori
|
108
119
|
recent: Recent
|
109
|
-
proposal:
|
110
|
-
view_proposal: Veure proposta
|
111
120
|
results_count:
|
112
121
|
count:
|
113
122
|
one: proposta seleccionada
|
@@ -127,10 +136,11 @@ ca:
|
|
127
136
|
time_seed: "(2) Llavor de temps"
|
128
137
|
witnesses: Testimonis
|
129
138
|
sortition:
|
139
|
+
random_seed: Llavor aleatòria
|
130
140
|
selected_proposals:
|
131
141
|
one: 1 proposta seleccionada
|
132
|
-
other:
|
133
|
-
|
142
|
+
other: '%{count} propostes seleccionades'
|
143
|
+
view: Veure
|
134
144
|
sortition_author:
|
135
145
|
deleted: Usuari eliminat
|
136
146
|
sortition_cancel_author:
|
@@ -139,7 +149,3 @@ ca:
|
|
139
149
|
count:
|
140
150
|
one: 1 sorteig
|
141
151
|
other: "%{count} classificacions"
|
142
|
-
pages:
|
143
|
-
home:
|
144
|
-
statistics:
|
145
|
-
sortitions_count: Sortejos
|
data/config/locales/en.yml
CHANGED
@@ -6,10 +6,17 @@ en:
|
|
6
6
|
additional_info: Sortition information
|
7
7
|
decidim_category_id: Categories of the set of proposals in which you want to apply the draw
|
8
8
|
decidim_proposals_component_id: Proposals set
|
9
|
-
dice: Result of die roll
|
9
|
+
dice: Result of die roll. Roll a 6-sided die, or look for another random way to generate a number from 1 to 6, and enter here the resulting number in front of some witnesses. This contributes to the quality and guarantees of the randomness of the result
|
10
10
|
target_items: Number of proposals to be selected (indicates the number of proposals you want to be selected by drawing lots of the group of proposals you have previously chosen)
|
11
11
|
title: Title
|
12
12
|
witnesses: Witnesses
|
13
|
+
models:
|
14
|
+
decidim/sortitions/create_sortition_event: Sortition
|
15
|
+
activerecord:
|
16
|
+
models:
|
17
|
+
decidim/sortitions/sortition:
|
18
|
+
one: Sortition
|
19
|
+
other: Sortitions
|
13
20
|
decidim:
|
14
21
|
components:
|
15
22
|
sortitions:
|
@@ -24,6 +31,10 @@ en:
|
|
24
31
|
email_outro: You have received this notification because you are following "%{participatory_space_title}". You can unfollow it from the previous link.
|
25
32
|
email_subject: New sortition added to %{participatory_space_title}
|
26
33
|
notification_title: The sortition <a href="%{resource_path}">%{resource_title}</a> has been added to %{participatory_space_title}
|
34
|
+
pages:
|
35
|
+
home:
|
36
|
+
statistics:
|
37
|
+
sortitions_count: Sortitions
|
27
38
|
participatory_processes:
|
28
39
|
statistics:
|
29
40
|
sortitions_count: Sortitions
|
@@ -77,7 +88,7 @@ en:
|
|
77
88
|
selected_proposals: Proposals selected for draw
|
78
89
|
update:
|
79
90
|
error: There was an error updating the sortition.
|
80
|
-
success: Sortition successfully
|
91
|
+
success: Sortition successfully updated
|
81
92
|
admin_log:
|
82
93
|
sortition:
|
83
94
|
create: "%{user_name} created the %{resource_name} sortition in %{space_name}"
|
@@ -107,8 +118,6 @@ en:
|
|
107
118
|
label: 'Order sortitions by:'
|
108
119
|
random: Random
|
109
120
|
recent: Recent
|
110
|
-
proposal:
|
111
|
-
view_proposal: View proposal
|
112
121
|
results_count:
|
113
122
|
count:
|
114
123
|
one: selected proposal
|
@@ -132,10 +141,11 @@ en:
|
|
132
141
|
time_seed: "(2) Time seed"
|
133
142
|
witnesses: Witnesses
|
134
143
|
sortition:
|
144
|
+
random_seed: Random seed
|
135
145
|
selected_proposals:
|
136
|
-
one:
|
137
|
-
other:
|
138
|
-
|
146
|
+
one: proposal selected
|
147
|
+
other: proposals selected
|
148
|
+
view: View
|
139
149
|
sortition_author:
|
140
150
|
deleted: Deleted user
|
141
151
|
sortition_cancel_author:
|
@@ -144,7 +154,3 @@ en:
|
|
144
154
|
count:
|
145
155
|
one: 1 sortition
|
146
156
|
other: "%{count} sortitions"
|
147
|
-
pages:
|
148
|
-
home:
|
149
|
-
statistics:
|
150
|
-
sortitions_count: Sortitions
|