decidim-surveys 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/decidim/surveys/admin/surveys_controller.rb +11 -0
  3. data/app/controllers/decidim/surveys/surveys_controller.rb +7 -1
  4. data/app/jobs/decidim/surveys/clean_survey_answers_job.rb +32 -0
  5. data/app/jobs/decidim/surveys/settings_change_job.rb +4 -0
  6. data/app/models/decidim/surveys/survey.rb +4 -0
  7. data/app/permissions/decidim/surveys/admin/permissions.rb +12 -6
  8. data/config/locales/am-ET.yml +1 -0
  9. data/config/locales/bg.yml +10 -0
  10. data/config/locales/ca.yml +3 -0
  11. data/config/locales/cs.yml +3 -0
  12. data/config/locales/da.yml +1 -0
  13. data/config/locales/de.yml +3 -0
  14. data/config/locales/en.yml +3 -0
  15. data/config/locales/eo.yml +1 -0
  16. data/config/locales/es-MX.yml +3 -0
  17. data/config/locales/es-PY.yml +3 -0
  18. data/config/locales/es.yml +3 -0
  19. data/config/locales/et.yml +1 -0
  20. data/config/locales/fi-plain.yml +3 -0
  21. data/config/locales/fi.yml +3 -0
  22. data/config/locales/fr-CA.yml +3 -0
  23. data/config/locales/fr.yml +3 -0
  24. data/config/locales/hr.yml +1 -0
  25. data/config/locales/is.yml +25 -0
  26. data/config/locales/it.yml +1 -0
  27. data/config/locales/ja-JP.yml +1 -0
  28. data/config/locales/ja.yml +60 -0
  29. data/config/locales/ko-KR.yml +1 -0
  30. data/config/locales/ko.yml +1 -0
  31. data/config/locales/lt.yml +1 -0
  32. data/config/locales/{lv-LV.yml → lv.yml} +0 -0
  33. data/config/locales/mt.yml +1 -0
  34. data/config/locales/nl.yml +3 -0
  35. data/config/locales/om-ET.yml +1 -0
  36. data/config/locales/pl.yml +17 -14
  37. data/config/locales/pt.yml +1 -0
  38. data/config/locales/ro-RO.yml +1 -0
  39. data/config/locales/so-SO.yml +1 -0
  40. data/config/locales/sv.yml +1 -0
  41. data/config/locales/ti-ER.yml +1 -0
  42. data/config/locales/vi-VN.yml +1 -0
  43. data/config/locales/vi.yml +1 -0
  44. data/config/locales/zh-CN.yml +60 -0
  45. data/config/locales/zh-TW.yml +1 -0
  46. data/db/migrate/20200609090533_check_legacy_tables.rb +1 -0
  47. data/lib/decidim/surveys/admin_engine.rb +10 -0
  48. data/lib/decidim/surveys/component.rb +19 -5
  49. data/lib/decidim/surveys/test/factories.rb +1 -1
  50. data/lib/decidim/surveys/version.rb +1 -1
  51. metadata +49 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d14a8aaa5a0ede9d984f77eeac91dbacd3c4e400cd3942555506f3c81c740a3
4
- data.tar.gz: b6d3a986147764edb8a20ad4e8bf1219860949dac654dc93a4a0367b5d9b1c4a
3
+ metadata.gz: 438c473b61d9bc07cad2c8e3ce3c6c56f900ae0a4aaade52db7dffbcb1e4a433
4
+ data.tar.gz: 182793a9e4e0fee42249e40ec2862f4a756344656f5010c055167c0477240559
5
5
  SHA512:
6
- metadata.gz: 40cc1192e187b3a192516fb90150e76e5a2233d2acf7155f8937728781602e102459dee3ab1a9775b012af9d2d616ed6f379059ee8f11d9b9975dc409b65cf88
7
- data.tar.gz: cf7ba0b830eb911b88fdfda3d3aec5bcab6cfc187300d73e2563904eeb37f2c707c551cf59ab16eb965591e6fb2ff72eb534957df3490ea0e333efb5f172b290
6
+ metadata.gz: fd718b0903ddd737e42ea62e71039e4fdc34bf7c5cc13444f8b1f4353a5d197dd0b95cbd20434d1c52cbefe6c74d82ed64fb590732fddbe6f1f1a17ea5df685d
7
+ data.tar.gz: 92a9f208813e602e656b27f7549da9aafbfb88da073f2d2280d5eddde519fd0756a95223f5860cdbb4f3c207406a0420e4e0dbac8a19f6b5ae32129485dab7c0
@@ -6,11 +6,22 @@ module Decidim
6
6
  # This controller allows the user to update a Page.
7
7
  class SurveysController < Admin::ApplicationController
8
8
  include Decidim::Forms::Admin::Concerns::HasQuestionnaire
9
+ include Decidim::Forms::Admin::Concerns::HasQuestionnaireAnswers
9
10
 
10
11
  def questionnaire_for
11
12
  survey
12
13
  end
13
14
 
15
+ # Specify the public url from which the survey can be viewed and answered
16
+ def public_url
17
+ Decidim::EngineRouter.main_proxy(current_component).survey_path(survey)
18
+ end
19
+
20
+ # Specify where to redirect after exporting a user response
21
+ def questionnaire_participant_answers_url(session_token)
22
+ Decidim::EngineRouter.admin_proxy(survey.component).show_survey_path(session_token: session_token)
23
+ end
24
+
14
25
  private
