decidim-surveys 0.14.4 → 0.15.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: 489cb19ce6c304379f2352864349c0cc7a053fcdfbe90a8990e5c1535096fd25
4
- data.tar.gz: 898e2ba19ffff3a96a71820e0695d984230536a04be175816564be395d4e9f28
3
+ metadata.gz: ab880c5579f03c8c0f088a43b0afe39904e410e720ef4180ec9400fd3af64178
4
+ data.tar.gz: bdbbe058f4fe8aaec83590ab7c4b72742f6d6474ff86ad64c35eba30b57ddf61
5
5
  SHA512:
6
- metadata.gz: cf28d2c6f5e3aae3f5af02b0ef4e2e41a6ee8a1403835ad331e799cc48a662c6fad68aa0464a3402c7b05ebd088b65b48bb8612a94e48b87829922bdea0c2019
7
- data.tar.gz: a662eb26894ee4d4a3a2586ef1fd0e3197c3fcbbc6a119de7229f3ef3efd0d1d1ba57a99206f2d9c52f4c663603517dd2622363bc97d531853d0e727c2fe97ff
6
+ metadata.gz: a64b7e5de0a22af66fbb5309a01835923409f16d1e15a96dc5036a1c3524539af60cca312975f3b0571462cbbc626f2d5c7cf44dc6da4685a89c65d79081808f
7
+ data.tar.gz: 32f930fe24eebd905533bfdee3ff8db902f27afa8e27baf6666c637b433085d1361a1b15d7a02658de79295c6b5324104c45f40644686d5a69642cccd1e18a64
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Surveys
5
+ # A cell to display when a Survey has been published.
6
+ class SurveyActivityCell < ActivityCell
7
+ include Decidim::ComponentPathHelper
8
+
9
+ def title
10
+ I18n.t(
11
+ "decidim.surveys.last_activity.new_survey_at_html",
12
+ link: participatory_space_link
13
+ )
14
+ end
15
+
16
+ def activity_link_path
17
+ main_component_path(component)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -27,7 +27,7 @@ module Decidim
27
27
  end
28
28
 
29
29
  def self.export_serializer
30
- Decidim::Surveys::SurveyUserAnswersSerializer
30
+ Decidim::Surveys::DataPortabilitySurveyUserAnswersSerializer
31
31
  end
32
32
 
33
33
  private
@@ -85,6 +85,8 @@ ca:
85
85
  update:
86
86
  invalid: Hi ha hagut errors en desar l'enquesta.
87
87
  success: Enquesta desada correctament.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Nova enquesta a %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Resposta llarga
90
92
  multiple_option: Opció múltiple
@@ -85,6 +85,8 @@ de:
85
85
  update:
86
86
  invalid: Beim Speichern der Umfrage sind Fehler aufgetreten.
87
87
  success: Umfrage wurde erfolgreich gespeichert.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Neue Umfrage bei %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Lange Antwort
90
92
  multiple_option: Mehrere Optionen
@@ -86,6 +86,8 @@ en:
86
86
  update:
87
87
  invalid: There's been errors when saving the survey.
88
88
  success: Survey saved successfully.
89
+ last_activity:
90
+ new_survey_at_html: "<span>New survey at %{link}</span>"
89
91
  question_types:
90
92
  long_answer: Long answer
91
93
  multiple_option: Multiple option
@@ -2,7 +2,7 @@ es-PY:
2
2
  activemodel:
3
3
  attributes:
4
4
  survey_answer:
5
- body: Respuesta
5
+ body: Responder
6
6
  survey_question:
7
7
  mandatory: Obligatorio
8
8
  max_choices: Número máximo de opciones
@@ -85,6 +85,8 @@ es-PY:
85
85
  update:
86
86
  invalid: Se han producido errores al guardar la encuesta.
87
87
  success: Encuesta guardada correctamente.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Nueva encuesta en %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Respuesta larga
90
92
  multiple_option: Opción múltiple
@@ -2,7 +2,7 @@ es:
2
2
  activemodel:
3
3
  attributes:
4
4
  survey_answer:
5
- body: Respuesta
5
+ body: Responder
6
6
  survey_question:
7
7
  mandatory: Obligatorio
8
8
  max_choices: Número máximo de opciones
@@ -85,6 +85,8 @@ es:
85
85
  update:
86
86
  invalid: Se han producido errores al guardar la encuesta.
87
87
  success: Encuesta guardada correctamente.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Nueva encuesta en %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Respuesta larga
90
92
  multiple_option: Opción múltiple
@@ -85,6 +85,8 @@ eu:
85
85
  update:
86
86
  invalid: Inkesta gordetzean erroreak gertatu dira.
