decidim-debates 0.20.1 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 809930ea2defd43aa312cc2161f9de53c415b7474a468ab5a0f85557e32049c0
4
- data.tar.gz: 19cd83236ba7dbffb0f4840e528f2efc3b8f5a8e740d26ada593b3e465359143
3
+ metadata.gz: 24ecd1ca0fa6741a77421c6b5112305b9201676dd84b2919c2a9928d9dbd733d
4
+ data.tar.gz: 74033142cb4faa0833f9825c922b6aec32a9b2ed45f14928f6277686641b0405
5
5
  SHA512:
6
- metadata.gz: ed9c919a1930c2df842ec3e67ab2ef7aa7d3dcf2f7df9bbb5997876fe4ef2f19a9fdeba5a1a652e07ee95a8507892acbb4dfb1bf689869658a0f0c8e22f26d57
7
- data.tar.gz: 0ad70dcc09e894a57eebaa18fdada4949e5868e6ada66a6a2cba563b15bca6cfac4e6c0e60ed46afa16e37091bf10baa615e9fc6d1ffd1b889051a76b945088c
6
+ metadata.gz: 8816ad224e66345561250ca0b7c53639c1d3984262cc38642e4d194e3a4533687e38edeeb492765e51c078775f325237e3a05414109c9ce52cfea8378fc6cbd1
7
+ data.tar.gz: 422fb26a1ea59bd93f421527d7608c420d6b21c78c3c7353b49944af77b4c71d2a2cf221a4c39d1fcfdd514a2ccb7543ecc16a4587af3c42a72f755315783a6c
@@ -17,6 +17,10 @@ module Decidim
17
17
  present(model).title
18
18
  end
19
19
 
20
+ def description
21
+ present(model).description(strip_tags: true)
22
+ end
23
+
20
24
  def resource_icon
21
25
  icon "debates", class: "icon--big"
22
26
  end
@@ -7,6 +7,25 @@ module Decidim
7
7
  module ApplicationHelper
8
8
  include PaginateHelper
9
9
  include Decidim::Comments::CommentsHelper
10
+ include Decidim::RichTextEditorHelper
11
+
12
+ # If the debate is official or the rich text editor is enabled on the
13
+ # frontend, the debate description is considered as safe content.
14
+ def safe_content?
15
+ debate&.official? || rich_text_editor_in_public_views?
16
+ end
17
+
18
+ # If the content is safe, HTML tags are sanitized, otherwise, they are stripped.
19
+ def render_debate_description(debate)
20
+ description = present(debate).description(strip_tags: !safe_content?)
21
+
22
+ safe_content? ? decidim_sanitize(description) : simple_format(description)
23
+ end
24
+
25
+ # Returns :text_area or :editor based on current_component settings.
26
+ def text_editor_for_debate_description(form)
27
+ text_editor_for(form, :description)
28
+ end
10
29
  end
11
30
  end
12
31
  end
@@ -27,6 +27,12 @@ module Decidim
27
27
  content = translated_attribute(debate.title)
28
28
  decidim_html_escape(content)
29
29
  end
30
+
31
+ def description(strip_tags: false)
32
+ content = translated_attribute(debate.description)
33
+ content = strip_tags(content) if strip_tags
34
+ content
35
+ end
30
36
  end
31
37
  end
32
38
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Debates
5
+ DebateType = GraphQL::ObjectType.define do
6
+ interfaces [
7
+ -> { Decidim::Core::CategorizableInterface },
8
+ -> { Decidim::Comments::CommentableInterface },
9
+ -> { Decidim::Core::AuthorableInterface }
10
+ ]
11
+
12
+ name "Debate"
13
+ description "A debate"
14
+
15
+ field :id, !types.ID, "The internal ID for this debate"
16
+ field :title, Decidim::Core::TranslatedFieldType, "The title for this debate"
17
+ field :description, Decidim::Core::TranslatedFieldType, "The description for this debate"
18
+ field :instructions, Decidim::Core::TranslatedFieldType, "The instructions for this debate"
19
+ field :startTime, Decidim::Core::DateTimeType, "The start time for this debate", property: :start_time
20
+ field :endTime, Decidim::Core::DateTimeType, "The end time for this debate", property: :end_time
21
+ field :image, types.String, "The image of this debate"
22
+ field :createdAt, Decidim::Core::DateTimeType, "When this debate was created", property: :created_at
23
+ field :updatedAt, Decidim::Core::DateTimeType, "When this debate was updated", property: :updated_at
24
+ field :informationUpdates, Decidim::Core::TranslatedFieldType, "The information updates for this debate", property: :information_updates
25
+ field :reference, types.String, "The reference for this debate"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Debates
5
+ DebatesType = GraphQL::ObjectType.define do
6
+ interfaces [-> { Decidim::Core::ComponentInterface }]
7
+
8
+ name "Debates"
9
+ description "A debates component of a participatory space."
10
+
11
+ connection :debates, DebateType.connection_type do
12
+ resolve ->(component, _args, _ctx) {
13
+ DebatesTypeHelper.base_scope(component).includes(:component)
14
+ }
15
+ end
16
+
17
+ field(:debate, DebateType) do
18
+ argument :id, !types.ID
19
+
20
+ resolve ->(component, args, _ctx) {
21
+ DebatesTypeHelper.base_scope(component).find_by(id: args[:id])
22
+ }
23
+ end
24
+ end
25
+
26
+ module DebatesTypeHelper
27
+ def self.base_scope(component)
28
+ Debate.where(component: component)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -16,7 +16,7 @@
16
16
  </div>