15
26
 
16
27
  def i18n_flashes_scope
@@ -8,7 +8,7 @@ module Decidim
8
8
  include Decidim::ComponentPathHelper
9
9
  helper Decidim::Surveys::SurveyHelper
10
10
 
11
- delegate :allow_answers?, :allow_unregistered?, to: :current_settings
11
+ delegate :allow_unregistered?, to: :current_settings
12
12
 
13
13
  before_action :check_permissions
14
14
 
@@ -20,6 +20,12 @@ module Decidim
20
20
  survey
21
21
  end
22
22
 
23
+ protected
24
+
25
+ def allow_answers?
26
+ !current_component.published? || current_settings.allow_answers?
27
+ end
28
+
23
29
  def form_path
24
30
  main_component_path(current_component)
25
31
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Surveys
5
+ class CleanSurveyAnswersJob < ApplicationJob
6
+ def perform(_event_name, data)
7
+ @component = data[:resource]
8
+ return unless component&.manifest_name == "surveys"
9
+
10
+ @survey = Survey.find_by(component: component)
11
+ return unless survey&.questionnaire
12
+
13
+ case data[:event_class]
14
+ when "Decidim::ComponentPublishedEvent"
15
+ clean_answers
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :survey, :component
22
+
23
+ def clean_answers
24
+ return unless survey.clean_after_publish?
25
+
26
+ survey.questionnaire.answers.destroy_all
27
+ component.settings[:clean_after_publish] = false
28
+ component.save
29
+ end
30
+ end
31
+ end
32
+ end
@@ -42,6 +42,10 @@ module Decidim
42
42
  !!current_settings[:allow_answers] == false &&
43
43
  previous_settings[:allow_answers] == true
44
44
  end
45
+
46
+ def clean_after_publish_changed?(previous_settings, current_settings)
47
+ current_settings[:clean_after_publish] != previous_settings[:clean_after_publish]
48
+ end
45
49
  # rubocop:enable Style/DoubleNegation
46
50
  end
47
51
  end
@@ -11,6 +11,10 @@ module Decidim
11
11
  component_manifest_name "surveys"
12
12
 
13
13
  validates :questionnaire, presence: true
14
+
15
+ def clean_after_publish?
16
+ component.settings.clean_after_publish?
17
+ end
14
18
  end
15
19
  end
16
20
  end
@@ -7,13 +7,19 @@ module Decidim
7
7
  def permissions
8
8
  return permission_action unless user
9
9
 
10
- return permission_action if permission_action.scope != :admin
10
+ return permission_action unless permission_action.scope == :admin
11
11
 
12
- return permission_action if permission_action.subject != :questionnaire
13
-
14
- case permission_action.action
15
- when :export_answers, :update
16
- permission_action.allow!
12
+ case permission_action.subject
13
+ when :questionnaire
14
+ case permission_action.action
15
+ when :export_answers, :update
16
+ permission_action.allow!
17
+ end
18
+ when :questionnaire_answers
19
+ case permission_action.action
20
+ when :index, :show, :export_response
21
+ permission_action.allow!
22
+ end
17
23
  end
18
24
 
19
25
  permission_action
@@ -0,0 +1 @@
1
+ am:
@@ -0,0 +1,10 @@
1
+ bg:
2
+ activemodel:
3
+ models:
4
+ decidim/surveys/closed_survey_event: Анкетата завърши
5
+ decidim/surveys/opened_survey_event: Анкетата започна
6
+ activerecord:
7
+ models:
8
+ decidim/surveys/survey:
9
+ one: Анкета
10
+ other: Анкети
@@ -20,6 +20,9 @@ ca:
20
20
  settings:
21
21
  global:
22
22
  announcement: Avís
23
+ clean_after_publish: Esborrar les respostes en publicar l'enquesta
24
+ scope_id: Àmbit
25
+ scopes_enabled: Àmbits habilitats
23
26
  step:
24
27
  allow_answers: Permetre respostes
25
28
  allow_unregistered: Permet a usuàries no registrades contestar l'enquesta
@@ -24,6 +24,9 @@ cs:
24
24
  settings:
25
25
  global:
26
26
  announcement: Oznámení
27
+ clean_after_publish: Odstranit odpovědi při publikování ankety
28
+ scope_id: Oblast působnosti
29
+ scopes_enabled: Oblasti působnosti povoleny
27
30
  step:
28
31
  allow_answers: Povolte odpovědi
29
32
  allow_unregistered: Umožnit neregistrovaným uživatelům odpovědět na průzkum
@@ -0,0 +1 @@
1
+ da:
@@ -20,6 +20,9 @@ de:
20
20
  settings:
21
21
  global:
22
22
  announcement: Ankündigung
23
+ clean_after_publish: Antworten bei Veröffentlichung des Fragebogens löschen
24
+ scope_id: Bereich
25
+ scopes_enabled: Bereiche aktiviert
23
26
  step:
24
27
  allow_answers: Erlaube Antworten
25
28
  allow_unregistered: Nicht registrierten Benutzern die Beantwortung des Fragebogens erlauben
@@ -21,6 +21,9 @@ en:
21
21
  settings:
22
22
  global:
23
23
  announcement: Announcement
24
+ clean_after_publish: Delete answers when publishing the survey
25
+ scope_id: Scope
26
+ scopes_enabled: Scopes enabled
24
27
  step:
25
28
  allow_answers: Allow answers
26
29
  allow_unregistered: Allow unregistered users to answer the survey
@@ -0,0 +1 @@
1
+ eo:
@@ -20,6 +20,9 @@ es-MX:
20
20
  settings:
21
21
  global:
22
22
  announcement: Anuncio
23
+ clean_after_publish: Borrar respuestas al publicar la encuesta
24
+ scope_id: Ámbito
25
+ scopes_enabled: Ámbitos habilitados
23
26
  step:
24
27
  allow_answers: Permitir respuestas
25
28
  allow_unregistered: Permitir a las usuarias no registradas responder a la encuesta
@@ -20,6 +20,9 @@ es-PY:
20
20
  settings:
21
21
  global:
22
22
  announcement: Anuncio
23
+ clean_after_publish: Borrar respuestas al publicar la encuesta
24
+ scope_id: Ámbito
25
+ scopes_enabled: Ámbitos habilitados
23
26
  step:
24
27
  allow_answers: Permitir respuestas
25
28
  allow_unregistered: Permitir a las usuarias no registradas responder a la encuesta
@@ -20,6 +20,9 @@ es:
20
20
  settings:
21
21
  global:
22
22
  announcement: Aviso
23
+ clean_after_publish: Borrar respuestas al publicar la encuesta
24
+ scope_id: Ámbito
25
+ scopes_enabled: Ámbitos habilitados
23
26
  step:
24
27
  allow_answers: Permitir respuestas
25
28
  allow_unregistered: Permitir a las usuarias no registradas responder a la encuesta
@@ -0,0 +1 @@
1
+ et:
@@ -20,6 +20,9 @@ fi-pl:
20
20
  settings:
21
21
  global:
22
22
  announcement: Ilmoitus
23
+ clean_after_publish: Poista vastaukset julkaistaessa kysely
24
+ scope_id: Teema
25
+ scopes_enabled: Teemat käytössä
23
26
  step:
24
27
  allow_answers: Salli vastaukset
25
28
  allow_unregistered: Salli rekisteröitymättömien käyttäjien vastata tähän kyselyyn
@@ -20,6 +20,9 @@ fi:
20
20
  settings:
21
21
  global:
22
22
  announcement: Ilmoitus
23
+ clean_after_publish: Poista vastaukset julkaistaessa kysely
24
+ scope_id: Teema
25
+ scopes_enabled: Teemat käytössä
23
26
  step:
24
27
  allow_answers: Salli vastaukset
25
28
  allow_unregistered: Salli rekisteröitymättömien käyttäjien vastata tähän kyselyyn
@@ -20,6 +20,9 @@ fr-CA:
20
20
  settings:
21
21
  global:
22
22
  announcement: Annonce
23
+ clean_after_publish: Supprimer les réponses lors de la publication du sondage
24
+ scope_id: Secteur
25
+ scopes_enabled: Secteurs activés
23
26
  step:
24
27
  allow_answers: Autoriser les réponses
25
28
  allow_unregistered: Autoriser les utilisateurs non inscrits à répondre à l'enquête
@@ -20,6 +20,9 @@ fr:
20
20
  settings:
21
21
  global:
22
22
  announcement: Annonce
23
+ clean_after_publish: Supprimer les réponses lors de la publication de l'enquête
24
+ scope_id: Secteur
25
+ scopes_enabled: Secteurs activés
23
26
  step:
24
27
  allow_answers: Autoriser les réponses
25
28
  allow_unregistered: Autoriser les utilisateurs non inscrits à répondre à l'enquête
@@ -0,0 +1 @@
1
+ hr:
@@ -0,0 +1,25 @@
1
+ is:
2
+ decidim:
3
+ components:
4
+ surveys:
5
+ actions:
6
+ answer: Svara
7
+ name: Könnun
8
+ settings:
9
+ global:
10
+ announcement: Tilkynning
11
+ step:
12
+ allow_answers: Leyfa svörum
13
+ announcement: Tilkynning
14
+ events:
15
+ surveys:
16
+ survey_closed:
17
+ email_intro: Könnunin %{resource_title} í %{participatory_space_title} hefur verið lokuð.
18
+ email_outro: Þú hefur fengið þessa tilkynningu vegna þess að þú fylgist með %{participatory_space_title}. Þú getur hætt við að fá tilkynningar eftir fyrri tengilinn.
19
+ email_subject: Könnun er lokið í %{participatory_space_title}
20
+ notification_title: Könnunin <a href="%{resource_path}">%{resource_title}</a> í <a href="%{participatory_space_url}">%{participatory_space_title}</a> er lokið.
21
+ survey_opened:
22
+ email_intro: 'Könnunin %{resource_title} í %{participatory_space_title} er nú opin. Þú getur tekið þátt í henni frá þessari síðu:'
23
+ email_outro: Þú hefur fengið þessa tilkynningu vegna þess að þú fylgist með %{participatory_space_title}. Þú getur hætt við að fá tilkynningar eftir fyrri tengilinn.
24
+ email_subject: Ný könnun á %{participatory_space_title}
25
+ notification_title: Könnunin <a href="%{resource_path}">%{resource_title}</a> í <a href="%{participatory_space_url}">%{participatory_space_title}</a> er nú opin.
@@ -20,6 +20,7 @@ it:
20
20
  settings:
21
21
  global:
22
22
  announcement: Annuncio
23
+ clean_after_publish: Eliminare le risposte quando si pubblica il sondaggio
23
24
  step:
24
25
  allow_answers: Consenti risposte
25
26
  allow_unregistered: Consenti agli utenti non registrati di rispondere al sondaggio
@@ -18,6 +18,7 @@ ja:
18
18
  settings:
19
19
  global:
20
20
  announcement: お知らせ
21
+ clean_after_publish: アンケートを公開するときに回答を削除する
21
22
  step:
22
23
  allow_answers: 回答を許可
23
24
  allow_unregistered: 未登録ユーザーがアンケートに回答できるようにする
@@ -0,0 +1,60 @@
1
+ ja:
2
+ activemodel:
3
+ models:
4
+ decidim/surveys/closed_survey_event: アンケートが終了しました
5
+ decidim/surveys/opened_survey_event: アンケートを開始
6
+ activerecord:
7
+ models:
8
+ decidim/surveys/survey:
9
+ other: 調査
10
+ decidim/surveys/survey_answer:
11
+ other: 回答
12
+ decidim:
13
+ components:
14
+ surveys:
15
+ actions:
16
+ answer: 回答
17
+ name: 調査
18
+ settings:
19
+ global:
20
+ announcement: お知らせ
21
+ clean_after_publish: アンケートを公開するときに回答を削除する
22
+ scope_id: スコープ
23
+ scopes_enabled: スコープが有効
24
+ step:
25
+ allow_answers: 回答を許可
26
+ allow_unregistered: 未登録ユーザーがアンケートに回答できるようにする
27
+ allow_unregistered_help: 有効な場合、アンケートに回答するためにログインは必要ありません。 これにより、データが貧弱または信頼できない可能性があり、自動攻撃に対してより脆弱になります。注意して使用してください!
28
+ announcement: お知らせ
29
+ events:
30
+ surveys:
31
+ survey_closed:
32
+ email_intro: '%{resource_title} の調査 %{participatory_space_title} はクローズされました。'
33
+ email_outro: '%{participatory_space_title}をフォローしているため、この通知を受け取りました。前のリンクに続く通知の受信を停止することができます。'
34
+ email_subject: '%{participatory_space_title} でアンケートが完了しました'
35
+ notification_title: <a href="%{resource_path}">%{resource_title}の</a> <a href="%{participatory_space_url}">%{participatory_space_title}</a> の調査は終了しました。
36
+ survey_opened:
37
+ email_intro: '%{resource_title} のアンケート %{participatory_space_title} が公開されました。このページから参加できます:'
38
+ email_outro: '%{participatory_space_title}をフォローしているため、この通知を受け取りました。前のリンクに続く通知の受信を停止することができます。'
39
+ email_subject: '%{participatory_space_title} での新しい調査'
40
+ notification_title: <a href="%{resource_path}">%{resource_title}の</a> <a href="%{participatory_space_url}">%{participatory_space_title}の調査</a> が公開されました。
41
+ metrics:
42
+ survey_answers:
43
+ description: 回答したアンケート数
44
+ object: アンケートに対する答えは
45
+ title: アンケートへの回答
46
+ surveys:
47
+ admin:
48
+ exports:
49
+ survey_user_answers: アンケート参加者の回答
50
+ surveys:
51
+ update:
52
+ invalid: 調査の保存中に問題が発生しました。
53
+ success: アンケートを保存しました。
54
+ last_activity:
55
+ new_survey_at_html: "<span>新しい調査 %{link}</span>"
56
+ surveys:
57
+ answer:
58
+ invalid: アンケートの回答に問題がありました。
59
+ spam_detected: フォームに応答する際に問題が発生しました。もう一度試してみてください。
60
+ success: アンケートは正常に回答しました。
@@ -0,0 +1 @@
1
+ ko:
@@ -0,0 +1 @@
1
+ ko:
@@ -0,0 +1 @@
1
+ lt:
File without changes
@@ -0,0 +1 @@
1
+ mt:
@@ -20,6 +20,9 @@ nl:
20
20
  settings:
21
21
  global:
22
22
  announcement: Aankondiging
23
+ clean_after_publish: Verwijder antwoorden bij publicatie van de enquête
24
+ scope_id: Scope
25
+ scopes_enabled: Scopes ingeschakeld
23
26
  step:
24
27
  allow_answers: Antwoorden toestaan
25
28
  allow_unregistered: Sta niet-geregistreerde gebruikers toe om de enquête te beantwoorden
@@ -0,0 +1 @@
1
+ om:
@@ -1,7 +1,7 @@
1
1
  pl:
2
2
  activemodel:
3
3
  models:
4
- decidim/surveys/closed_survey_event: Ankieta zakończyła się
4
+ decidim/surveys/closed_survey_event: Ankieta zamknięta
5
5
  decidim/surveys/opened_survey_event: Rozpoczęto ankietę
6
6
  activerecord:
7
7
  models:
@@ -24,40 +24,43 @@ pl:
24
24
  settings:
25
25
  global:
26
26
  announcement: Ogłoszenie
27
+ clean_after_publish: Usuń odpowiedzi podczas publikowania ankiety
28
+ scope_id: Zakres
29
+ scopes_enabled: Zakresy włączone
27
30
  step:
28
- allow_answers: Pozwól odpowiedzi
31
+ allow_answers: Pozwól na wypełnianie
29
32
  allow_unregistered: Pozwól niezarejestrowanym użytkownikom wypełnić ankietę
30
- allow_unregistered_help: Jeśli jest aktywny, do wypełnienia ankiety nie będzie wymagane logowanie. Może to dać słabej jakości lub niewiarygodne dane i ankieta będzie bardziej podatna na automatyczne ataki. Zalecamy ostrożność!
33
+ allow_unregistered_help: Jeśli jest aktywna, do wypełnienia ankiety nie będzie wymagane logowanie. Może to doprowadzić do słabej jakości lub niewiarygodnych danych i ankieta będzie bardziej podatna na automatyczne ataki. Zalecamy ostrożność!
31
34
  announcement: Ogłoszenie
32
35
  events:
33
36
  surveys:
34
37
  survey_closed:
35
38
  email_intro: Ankieta %{resource_title} w %{participatory_space_title} została zamknięta.
36
- email_outro: Otrzymałeś to powiadomienie, ponieważ obserwujesz %{participatory_space_title}. Możesz przestać otrzymywać powiadomienia po poprzednim linku.
37
- email_subject: Ankieta zakończyła się w %{participatory_space_title}
39
+ email_outro: Otrzymałeś to powiadomienie, ponieważ obserwujesz %{participatory_space_title}. Możesz przestać otrzymywać powiadomienia po kliknięciu w poprzedni link.
40
+ email_subject: Ankieta w %{participatory_space_title} została zakończona
38
41
  notification_title: Ankieta <a href="%{resource_path}">%{resource_title}</a> w <a href="%{participatory_space_url}">%{participatory_space_title}</a> została zakończona.
39
42
  survey_opened:
40
- email_intro: 'Ankieta %{resource_title} w %{participatory_space_title} jest teraz otwarta. Możesz wziąć w nim udział z tej strony:'
41
- email_outro: Otrzymałeś to powiadomienie, ponieważ obserwujesz %{participatory_space_title}. Możesz przestać otrzymywać powiadomienia po poprzednim linku.
43
+ email_intro: 'Ankieta %{resource_title} w %{participatory_space_title} jest teraz otwarta. Możesz wypełnić na tej stronie:'
44
+ email_outro: Otrzymałeś to powiadomienie, ponieważ obserwujesz %{participatory_space_title}. Możesz przestać otrzymywać powiadomienia po kliknięciu w poprzedni link.
42
45
  email_subject: Nowa ankieta w %{participatory_space_title}
43
46
  notification_title: Ankieta <a href="%{resource_path}">%{resource_title}</a> w <a href="%{participatory_space_url}">%{participatory_space_title}</a> jest teraz otwarta.
44
47
  metrics:
45
48
  survey_answers:
46
- description: Liczba ankiet odebranych przez użytkowników
49
+ description: Liczba ankiet wypełnionych przez użytkowników
47
50
  object: odpowiedzi na ankiety
48
51
  title: Odpowiedzi na ankiety
49
52
  surveys:
50
53
  admin:
51
54
  exports:
52
- survey_user_answers: Odpowiedzi na pytania użytkowników
55
+ survey_user_answers: Odpowiedzi użytkowników na pytania z ankiety
53
56
  surveys:
54
57
  update:
55
- invalid: Podczas zapisywania ankiety wystąpiły błędy.
58
+ invalid: Podczas zapisywania ankiety wystąpił błąd.
56
59
  success: Ankieta została zapisana pomyślnie.
57
60
  last_activity:
58
- new_survey_at_html: "<span>Nowa ankieta na %{link}</span>"
61
+ new_survey_at_html: "<span>Nowa ankieta %{link}</span>"
59
62
  surveys:
60
63
  answer:
61
- invalid: Podczas odpowiadania na ankiet pojawiły się błędy.
62
- spam_detected: Wystąpił błąd podczas udzielania odpowiedzi w formularzu. Spróbuj ponownie.
63
- success: Twoja ankieta została przesłana.
64
+ invalid: Podczas wypełniania ankiety pojawił się błąd.
65
+ spam_detected: Wystąpił błąd podczas wypełniania formularza. Być może zostało to zrobione zbyt szybko, czy możesz spróbować ponownie?
66
+ success: Twoja ankieta została wypełniona.
@@ -20,6 +20,7 @@ pt:
20
20
  settings:
21
21
  global:
22
22
  announcement: Anúncio
23
+ clean_after_publish: Eliminar respostas ao publicar o inquérito
23
24
  step:
24
25
  allow_answers: Permitir respostas
25
26
  allow_unregistered: Permitir que utilizadores não registados respondam ao inquérito
@@ -22,6 +22,7 @@ ro:
22
22
  settings:
23
23
  global:
24
24
  announcement: Anunţ
25
+ clean_after_publish: Ștergeți răspunsurile la publicarea sondajului
25
26
  step:
26
27
  allow_answers: Permite răspunsuri
27
28
  allow_unregistered: Permite utilizatorilor neînregistrați să răspundă la chestionar
@@ -0,0 +1 @@
1
+ so:
@@ -20,6 +20,7 @@ sv:
20
20
  settings:
21
21
  global:
22
22
  announcement: Meddelande
23
+ clean_after_publish: Ta bort svar vid publicering av enkäten
23
24
  step:
24
25
  allow_answers: Tillåt svar
25
26
  allow_unregistered: Tillåt ej registrerade användare att besvara enkäten
@@ -0,0 +1 @@
1
+ ti:
@@ -0,0 +1 @@
1
+ vi:
@@ -0,0 +1 @@
1
+ vi:
@@ -0,0 +1,60 @@
1
+ zh-CN:
2
+ activemodel:
3
+ models:
4
+ decidim/surveys/closed_survey_event: 调查结束
5
+ decidim/surveys/opened_survey_event: 调查已开始
6
+ activerecord:
7
+ models:
8
+ decidim/surveys/survey:
9
+ other: 调查
10
+ decidim/surveys/survey_answer:
11
+ other: 答案
12
+ decidim:
13
+ components:
14
+ surveys:
15
+ actions:
16
+ answer: 答案
17
+ name: 调查
18
+ settings:
19
+ global:
20
+ announcement: 通 知
21
+ clean_after_publish: 在发布调查时删除答案
22
+ scope_id: 范围
23
+ scopes_enabled: 范围已启用
24
+ step:
25
+ allow_answers: 允许答案
26
+ allow_unregistered: 允许未注册用户回答调查
27
+ allow_unregistered_help: 如果激活,将不需要登录才能回答调查。 这可能导致数据不准确或不可靠,更容易受到自动攻击。请谨慎使用!
28
+ announcement: 通 知
29
+ events:
30
+ surveys:
31
+ survey_closed:
32
+ email_intro: '%{resource_title} 在 %{participatory_space_title} 中的调查已被关闭。'
33
+ email_outro: 您收到此通知是因为您正在关注 %{participatory_space_title}。您可以停止收到跟随上一个链接的通知。
34
+ email_subject: 调查已在 %{participatory_space_title} 完成
35
+ notification_title: 调查 <a href="%{resource_path}">%{resource_title}</a> 在 <a href="%{participatory_space_url}">%{participatory_space_title}</a> 已完成。
36
+ survey_opened:
37
+ email_intro: '调查 %{resource_title} %{participatory_space_title} 现已打开。您可以从这个页面参与:'
38
+ email_outro: 您收到此通知是因为您正在关注 %{participatory_space_title}。您可以停止收到跟随上一个链接的通知。
39
+ email_subject: '%{participatory_space_title} 的新调查'
40
+ notification_title: <a href="%{resource_path}">%{resource_title}</a> 在 <a href="%{participatory_space_url}">%{participatory_space_title}</a> 中的调查现已打开。
41
+ metrics:
42
+ survey_answers:
43
+ description: 参与者回答的调查次数
44
+ object: 调查答案
45
+ title: 对调查的答复
46
+ surveys:
47
+ admin:
48
+ exports:
49
+ survey_user_answers: 调查参与者答案
50
+ surveys:
51
+ update:
52
+ invalid: 保存调查时出现问题。
53
+ success: 调查保存成功。
54
+ last_activity:
55
+ new_survey_at_html: "<span>在 %{link}上的新调查</span>"
56
+ surveys:
57
+ answer:
58
+ invalid: 回答调查时出现问题。
59
+ spam_detected: 回答表单时出现问题。可能你太快了,你可以再试一次吗?
60
+ success: 调查回答成功。
@@ -0,0 +1 @@
1
+ zh-TW:
@@ -109,5 +109,6 @@ class CheckLegacyTables < ActiveRecord::Migration[5.2]
109
109
  end
110
110
  end
111
111
  end
112
+
112
113
  # rubocop:enable Style/GuardClause
113
114
  # rubocop:enable Rails/Output
@@ -10,10 +10,20 @@ module Decidim
10
10
  paths["lib/tasks"] = nil
11
11
 
12
12
  routes do
13
+ get "/answer/:session_token", to: "surveys#show", as: :show_survey
14
+ get "/answer/:session_token/export", to: "surveys#export_response", as: :export_response_survey
15
+ get "/answers", to: "surveys#index", as: :index_survey
16
+ get "/answer_options", to: "surveys#answer_options", as: :answer_options_survey
13
17
  put "/", to: "surveys#update", as: :survey
14
18
  root to: "surveys#edit"
15
19
  end
16
20
 
21
+ initializer "decidim.notifications.components" do
22
+ Decidim::EventsManager.subscribe(/^decidim\.events\.components/) do |event_name, data|
23
+ CleanSurveyAnswersJob.perform_later(event_name, data)
24
+ end
25
+ end
26
+
17
27
  def load_seed
18
28
  nil
19
29
  end
@@ -43,7 +43,7 @@ Decidim.register_component(:surveys) do |component|
43
43
  surveys.count
44
44
  end
45
45
 