87
87
  success: Inkesta ondo gorde da.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Inkesta berrian %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Erantzun luzea
90
92
  multiple_option: Aukera anitz
@@ -2,7 +2,7 @@ fi:
2
2
  activemodel:
3
3
  attributes:
4
4
  survey_answer:
5
- body: Vastaa
5
+ body: Vastaus
6
6
  survey_question:
7
7
  mandatory: Pakollinen
8
8
  max_choices: Valintojen enimmäismäärä
@@ -85,6 +85,8 @@ fi:
85
85
  update:
86
86
  invalid: Kyselyn tallennus epäonnistui.
87
87
  success: Kysely tallennettu onnistuneesti.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Uusi kysely osoitteessa %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Pitkä vastaus
90
92
  multiple_option: Useita vaihtoehtoja
@@ -85,6 +85,8 @@ fr:
85
85
  update:
86
86
  invalid: Erreurs lors de la sauvegarde de l'enquête.
87
87
  success: Enquête enregistrée avec succès.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Nouvelle enquête à %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Réponse longue
90
92
  multiple_option: Options multiples
@@ -85,6 +85,8 @@ gl:
85
85
  update:
86
86
  invalid: Houbo erros ao gardar a enquisa.
87
87
  success: A enquisa gardouse correctamente.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Nova enquisa en %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Resposta longa
90
92
  multiple_option: Múltipla opción
@@ -15,7 +15,7 @@ hu:
15
15
  missing: nincs befejezve
16
16
  too_many: túl sok
17
17
  models:
18
- decidim/surveys/closed_survey_event: Felmérés vége
18
+ decidim/surveys/closed_survey_event: A felmérés véget ért
19
19
  decidim/surveys/opened_survey_event: Felmérés elindult
20
20
  activerecord:
21
21
  models:
@@ -85,6 +85,8 @@ hu:
85
85
  update:
86
86
  invalid: Hiba történt a felmérés mentése során.
87
87
  success: Felmérés mentése sikeres.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Új felmérés %{link}</span>kor"
88
90
  question_types:
89
91
  long_answer: Hosszú válasz
90
92
  multiple_option: Több lehetőség
@@ -85,6 +85,8 @@ it:
85
85
  update:
86
86
  invalid: Ci sono stati degli errori durante il salvataggio dell'indagine.
87
87
  success: Il questionario è stato salvato correttamente.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Nuovo sondaggio al %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Risposta lunga
90
92
  multiple_option: Opzione multipla
@@ -2,7 +2,7 @@ nl:
2
2
  activemodel:
3
3
  attributes:
4
4
  survey_answer:
5
- body: Antwoord
5
+ body: Antwoorden
6
6
  survey_question:
7
7
  mandatory: Verplicht
8
8
  max_choices: Maximum aantal keuzes
@@ -85,6 +85,8 @@ nl:
85
85
  update:
86
86
  invalid: Er zijn fouten geweest bij het opslaan van de enquête.
87
87
  success: Enquête succesvol opgeslagen.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Nieuwe enquête op %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Lang antwoord
90
92
  multiple_option: Meerdere opties
@@ -89,6 +89,8 @@ pl:
89
89
  update:
90
90
  invalid: Podczas zapisywania ankiety wystąpiły błędy.
91
91
  success: Ankieta została zapisana pomyślnie.
92
+ last_activity:
93
+ new_survey_at_html: "<span>Nowa ankieta na %{link}</span>"
92
94
  question_types:
93
95
  long_answer: Długa odpowiedź
94
96
  multiple_option: Wiele opcji
@@ -2,7 +2,7 @@ pt-BR:
2
2
  activemodel:
3
3
  attributes:
4
4
  survey_answer:
5
- body: Resposta
5
+ body: Responda
6
6
  survey_question:
7
7
  mandatory: Obrigatório
8
8
  max_choices: Número máximo de escolhas
@@ -85,6 +85,8 @@ pt-BR:
85
85
  update:
86
86
  invalid: Houve erros ao salvar a pesquisa.
87
87
  success: Pesquisa salva com sucesso.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Nova pesquisa em %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Resposta longa
90
92
  multiple_option: Opção múltipla
@@ -2,7 +2,7 @@ pt:
2
2
  activemodel:
3
3
  attributes:
4
4
  survey_answer:
5
- body: Resposta
5
+ body: Responda
6
6
  survey_question:
7
7
  mandatory: Obrigatório
8
8
  max_choices: Número máximo de escolhas
@@ -85,6 +85,8 @@ pt:
85
85
  update:
86
86
  invalid: Houve erros ao salvar a pesquisa.