17
17
 
18
18
  <div class="field">
19
- <%= form.text_area :description, rows: 10 %>
19
+ <%= text_editor_for_debate_description(form) %>
20
20
  </div>
21
21
 
22
22
  <% if current_participatory_space.categories&.any? %>
@@ -42,7 +42,7 @@ edit_link(
42
42
  </div>
43
43
  <div class="columns mediumlarge-8 mediumlarge-pull-4">
44
44
  <div class="section">
45
- <p><%= decidim_sanitize(simple_format(translated_attribute(debate.description))) %></p>
45
+ <%= render_debate_description(debate) %>
46
46
  <% if translated_attribute(debate.instructions).present? %>
47
47
  <div class="callout secondary">
48
48
  <%= decidim_sanitize(simple_format(translated_attribute(debate.instructions))) %>
@@ -0,0 +1 @@
1
+ el:
@@ -8,6 +8,7 @@ Decidim.register_component(:debates) do |component|
8
8
  component.icon = "decidim/debates/icon.svg"
9
9
  component.permissions_class_name = "Decidim::Debates::Permissions"
10
10
 
11
+ component.query_type = "Decidim::Debates::DebatesType"
11
12
  component.data_portable_entities = ["Decidim::Debates::Debate"]
12
13
 
13
14
  component.newsletter_participant_entities = ["Decidim::Debates::Debate"]
@@ -31,6 +32,11 @@ Decidim.register_component(:debates) do |component|
31
32
  Decidim::Debates::Debate.where(component: components).not_hidden.count
32
33
  end
33
34
 
35
+ component.register_stat :followers_count, tag: :followers, priority: Decidim::StatsRegistry::LOW_PRIORITY do |components, _start_at, _end_at|
36
+ debates_ids = Decidim::Debates::Debate.where(component: components).not_hidden.pluck(:id)
37
+ Decidim::Follow.where(decidim_followable_type: "Decidim::Debates::Debate", decidim_followable_id: debates_ids).count
38
+ end
39
+
34
40
  component.register_resource(:debate) do |resource|
35
41
  resource.model_class_name = "Decidim::Debates::Debate"
36
42
  resource.card = "decidim/debates/debate"
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-debates version.
5
5
  module Debates
6
6
  def self.version
7
- "0.20.1"
7
+ "0.21.0"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-debates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.1
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-03-27 00:00:00.000000000 Z
14
+ date: 2020-04-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: decidim-comments
@@ -19,28 +19,28 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.20.1
22
+ version: 0.21.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.20.1
29
+ version: 0.21.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: decidim-core
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - '='
35
35
  - !ruby/object:Gem::Version
36
- version: 0.20.1
36
+ version: 0.21.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - '='
42
42
  - !ruby/object:Gem::Version
43
- version: 0.20.1
43
+ version: 0.21.0
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: kaminari
46
46
  requirement: !ruby/object:Gem::Requirement
@@ -75,28 +75,28 @@ dependencies:
75
75
  requirements:
76
76
  - - '='
77
77
  - !ruby/object:Gem::Version
78
- version: 0.20.1
78
+ version: 0.21.0
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - '='
84
84
  - !ruby/object:Gem::Version
85
- version: 0.20.1
85
+ version: 0.21.0
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: decidim-dev
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - '='
91
91
  - !ruby/object:Gem::Version
92
- version: 0.20.1
92
+ version: 0.21.0
93
93
  type: :development
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - '='
98
98
  - !ruby/object:Gem::Version
99
- version: 0.20.1
99
+ version: 0.21.0
100
100
  description: A debates component for decidim's participatory spaces.
101
101
  email:
102
102
  - josepjaume@gmail.com
@@ -147,6 +147,8 @@ files:
147
147
  - app/queries/decidim/debates/metrics/debates_metric_manage.rb
148
148
  - app/serializers/decidim/debates/data_portability_debate_serializer.rb
149
149
  - app/services/decidim/debates/debate_search.rb
150
+ - app/types/decidim/debates/debate_type.rb
151
+ - app/types/decidim/debates/debates_type.rb
150
152
  - app/views/decidim/debates/admin/debates/_form.html.erb
151
153
  - app/views/decidim/debates/admin/debates/edit.html.erb
152
154
  - app/views/decidim/debates/admin/debates/index.html.erb
@@ -167,6 +169,7 @@ files:
167
169
  - config/locales/cs.yml
168
170
  - config/locales/de.yml
169
171
  - config/locales/el-GR.yml
172
+ - config/locales/el.yml
170
173
  - config/locales/en.yml
171
174
  - config/locales/eo-UY.yml
172
175
  - config/locales/es-MX.yml