46
- component.register_stat :answers_count, priority: Decidim::StatsRegistry::MEDIUM_PRIORITY do |components, start_at, end_at|
46
+ component.register_stat :answers_count, primary: true, priority: Decidim::StatsRegistry::MEDIUM_PRIORITY do |components, start_at, end_at|
47
47
  surveys = Decidim::Surveys::Survey.includes(:questionnaire).where(component: components)
48
48
  answers = Decidim::Forms::Answer.where(questionnaire: surveys.map(&:questionnaire))
49
49
  answers = answers.where("created_at >= ?", start_at) if start_at.present?
@@ -55,7 +55,10 @@ Decidim.register_component(:surveys) do |component|
55
55
  component.actions = %w(answer)
56
56
 
57
57
  component.settings(:global) do |settings|
58
+ settings.attribute :scopes_enabled, type: :boolean, default: false
59
+ settings.attribute :scope_id, type: :scope
58
60
  settings.attribute :announcement, type: :text, translated: true, editor: true
61
+ settings.attribute :clean_after_publish, type: :boolean, default: true
59
62
  end
60
63
 
61
64
  component.settings(:step) do |settings|
@@ -70,6 +73,8 @@ Decidim.register_component(:surveys) do |component|
70
73
  Decidim::Forms::QuestionnaireUserAnswers.for(survey.questionnaire)
71
74
  end
72
75
 
76
+ exports.formats %w(CSV JSON Excel FormPDF)
77
+
73
78
  exports.serializer Decidim::Forms::UserAnswersSerializer
74
79
  end
75
80
 
@@ -117,24 +122,33 @@ Decidim.register_component(:surveys) do |component|
117
122
  visibility: "all"
118
123
  )
119
124
 
120
- %w(short_answer long_answer).each do |text_question_type|
125
+ %w(short_answer long_answer).each_with_index do |text_question_type, index|
121
126
  Decidim::Forms::Question.create!(
122
127
  questionnaire: questionnaire,
123
128
  body: Decidim::Faker::Localized.paragraph,
124
- question_type: text_question_type
129
+ question_type: text_question_type,
130
+ position: index
125
131
  )
126
132
  end
127
133
 
128
- %w(single_option multiple_option).each do |multiple_choice_question_type|
134
+ %w(single_option multiple_option).each_with_index do |multiple_choice_question_type, index|
129
135
  question = Decidim::Forms::Question.create!(
130
136
  questionnaire: questionnaire,
131
137
  body: Decidim::Faker::Localized.paragraph,
132
- question_type: multiple_choice_question_type
138
+ question_type: multiple_choice_question_type,
139
+ position: index + 2
133
140
  )
134
141
 
135
142
  3.times do
136
143
  question.answer_options.create!(body: Decidim::Faker::Localized.sentence)
137
144
  end
145
+
146
+ question.display_conditions.create!(
147
+ condition_question: questionnaire.questions.find_by(position: question.position - 2),
148
+ question: question,
149
+ condition_type: :answered,
150
+ mandatory: true
151
+ )
138
152
  end
139
153
 
140
154
  %w(matrix_single matrix_multiple).each do |matrix_question_type|
@@ -12,7 +12,7 @@ FactoryBot.define do
12
12
  end
13
13
 
14
14
  factory :survey, class: "Decidim::Surveys::Survey" do
15
- questionnaire { build(:questionnaire) }
15
+ questionnaire { build(:questionnaire, :with_questions) }
16
16
  component { build(:surveys_component) }
17
17
  end
18
18
  end
@@ -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.22.0"
7
+ "0.23.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.22.0
4
+ version: 0.23.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: 2020-09-01 00:00:00.000000000 Z
13
+ date: 2020-11-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: decidim-core
@@ -18,70 +18,84 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.22.0
21
+ version: 0.23.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.22.0
28
+ version: 0.23.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: decidim-forms
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 0.22.0
35
+ version: 0.23.0
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.22.0
42
+ version: 0.23.0
43
+ - !ruby/object:Gem::Dependency
44
+ name: decidim-templates
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '='
48
+ - !ruby/object:Gem::Version
49
+ version: 0.23.0
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '='
55
+ - !ruby/object:Gem::Version
56
+ version: 0.23.0
43
57
  - !ruby/object:Gem::Dependency
44
58
  name: decidim-admin
45
59
  requirement: !ruby/object:Gem::Requirement
46
60
  requirements:
47
61
  - - '='
48
62
  - !ruby/object:Gem::Version
49
- version: 0.22.0
63
+ version: 0.23.0
50
64
  type: :development
51
65
  prerelease: false
52
66
  version_requirements: !ruby/object:Gem::Requirement
53
67
  requirements:
54
68
  - - '='
55
69
  - !ruby/object:Gem::Version
56
- version: 0.22.0
70
+ version: 0.23.0
57
71
  - !ruby/object:Gem::Dependency
58
72
  name: decidim-dev
59
73
  requirement: !ruby/object:Gem::Requirement
60
74
  requirements:
61
75
  - - '='
62
76
  - !ruby/object:Gem::Version
63
- version: 0.22.0
77
+ version: 0.23.0
64
78
  type: :development
65
79
  prerelease: false
66
80
  version_requirements: !ruby/object:Gem::Requirement
67
81
  requirements:
68
82
  - - '='
69
83
  - !ruby/object:Gem::Version
70
- version: 0.22.0
84
+ version: 0.23.0
71
85
  - !ruby/object:Gem::Dependency