87
87
  success: Pesquisa salva com sucesso.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Nova pesquisa em %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Resposta longa
90
92
  multiple_option: Opção múltipla
@@ -2,7 +2,7 @@ ru:
2
2
  activemodel:
3
3
  attributes:
4
4
  survey_answer:
5
- body: Ответить
5
+ body: Ответ
6
6
  survey_question:
7
7
  mandatory: Обязательно
8
8
  max_choices: Максимальное количество вариантов
@@ -2,7 +2,7 @@ sv:
2
2
  activemodel:
3
3
  attributes:
4
4
  survey_answer:
5
- body: Svar
5
+ body: Svara
6
6
  survey_question:
7
7
  mandatory: Obligatorisk
8
8
  max_choices: Max antal val
@@ -85,6 +85,8 @@ sv:
85
85
  update:
86
86
  invalid: Det har blivit fel när du sparat enkäten.
87
87
  success: Enkäten sparades.
88
+ last_activity:
89
+ new_survey_at_html: "<span>Ny undersökning vid %{link}</span>"
88
90
  question_types:
89
91
  long_answer: Långt svar
90
92
  multiple_option: Flera alternativ
@@ -2,7 +2,7 @@ uk:
2
2
  activemodel:
3
3
  attributes:
4
4
  survey_answer:
5
- body: Відповісти
5
+ body: Відповідь
6
6
  survey_question:
7
7
  mandatory: Обов’язкове поле
8
8
  max_choices: Гранична кількість варіантів
@@ -10,5 +10,6 @@ module Decidim
10
10
  # allows users to create surveys in a participatory process.
11
11
  module Surveys
12
12
  autoload :SurveyUserAnswersSerializer, "decidim/surveys/survey_user_answers_serializer"
13
+ autoload :DataPortabilitySurveyUserAnswersSerializer, "decidim/surveys/data_portability_survey_user_answers_serializer"
13
14
  end
14
15
  end
@@ -9,6 +9,12 @@ Decidim.register_component(:surveys) do |component|
9
9
  component.stylesheet = "decidim/surveys/surveys"
10
10
  component.permissions_class_name = "Decidim::Surveys::Permissions"
11
11
 
12
+ component.on(:copy) do |context|
13
+ Decidim::Surveys::CreateSurvey.call(context[:new_component]) do
14
+ on(:invalid) { raise "Can't create survey" }
15
+ end
16
+ end
17
+
12
18
  component.on(:create) do |instance|
13
19
  Decidim::Surveys::CreateSurvey.call(instance) do
14
20
  on(:invalid) { raise "Can't create survey" }
@@ -62,14 +68,28 @@ Decidim.register_component(:surveys) do |component|
62
68
  end
63
69
 
64
70
  component.seeds do |participatory_space|
65
- component = Decidim::Component.create!(
71
+ admin_user = Decidim::User.find_by(
72
+ organization: participatory_space.organization,
73
+ email: "admin@example.org"
74
+ )
75
+
76
+ params = {
66
77
  name: Decidim::Components::Namer.new(participatory_space.organization.available_locales, :surveys).i18n_name,
67
78
  manifest_name: :surveys,
68
79
  published_at: Time.current,
69
80
  participatory_space: participatory_space
70
- )
81
+ }
82
+
83
+ component = Decidim.traceability.perform_action!(
84
+ "publish",
85
+ Decidim::Component,
86
+ admin_user,
87
+ visibility: "all"
88
+ ) do
89
+ Decidim::Component.create!(params)
90
+ end
71
91
 
