decidim-debates 0.10.1 → 0.11.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/commands/decidim/debates/admin/create_debate.rb +2 -2
- data/app/commands/decidim/debates/create_debate.rb +2 -2
- data/app/controllers/decidim/debates/admin/application_controller.rb +2 -2
- data/app/controllers/decidim/debates/admin/debates_controller.rb +3 -3
- data/app/controllers/decidim/debates/application_controller.rb +1 -1
- data/app/controllers/decidim/debates/debates_controller.rb +1 -1
- data/app/forms/decidim/debates/admin/debate_form.rb +2 -2
- data/app/forms/decidim/debates/debate_form.rb +1 -1
- data/app/jobs/decidim/debates/settings_change_job.rb +4 -4
- data/app/models/decidim/debates/abilities/admin/participatory_process_moderator_ability.rb +1 -1
- data/app/models/decidim/debates/abilities/current_user_ability.rb +6 -6
- data/app/models/decidim/debates/debate.rb +6 -6
- data/app/services/decidim/debates/debate_search.rb +2 -2
- data/app/views/decidim/debates/admin/debates/_form.html.erb +6 -6
- data/app/views/decidim/debates/admin/debates/edit.html.erb +1 -1
- data/app/views/decidim/debates/admin/debates/index.html.erb +3 -3
- data/app/views/decidim/debates/admin/debates/new.html.erb +1 -1
- data/app/views/decidim/debates/debates/_debate.html.erb +4 -4
- data/app/views/decidim/debates/debates/_filters.html.erb +5 -5
- data/app/views/decidim/debates/debates/_filters_small_view.html.erb +1 -1
- data/app/views/decidim/debates/debates/_share.html.erb +1 -1
- data/app/views/decidim/debates/debates/index.html.erb +2 -2
- data/app/views/decidim/debates/debates/show.html.erb +4 -4
- data/config/locales/ca.yml +13 -13
- data/config/locales/en.yml +13 -13
- data/config/locales/es.yml +13 -13
- data/config/locales/eu.yml +13 -13
- data/config/locales/fi.yml +13 -13
- data/config/locales/fr.yml +13 -13
- data/config/locales/gl.yml +13 -13
- data/config/locales/it.yml +13 -13
- data/config/locales/nl.yml +51 -50
- data/config/locales/pl.yml +13 -13
- data/config/locales/pt-BR.yml +13 -13
- data/config/locales/pt.yml +13 -13
- data/config/locales/ru.yml +2 -0
- data/config/locales/sv.yml +13 -13
- data/config/locales/uk.yml +8 -11
- data/db/migrate/20180305133556_rename_features_to_components_at_debates.rb +11 -0
- data/lib/decidim/debates.rb +1 -1
- data/lib/decidim/debates/{feature.rb → component.rb} +19 -15
- data/lib/decidim/debates/engine.rb +1 -1
- data/lib/decidim/debates/test/factories.rb +6 -6
- data/lib/decidim/debates/version.rb +1 -1
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0da7649f21a90cd8b25affec2d754b336c6eefeaecf6784162c2930193a885d1
|
4
|
+
data.tar.gz: 0c3b6d55d55d5f888f221497240e206f75e388ca0c33f4bbca360f4ce615c8c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 283a66424e943e8b05f4d99c74d9b76bbef4c21c268ceb802db46540d2cdf43feffed606c2ff5750a633ecaf4ab01b8a3964624c252108f64a4417f11b9700c6
|
7
|
+
data.tar.gz: cf39b4d1c8ecd09294daa0c17345a8c11189b55c70533233042273e8cef52e3a4e451a551c12fe0bbc461fa2b32fc9e77b3896d30c2116b1980e99146a0f4520
|
@@ -38,7 +38,7 @@ module Decidim
|
|
38
38
|
instructions: form.instructions,
|
39
39
|
end_time: form.end_time,
|
40
40
|
start_time: form.start_time,
|
41
|
-
|
41
|
+
component: form.current_component
|
42
42
|
)
|
43
43
|
end
|
44
44
|
|
@@ -47,7 +47,7 @@ module Decidim
|
|
47
47
|
event: "decidim.events.debates.debate_created",
|
48
48
|
event_class: Decidim::Debates::CreateDebateEvent,
|
49
49
|
resource: debate,
|
50
|
-
recipient_ids: form.
|
50
|
+
recipient_ids: form.current_component.participatory_space.followers.pluck(:id),
|
51
51
|
extra: {
|
52
52
|
type: "participatory_space"
|
53
53
|
}
|
@@ -27,7 +27,7 @@ module Decidim
|
|
27
27
|
attr_reader :debate, :form
|
28
28
|
|
29
29
|
def organization
|
30
|
-
@organization = form.
|
30
|
+
@organization = form.current_component.organization
|
31
31
|
end
|
32
32
|
|
33
33
|
def i18n_field(field)
|
@@ -43,7 +43,7 @@ module Decidim
|
|
43
43
|
category: form.category,
|
44
44
|
title: i18n_field(form.title),
|
45
45
|
description: i18n_field(form.description),
|
46
|
-
|
46
|
+
component: form.current_component
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
@@ -6,9 +6,9 @@ module Decidim
|
|
6
6
|
# This controller is the abstract class from which all other controllers of
|
7
7
|
# this engine inherit.
|
8
8
|
#
|
9
|
-
# Note that it inherits from `Decidim::
|
9
|
+
# Note that it inherits from `Decidim::Components::BaseController`, which
|
10
10
|
# override its layout and provide all kinds of useful methods.
|
11
|
-
class ApplicationController < Decidim::Admin::
|
11
|
+
class ApplicationController < Decidim::Admin::Components::BaseController
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -12,7 +12,7 @@ module Decidim
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def create
|
15
|
-
@form = form(Decidim::Debates::Admin::DebateForm).from_params(params,
|
15
|
+
@form = form(Decidim::Debates::Admin::DebateForm).from_params(params, current_component: current_component)
|
16
16
|
|
17
17
|
CreateDebate.call(@form) do
|
18
18
|
on(:ok) do
|
@@ -34,7 +34,7 @@ module Decidim
|
|
34
34
|
|
35
35
|
def update
|
36
36
|
authorize! :edit, debate
|
37
|
-
@form = form(DebateForm).from_params(params,
|
37
|
+
@form = form(DebateForm).from_params(params, current_component: current_component)
|
38
38
|
|
39
39
|
UpdateDebate.call(@form, debate) do
|
40
40
|
on(:ok) do
|
@@ -61,7 +61,7 @@ module Decidim
|
|
61
61
|
private
|
62
62
|
|
63
63
|
def debates
|
64
|
-
@debates ||= Debate.where(
|
64
|
+
@debates ||= Debate.where(component: current_component)
|
65
65
|
end
|
66
66
|
|
67
67
|
def debate
|
@@ -7,7 +7,7 @@ module Decidim
|
|
7
7
|
#
|
8
8
|
# Note that it inherits from `Decidim::Components::BaseController`, which
|
9
9
|
# override its layout and provide all kinds of useful methods.
|
10
|
-
class ApplicationController < Decidim::
|
10
|
+
class ApplicationController < Decidim::Components::BaseController
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -20,7 +20,7 @@ module Decidim
|
|
20
20
|
|
21
21
|
def create
|
22
22
|
authorize! :create, Debate
|
23
|
-
@form = form(DebateForm).from_params(params,
|
23
|
+
@form = form(DebateForm).from_params(params, current_component: current_component)
|
24
24
|
|
25
25
|
CreateDebate.call(@form) do
|
26
26
|
on(:ok) do |debate|
|
@@ -24,8 +24,8 @@ module Decidim
|
|
24
24
|
validates :category, presence: true, if: ->(form) { form.decidim_category_id.present? }
|
25
25
|
|
26
26
|
def category
|
27
|
-
return unless
|
28
|
-
@category ||=
|
27
|
+
return unless current_component
|
28
|
+
@category ||= current_component.categories.find_by(id: decidim_category_id)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -17,7 +17,7 @@ module Decidim
|
|
17
17
|
validates :category, presence: true, if: ->(form) { form.category_id.present? }
|
18
18
|
|
19
19
|
def category
|
20
|
-
@category ||=
|
20
|
+
@category ||= current_component.categories.find_by(id: category_id)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -3,10 +3,10 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Debates
|
5
5
|
class SettingsChangeJob < ApplicationJob
|
6
|
-
def perform(
|
6
|
+
def perform(component_id, previous_settings, current_settings)
|
7
7
|
return if unchanged?(previous_settings, current_settings)
|
8
8
|
|
9
|
-
|
9
|
+
component = Decidim::Component.find(component_id)
|
10
10
|
|
11
11
|
if debate_creation_enabled?(previous_settings, current_settings)
|
12
12
|
event = "decidim.events.debates.creation_enabled"
|
@@ -19,8 +19,8 @@ module Decidim
|
|
19
19
|
Decidim::EventsManager.publish(
|
20
20
|
event: event,
|
21
21
|
event_class: event_class,
|
22
|
-
resource:
|
23
|
-
recipient_ids:
|
22
|
+
resource: component,
|
23
|
+
recipient_ids: component.participatory_space.followers.pluck(:id)
|
24
24
|
)
|
25
25
|
end
|
26
26
|
|
@@ -23,9 +23,9 @@ module Decidim
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def authorized?(action)
|
26
|
-
return unless
|
26
|
+
return unless component
|
27
27
|
|
28
|
-
ActionAuthorizer.new(user,
|
28
|
+
ActionAuthorizer.new(user, component, action).authorize.ok?
|
29
29
|
end
|
30
30
|
|
31
31
|
def creation_enabled?
|
@@ -37,11 +37,11 @@ module Decidim
|
|
37
37
|
context.fetch(:current_settings, nil)
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
41
|
-
|
42
|
-
return nil unless
|
40
|
+
def component
|
41
|
+
component = context.fetch(:current_component, nil)
|
42
|
+
return nil unless component && component.manifest.name == :debates
|
43
43
|
|
44
|
-
|
44
|
+
component
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -6,19 +6,19 @@ module Decidim
|
|
6
6
|
# title, description and any other useful information to render a custom
|
7
7
|
# debate.
|
8
8
|
class Debate < Debates::ApplicationRecord
|
9
|
-
include Decidim::
|
9
|
+
include Decidim::HasComponent
|
10
10
|
include Decidim::HasCategory
|
11
11
|
include Decidim::Resourceable
|
12
12
|
include Decidim::Followable
|
13
13
|
include Decidim::Comments::Commentable
|
14
|
-
include Decidim::
|
14
|
+
include Decidim::ScopableComponent
|
15
15
|
include Decidim::Authorable
|
16
16
|
include Decidim::Reportable
|
17
17
|
include Decidim::HasReference
|
18
18
|
include Decidim::Traceable
|
19
19
|
include Decidim::Loggable
|
20
20
|
|
21
|
-
|
21
|
+
component_manifest_name "debates"
|
22
22
|
|
23
23
|
validates :title, presence: true
|
24
24
|
|
@@ -64,7 +64,7 @@ module Decidim
|
|
64
64
|
|
65
65
|
# Public: Overrides the `commentable?` Commentable concern method.
|
66
66
|
def commentable?
|
67
|
-
|
67
|
+
component.settings.comments_enabled?
|
68
68
|
end
|
69
69
|
|
70
70
|
# Public: Overrides the `accepts_new_comments?` Commentable concern method.
|
@@ -95,14 +95,14 @@ module Decidim
|
|
95
95
|
|
96
96
|
# Public: Override Commentable concern method `users_to_notify_on_comment_created`
|
97
97
|
def users_to_notify_on_comment_created
|
98
|
-
return (followers
|
98
|
+
return Decidim::User.where(id: followers).or(Decidim::User.where(id: component.participatory_space.admins)).distinct if official?
|
99
99
|
followers
|
100
100
|
end
|
101
101
|
|
102
102
|
private
|
103
103
|
|
104
104
|
def comments_blocked?
|
105
|
-
|
105
|
+
component.current_settings.comments_blocked
|
106
106
|
end
|
107
107
|
end
|
108
108
|
end
|
@@ -3,11 +3,11 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Debates
|
5
5
|
# This class handles search and filtering of debates. Needs a
|
6
|
-
# `
|
6
|
+
# `current_component` param with a `Decidim::Component` in order to
|
7
7
|
# find the debates.
|
8
8
|
class DebateSearch < ResourceSearch
|
9
9
|
# Public: Initializes the service.
|
10
|
-
#
|
10
|
+
# component - A Decidim::Component to get the debates from.
|
11
11
|
# page - The page number to paginate the results.
|
12
12
|
# per_page - The number of proposals to return per page.
|
13
13
|
def initialize(options = {})
|
@@ -4,23 +4,23 @@
|
|
4
4
|
</div>
|
5
5
|
|
6
6
|
<div class="card-section">
|
7
|
-
<div class="row column"
|
7
|
+
<div class="row column">
|
8
8
|
<%= form.translated :text_field, :title, autofocus: true %>
|
9
9
|
</div>
|
10
10
|
|
11
|
-
<div class="row column"
|
11
|
+
<div class="row column">
|
12
12
|
<%= form.translated :editor, :description %>
|
13
13
|
</div>
|
14
14
|
|
15
|
-
<div class="row column"
|
15
|
+
<div class="row column">
|
16
16
|
<%= form.translated :editor, :instructions %>
|
17
17
|
</div>
|
18
18
|
|
19
|
-
<div class="row column"
|
19
|
+
<div class="row column">
|
20
20
|
<%= form.translated :editor, :information_updates %>
|
21
21
|
</div>
|
22
22
|
|
23
|
-
<div class="row"
|
23
|
+
<div class="row">
|
24
24
|
<div class="column xlarge-6">
|
25
25
|
<%= form.datetime_field :start_time %>
|
26
26
|
</div>
|
@@ -29,7 +29,7 @@
|
|
29
29
|
</div>
|
30
30
|
</div>
|
31
31
|
|
32
|
-
<div class="row column"
|
32
|
+
<div class="row column">
|
33
33
|
<%= form.categories_select :decidim_category_id, current_participatory_space.categories, prompt: "", disable_parents: false %>
|
34
34
|
</div>
|
35
35
|
</div>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= decidim_form_for(@form, html: { class: "form edit_debate" }) do |f| %>
|
2
|
-
<%= render partial:
|
2
|
+
<%= render partial: "form", object: f, locals: { title: t(".title") } %>
|
3
3
|
|
4
4
|
<div class="button--double form-general-submit">
|
5
5
|
<%= f.submit t(".update") %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<h2 class="card-title">
|
4
4
|
<%= t(".title") %>
|
5
5
|
|
6
|
-
<%= link_to t("actions.new", scope: "decidim.debates", name: t("models.debate.name", scope: "decidim.debates.admin")), new_debate_path, class:
|
6
|
+
<%= link_to t("actions.new", scope: "decidim.debates", name: t("models.debate.name", scope: "decidim.debates.admin")), new_debate_path, class: "button tiny button--title" if can? :manage, current_component %>
|
7
7
|
</h2>
|
8
8
|
</div>
|
9
9
|
|
@@ -27,12 +27,12 @@
|
|
27
27
|
<td>
|
28
28
|
<% if debate.start_time %>
|
29
29
|
<%= l debate.start_time, format: :long %>
|
30
|
-
<%
|
30
|
+
<% end %>
|
31
31
|
</td>
|
32
32
|
<td>
|
33
33
|
<% if debate.end_time %>
|
34
34
|
<%= l debate.end_time, format: :long %>
|
35
|
-
<%
|
35
|
+
<% end %>
|
36
36
|
</td>
|
37
37
|
<td class="table-list__actions">
|
38
38
|
<% if can? :update, debate %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= decidim_form_for(@form, html: { class: "form new_debate" }) do |f| %>
|
2
|
-
<%= render partial:
|
2
|
+
<%= render partial: "form", object: f, locals: { title: t(".title") } %>
|
3
3
|
|
4
4
|
<div class="button--double form-general-submit">
|
5
5
|
<%= f.submit t(".create") %>
|
@@ -20,7 +20,7 @@
|
|
20
20
|
<%== html_truncate(translated_attribute(debate.description), length: 630, separator: "...") %>
|
21
21
|
</p>
|
22
22
|
<% if debate.category.present? %>
|
23
|
-
<ul class="tags tags--debate"
|
23
|
+
<ul class="tags tags--debate">
|
24
24
|
<li><%= link_to translated_attribute(debate.category.name), debates_path(filter: { category_id: debate.category.id }) %></li>
|
25
25
|
</ul>
|
26
26
|
<% end %>
|
@@ -32,11 +32,11 @@
|
|
32
32
|
<%= debate.comments.count %>
|
33
33
|
</span>
|
34
34
|
<span>
|
35
|
-
<%= t(
|
35
|
+
<%= t(".comments", count: debate.comments.count) %>
|
36
36
|
</span>
|
37
37
|
</div>
|
38
|
-
<%= link_to t(
|
38
|
+
<%= link_to t(".participate"), debate_path(debate), class: "button small secondary card__button" %>
|
39
39
|
</div>
|
40
40
|
</div>
|
41
41
|
</article>
|
42
|
-
</div>
|
42
|
+
</div>
|
@@ -2,19 +2,19 @@
|
|
2
2
|
<div class="filters__section">
|
3
3
|
<div class="filters__search">
|
4
4
|
<div class="input-group">
|
5
|
-
<%= form.search_field :search_text, label: false, class: "input-group-field", placeholder: t(
|
5
|
+
<%= form.search_field :search_text, label: false, class: "input-group-field", placeholder: t(".search") %>
|
6
6
|
<div class="input-group-button">
|
7
7
|
<button type="submit" class="button button--muted">
|
8
|
-
<%= icon "magnifying-glass", aria_label: t(
|
8
|
+
<%= icon "magnifying-glass", aria_label: t(".search") %>
|
9
9
|
</button>
|
10
10
|
</div>
|
11
11
|
</div>
|
12
12
|
</div>
|
13
13
|
</div>
|
14
14
|
|
15
|
-
<%= form.collection_radio_buttons :origin, [["all", t(
|
15
|
+
<%= form.collection_radio_buttons :origin, [["all", t(".all")], ["official", t(".official")], ["citizens", t(".citizens")]], :first, :last, legend_title: t(".origin") %>
|
16
16
|
|
17
|
-
<% if
|
18
|
-
<%= form.categories_select :category_id,
|
17
|
+
<% if current_component.categories.any? %>
|
18
|
+
<%= form.categories_select :category_id, current_component.categories, legend_title: t(".category"), disable_parents: false, label: false, prompt: t(".category_prompt") %>
|
19
19
|
<% end %>
|
20
20
|
<% end %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class="filters-controls hide-for-mediumlarge">
|
2
2
|
<button data-open="filter-box" class="filters-controls__trigger">
|
3
3
|
<%= t ".filter" %>
|
4
|
-
<%= icon "caret-bottom", class: "icon--small float-right", aria_label: t(
|
4
|
+
<%= icon "caret-bottom", class: "icon--small float-right", aria_label: t(".unfold"), role: "img" %>
|
5
5
|
</button>
|
6
6
|
</div>
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class="text-center">
|
2
2
|
<button class="link text-center" data-open="processShare">
|
3
3
|
<%= t(".share") %>
|
4
|
-
<%= icon "share", class: "icon--after"%>
|
4
|
+
<%= icon "share", class: "icon--after" %>
|
5
5
|
</button>
|
6
6
|
</div>
|
7
7
|
<div class="reveal" id="processShare" data-reveal>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= render partial: "decidim/shared/
|
1
|
+
<%= render partial: "decidim/shared/component_announcement" %>
|
2
2
|
|
3
3
|
<div class="row columns">
|
4
4
|
<div class="title-action">
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<div class="row">
|
18
18
|
<div class="columns mediumlarge-4 large-3">
|
19
19
|
<%= render partial: "filters_small_view" %>
|
20
|
-
<div class="card card--secondary show-for-mediumlarge"
|
20
|
+
<div class="card card--secondary show-for-mediumlarge">
|
21
21
|
<%= render partial: "filters" %>
|
22
22
|
</div>
|
23
23
|
</div>
|
@@ -11,16 +11,16 @@
|
|
11
11
|
<div class="author-data">
|
12
12
|
<%= render partial: "decidim/shared/author_reference", locals: { author: Decidim::Debates::DebatePresenter.new(debate).author } %>
|
13
13
|
<div class="author-data__extra">
|
14
|
-
<button type="button" data-open="<%= current_user.present? ?
|
15
|
-
<%= icon "flag", aria_label: t(
|
14
|
+
<button type="button" data-open="<%= current_user.present? ? "flagModal" : "loginModal" %>" title="<%= t(".report") %>" aria-controls="<%= current_user.present? ? "flagModal" : "loginModal" %>" aria-haspopup="true" tabindex="0">
|
15
|
+
<%= icon "flag", aria_label: t(".report"), class: "icon--small" %>
|
16
16
|
</button>
|
17
17
|
<% unless debate.official? %>
|
18
18
|
<%= link_to_current_or_new_conversation_with(debate.author) %>
|
19
19
|
<% end %>
|
20
20
|
</div>
|
21
21
|
<% if debate.commentable? %>
|
22
|
-
<a href="#comments" title="<%= t(
|
23
|
-
<%= icon "comment-square", aria_label: t(
|
22
|
+
<a href="#comments" title="<%= t(".comments") %>">
|
23
|
+
<%= icon "comment-square", aria_label: t(".comments"), role: "img" %> <%= debate.comments.count %>
|
24
24
|
</a>
|
25
25
|
<% end %>
|
26
26
|
</div>
|