72
86
  name: decidim-participatory_processes
73
87
  requirement: !ruby/object:Gem::Requirement
74
88
  requirements:
75
89
  - - '='
76
90
  - !ruby/object:Gem::Version
77
- version: 0.22.0
91
+ version: 0.23.0
78
92
  type: :development
79
93
  prerelease: false
80
94
  version_requirements: !ruby/object:Gem::Requirement
81
95
  requirements:
82
96
  - - '='
83
97
  - !ruby/object:Gem::Version
84
- version: 0.22.0
98
+ version: 0.23.0
85
99
  description: A surveys component for decidim's participatory spaces.
86
100
  email:
87
101
  - josepjaume@gmail.com
@@ -103,6 +117,7 @@ files:
103
117
  - app/events/decidim/surveys/closed_survey_event.rb
104
118
  - app/events/decidim/surveys/opened_survey_event.rb
105
119
  - app/helpers/decidim/surveys/survey_helper.rb
120
+ - app/jobs/decidim/surveys/clean_survey_answers_job.rb
106
121
  - app/jobs/decidim/surveys/settings_change_job.rb
107
122
  - app/models/decidim/surveys/application_record.rb
108
123
  - app/models/decidim/surveys/survey.rb
@@ -115,22 +130,27 @@ files:
115
130
  - app/types/decidim/surveys/survey_type.rb
116
131
  - app/types/decidim/surveys/surveys_type.rb
117
132
  - app/views/decidim/surveys/surveys/no_permission.html.erb
133
+ - config/locales/am-ET.yml
118
134
  - config/locales/ar-SA.yml
119
135
  - config/locales/ar.yml
120
136
  - config/locales/bg-BG.yml
137
+ - config/locales/bg.yml
121
138
  - config/locales/ca.yml
122
139
  - config/locales/cs-CZ.yml
123
140
  - config/locales/cs.yml
124
141
  - config/locales/da-DK.yml
142
+ - config/locales/da.yml
125
143
  - config/locales/de.yml
126
144
  - config/locales/el-GR.yml
127
145
  - config/locales/el.yml
128
146
  - config/locales/en.yml
129
147
  - config/locales/eo-UY.yml
148
+ - config/locales/eo.yml
130
149
  - config/locales/es-MX.yml
131
150
  - config/locales/es-PY.yml
132
151
  - config/locales/es.yml
133
152
  - config/locales/et-EE.yml
153
+ - config/locales/et.yml
134
154
  - config/locales/eu.yml
135
155
  - config/locales/fi-pl.yml
136
156
  - config/locales/fi-plain.yml
@@ -140,16 +160,24 @@ files:
140
160
  - config/locales/ga-IE.yml
141
161
  - config/locales/gl.yml
142
162
  - config/locales/hr-HR.yml
163
+ - config/locales/hr.yml
143
164
  - config/locales/hu.yml
144
165
  - config/locales/id-ID.yml
145
166
  - config/locales/is-IS.yml
167
+ - config/locales/is.yml
146
168
  - config/locales/it.yml
147
169
  - config/locales/ja-JP.yml
170
+ - config/locales/ja.yml
171
+ - config/locales/ko-KR.yml
172
+ - config/locales/ko.yml
148
173
  - config/locales/lt-LT.yml
149
- - config/locales/lv-LV.yml
174
+ - config/locales/lt.yml
175
+ - config/locales/lv.yml
150
176
  - config/locales/mt-MT.yml
177
+ - config/locales/mt.yml
151
178
  - config/locales/nl.yml
152
179
  - config/locales/no.yml
180
+ - config/locales/om-ET.yml
153
181
  - config/locales/pl.yml
154
182
  - config/locales/pt-BR.yml
155
183
  - config/locales/pt.yml
@@ -158,10 +186,16 @@ files:
158
186
  - config/locales/sk-SK.yml
159
187
  - config/locales/sk.yml
160
188
  - config/locales/sl.yml
189
+ - config/locales/so-SO.yml
161
190
  - config/locales/sr-CS.yml
162
191
  - config/locales/sv.yml
192
+ - config/locales/ti-ER.yml
163
193
  - config/locales/tr-TR.yml
164
194
  - config/locales/uk.yml
195
+ - config/locales/vi-VN.yml
196
+ - config/locales/vi.yml
197
+ - config/locales/zh-CN.yml
198
+ - config/locales/zh-TW.yml
165
199
  - db/migrate/20170511092231_create_decidim_surveys.rb
166
200
  - db/migrate/20170515090916_create_decidim_survey_questions.rb
167
201
  - db/migrate/20170515144119_create_decidim_survey_answers.rb
@@ -204,14 +238,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
204
238
  requirements:
205
239
  - - ">="
206
240
  - !ruby/object:Gem::Version
207
- version: '2.5'
241
+ version: '2.6'
208
242
  required_rubygems_version: !ruby/object:Gem::Requirement
209
243
  requirements:
210
244
  - - ">="
211
245
  - !ruby/object:Gem::Version
212
246
  version: '0'
213
247
  requirements: []
214
- rubygems_version: 3.1.2
248
+ rubygems_version: 3.0.3
215
249
  signing_key:
216
250
  specification_version: 4
217
251
  summary: Decidim surveys module