72
- survey = Decidim::Surveys::Survey.create!(
92
+ params = {
73
93
  component: component,
74
94
  title: Decidim::Faker::Localized.paragraph,
75
95
  description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
@@ -78,6 +98,13 @@ Decidim.register_component(:surveys) do |component|
78
98
  tos: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
79
99
  Decidim::Faker::Localized.paragraph(2)
80
100
  end
101
+ }
102
+
103
+ survey = Decidim.traceability.create!(
104
+ Decidim::Surveys::Survey,
105
+ admin_user,
106
+ params,
107
+ visibility: "all"
81
108
  )
82
109
 
83
110
  %w(short_answer long_answer).each do |text_question_type|
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Surveys
5
+ class DataPortabilitySurveyUserAnswersSerializer < Decidim::Exporters::Serializer
6
+ include Decidim::TranslationsHelper
7
+ # Serializes a Survey User Answer for data portability
8
+ def serialize
9
+ {
10
+ id: resource.id,
11
+ user: {
12
+ name: resource.user.name,
13
+ email: resource.user.email
14
+ },
15
+ survey: {
16
+ id: resource.question.survey.id,
17
+ title: translated_attribute(resource.question.survey.title),
18
+ description: translated_attribute(resource.question.survey.description),
19
+ tos: translated_attribute(resource.question.survey.tos)
20
+ },
21
+ question: {
22
+ id: resource.question.id,
23
+ body: translated_attribute(resource.question.body),
24
+ description: translated_attribute(resource.question.description)
25
+ },
26
+ answer: normalize_body(resource)
27
+ }
28
+ end
29
+
30
+ private
31
+
32
+ def normalize_body(resource)
33
+ resource.body || resource.choices.pluck(:body)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -11,13 +11,13 @@ FactoryBot.define do
11
11
  end
12
12
 
13
13
  factory :survey, class: Decidim::Surveys::Survey do
14
- title { Decidim::Faker::Localized.sentence }
14
+ title { generate_localized_title }
15
15
  description do
16
16
  Decidim::Faker::Localized.wrapped("<p>", "</p>") do
17
- Decidim::Faker::Localized.sentence(4)
17
+ generate_localized_title
18
18
  end
19
19
  end
20
- tos { Decidim::Faker::Localized.sentence(4) }
20
+ tos { generate_localized_title }
21
21
  component { build(:surveys_component) }
22
22
  end
23
23
 
@@ -26,7 +26,7 @@ FactoryBot.define do
26
26
  answer_options { [] }
27
27
  end
28
28
 
29
- body { Decidim::Faker::Localized.sentence }
29
+ body { generate_localized_title }
30
30
  mandatory { false }
31
31
  position { 0 }
32
32
  question_type { Decidim::Surveys::SurveyQuestion::TYPES.first }
@@ -50,7 +50,7 @@ FactoryBot.define do
50
50
  end
51
51
 
52
52
  factory :survey_answer_option, class: Decidim::Surveys::SurveyAnswerOption do
53
- body { Decidim::Faker::Localized.sentence }
53
+ body { generate_localized_title }
54
54
  end
55
55
 
56
56
  factory :survey_answer_choice, class: Decidim::Surveys::SurveyAnswerChoice do
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-surveys version.
5
5
  module Surveys
6
6
  def self.version
7
- "0.14.4"
7
+ "0.15.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-surveys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.15.0
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: 2018-10-24 00:00:00.000000000 Z
13
+ date: 2018-11-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: decidim-core
@@ -18,56 +18,56 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.14.4
21
+ version: 0.15.0
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.14.4
28
+ version: 0.15.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: decidim-admin
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 0.14.4
35
+ version: 0.15.0
36
36
  type: :development
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.14.4
42
+ version: 0.15.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: decidim-dev
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - '='
48
48
  - !ruby/object:Gem::Version
49
- version: 0.14.4
49
+ version: 0.15.0
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: 0.14.4
56
+ version: 0.15.0
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: decidim-participatory_processes
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - '='
62
62
  - !ruby/object:Gem::Version
63
- version: 0.14.4
63
+ version: 0.15.0
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - '='
69
69
  - !ruby/object:Gem::Version
70
- version: 0.14.4
70
+ version: 0.15.0
71
71
  description: A surveys component for decidim's participatory spaces.
72
72
  email:
73
73
  - josepjaume@gmail.com
@@ -89,6 +89,7 @@ files:
89
89
  - app/assets/javascripts/decidim/surveys/option_attached_inputs.component.js.es6
90
90
  - app/assets/javascripts/decidim/surveys/surveys.js.es6
91
91
  - app/assets/stylesheets/decidim/surveys/surveys.scss
92
+ - app/cells/decidim/surveys/survey_activity_cell.rb
92
93
  - app/commands/decidim/surveys/admin/update_survey.rb
93
94
  - app/commands/decidim/surveys/answer_survey.rb
94
95
  - app/commands/decidim/surveys/create_survey.rb
@@ -159,6 +160,7 @@ files:
159
160
  - lib/decidim/surveys/admin.rb
160
161
  - lib/decidim/surveys/admin_engine.rb
161
162
  - lib/decidim/surveys/component.rb
163
+ - lib/decidim/surveys/data_portability_survey_user_answers_serializer.rb
162
164
  - lib/decidim/surveys/engine.rb
163
165
  - lib/decidim/surveys/survey_user_answers_serializer.rb
164
166
  - lib/decidim/surveys/test/factories.rb
@@ -183,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
185
  version: '0'
184
186
  requirements: []
185
187
  rubyforge_project:
186
- rubygems_version: 2.7.7
188
+ rubygems_version: 2.7.6
187
189
  signing_key:
188
190
  specification_version: 4
189
191
  summary: Decidim surveys module