decidim-surveys 0.27.9 → 0.28.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/cells/decidim/surveys/survey_activity_cell.rb +1 -4
- data/app/controllers/decidim/surveys/admin/surveys_controller.rb +7 -1
- data/app/controllers/decidim/surveys/surveys_controller.rb +3 -1
- data/app/helpers/decidim/surveys/survey_helper.rb +1 -3
- data/app/jobs/decidim/surveys/clean_survey_answers_job.rb +1 -1
- data/app/jobs/decidim/surveys/settings_change_job.rb +2 -2
- data/app/mailers/decidim/surveys/survey_confirmation_mailer.rb +39 -0
- data/app/serializers/decidim/surveys/data_serializer.rb +1 -1
- data/app/views/decidim/surveys/admin/component/_actions.html.erb +17 -16
- data/app/views/decidim/surveys/admin/surveys/edit.html.erb +40 -0
- data/app/views/decidim/surveys/survey_confirmation_mailer/confirmation.html.erb +3 -0
- data/app/views/decidim/surveys/surveys/no_permission.html.erb +1 -1
- data/config/assets.rb +0 -1
- data/config/locales/ar.yml +0 -2
- data/config/locales/bg.yml +1 -62
- data/config/locales/ca.yml +9 -4
- data/config/locales/cs.yml +7 -2
- data/config/locales/de.yml +7 -2
- data/config/locales/el.yml +2 -2
- data/config/locales/en.yml +7 -2
- data/config/locales/es-MX.yml +7 -2
- data/config/locales/es-PY.yml +7 -2
- data/config/locales/es.yml +9 -4
- data/config/locales/eu.yml +7 -2
- data/config/locales/fi-plain.yml +7 -2
- data/config/locales/fi.yml +8 -3
- data/config/locales/fr-CA.yml +5 -2
- data/config/locales/fr.yml +7 -2
- data/config/locales/gl.yml +0 -3
- data/config/locales/hu.yml +0 -3
- data/config/locales/id-ID.yml +0 -2
- data/config/locales/it.yml +0 -3
- data/config/locales/ja.yml +2 -5
- data/config/locales/lb.yml +0 -3
- data/config/locales/lt.yml +2 -2
- data/config/locales/lv.yml +0 -3
- data/config/locales/nl.yml +0 -3
- data/config/locales/no.yml +0 -3
- data/config/locales/pl.yml +1 -8
- data/config/locales/pt-BR.yml +0 -7
- data/config/locales/pt.yml +0 -3
- data/config/locales/ro-RO.yml +2 -2
- data/config/locales/sk.yml +0 -3
- data/config/locales/sv.yml +3 -9
- data/config/locales/tr-TR.yml +0 -3
- data/config/locales/zh-CN.yml +0 -3
- data/config/locales/zh-TW.yml +2 -2
- data/db/migrate/20200609090533_check_legacy_tables.rb +5 -5
- data/lib/decidim/surveys/admin_engine.rb +1 -1
- data/lib/decidim/surveys/component.rb +6 -89
- data/lib/decidim/surveys/engine.rb +20 -1
- data/lib/decidim/surveys/seeds.rb +103 -0
- data/lib/decidim/surveys/test/factories.rb +5 -10
- data/lib/decidim/surveys/version.rb +1 -1
- data/lib/tasks/decidim_surveys_tasks.rake +4 -4
- metadata +35 -29
- data/app/packs/stylesheets/decidim/surveys/_surveys.scss +0 -67
- data/config/locales/he-IL.yml +0 -1
- data/decidim-surveys.gemspec +0 -35
data/config/locales/fr.yml
CHANGED
@@ -64,9 +64,14 @@ fr:
|
|
64
64
|
invalid: Erreurs lors de la sauvegarde de l'enquête.
|
65
65
|
success: Enquête enregistrée avec succès.
|
66
66
|
last_activity:
|
67
|
-
|
67
|
+
new_survey: 'Nouvelle enquête :'
|
68
|
+
survey_confirmation_mailer:
|
69
|
+
confirmation:
|
70
|
+
body: Vous avez répondu avec succès à l'enquête %{questionnaire_title} dans %{participatory_space}
|
71
|
+
subject: Questionnaire %{questionnaire_title} répondant à la confirmation
|
72
|
+
export_name: Réponses au questionnaire
|
68
73
|
surveys:
|
69
74
|
answer:
|
70
75
|
invalid: Votre réponse à l'enquête comporte des erreurs.
|
71
|
-
spam_detected:
|
76
|
+
spam_detected: Une erreur est survenue lorsque vous avez répondu au questionnaire. Pouvez-vous réessayer ?
|
72
77
|
success: Votre réponse à l'enquête a bien été enregistrée.
|
data/config/locales/gl.yml
CHANGED
@@ -59,10 +59,7 @@ gl:
|
|
59
59
|
update:
|
60
60
|
invalid: Houbo erros ao gardar a enquisa.
|
61
61
|
success: A enquisa gardouse correctamente.
|
62
|
-
last_activity:
|
63
|
-
new_survey_at_html: "<span>Nova enquisa en %{link}</span>"
|
64
62
|
surveys:
|
65
63
|
answer:
|
66
64
|
invalid: Houbo erros ao responder a enquisa.
|
67
|
-
spam_detected: Produciuse un problema ao contestar o formulario. É posíbel que o fixeras rápido de máis, podes tentalo de novo?
|
68
65
|
success: A enquisa respondeu con éxito.
|
data/config/locales/hu.yml
CHANGED
@@ -50,10 +50,7 @@ hu:
|
|
50
50
|
update:
|
51
51
|
invalid: Hiba történt a felmérés mentése során.
|
52
52
|
success: Felmérés mentése sikeres.
|
53
|
-
last_activity:
|
54
|
-
new_survey_at_html: "<span>Új felmérés %{link}</span>kor"
|
55
53
|
surveys:
|
56
54
|
answer:
|
57
55
|
invalid: Hiba történt a felmérés megválaszolása során.
|
58
|
-
spam_detected: Probléma történt az űrlap megválaszolása során. Lehet, hogy túl gyorsan próbálkoztál, megpróbálnád újra?
|
59
56
|
success: Felmérés kitöltése sikeres.
|
data/config/locales/id-ID.yml
CHANGED
data/config/locales/it.yml
CHANGED
@@ -59,10 +59,7 @@ it:
|
|
59
59
|
update:
|
60
60
|
invalid: Ci sono stati degli errori durante il salvataggio del sondaggio.
|
61
61
|
success: Sondaggio salvato correttamente.
|
62
|
-
last_activity:
|
63
|
-
new_survey_at_html: "<span>Nuovo sondaggio al %{link}</span>"
|
64
62
|
surveys:
|
65
63
|
answer:
|
66
64
|
invalid: Ci sono stati errori nel rispondere al sondaggio.
|
67
|
-
spam_detected: C'è stato un problema nelle risposte ai quesiti. Forse sei stato troppo veloce, puoi riprovare?
|
68
65
|
success: Le risposte sono state registrate correttamente.
|
data/config/locales/ja.yml
CHANGED
@@ -52,9 +52,6 @@ ja:
|
|
52
52
|
answers_count: 回答
|
53
53
|
surveys:
|
54
54
|
admin:
|
55
|
-
component:
|
56
|
-
actions:
|
57
|
-
answers_alert: コンポーネントを公開すると、すべての結果が削除されます。
|
58
55
|
exports:
|
59
56
|
survey_user_answers: アンケート参加者の回答
|
60
57
|
surveys:
|
@@ -62,9 +59,9 @@ ja:
|
|
62
59
|
invalid: 調査の保存中に問題が発生しました。
|
63
60
|
success: アンケートを保存しました。
|
64
61
|
last_activity:
|
65
|
-
|
62
|
+
new_survey: '新しいアンケート:'
|
66
63
|
surveys:
|
67
64
|
answer:
|
68
65
|
invalid: アンケートの回答に問題がありました。
|
69
|
-
spam_detected:
|
66
|
+
spam_detected: フォームでの回答中に問題が発生しました。もしかしたら回答が早すぎたかもしれません。再度お試しいただけますか?
|
70
67
|
success: アンケートは正常に回答しました。
|
data/config/locales/lb.yml
CHANGED
@@ -59,10 +59,7 @@ lb:
|
|
59
59
|
update:
|
60
60
|
invalid: Beim Speichern der Umfrage sind Fehler aufgetreten.
|
61
61
|
success: Umfrage wurde erfolgreich gespeichert.
|
62
|
-
last_activity:
|
63
|
-
new_survey_at_html: "<span>Neue Umfrage bei %{link}</span>"
|
64
62
|
surveys:
|
65
63
|
answer:
|
66
64
|
invalid: Bei der Beantwortung der Umfrage sind Fehler aufgetreten.
|
67
|
-
spam_detected: Bei der Beantwortung des Fragebogens sind Fehler aufgetreten. Möglicherweise waren Sie zu schnell. Versuchen Sie es vielleicht erneut.
|
68
65
|
success: Umfrage erfolgreich beantwortet.
|
data/config/locales/lt.yml
CHANGED
@@ -65,9 +65,9 @@ lt:
|
|
65
65
|
invalid: Išsaugant šią apklausą iškilo problema.
|
66
66
|
success: Apklausa išsaugota.
|
67
67
|
last_activity:
|
68
|
-
|
68
|
+
new_survey: 'Nauja apklausa:'
|
69
69
|
surveys:
|
70
70
|
answer:
|
71
71
|
invalid: Atsakant į šios apklausos klausimus iškilo problema.
|
72
|
-
spam_detected: Atsakant į
|
72
|
+
spam_detected: Atsakant į šią formą iškilo problema. Galbūt paskubėjote? Ar galite pabandyti dar kartą?
|
73
73
|
success: Į apklausos klausimus atsakyta.
|
data/config/locales/lv.yml
CHANGED
@@ -52,10 +52,7 @@ lv:
|
|
52
52
|
update:
|
53
53
|
invalid: Saglabājot aptauju, radās problēma.
|
54
54
|
success: Aptauja ir veiksmīgi saglabāta
|
55
|
-
last_activity:
|
56
|
-
new_survey_at_html: "<span>Jauna aptauja %{link}</span>"
|
57
55
|
surveys:
|
58
56
|
answer:
|
59
57
|
invalid: Atbildot uz aptauju, radās problēma.
|
60
|
-
spam_detected: Atbildot uz aptaujas jautājumiem, radās problēma. Varbūt jūs esat rīkojies pārāk ātri, vai varat mēģināt vēlreiz?
|
61
58
|
success: Uz aptaujas jautājumiem ir veiksmīgi atbildēts.
|
data/config/locales/nl.yml
CHANGED
@@ -59,10 +59,7 @@ nl:
|
|
59
59
|
update:
|
60
60
|
invalid: Er is een probleem opgetreden bij het opslaan van de enquête.
|
61
61
|
success: Enquête succesvol opgeslagen.
|
62
|
-
last_activity:
|
63
|
-
new_survey_at_html: "<span>Nieuwe enquête op %{link}</span>"
|
64
62
|
surveys:
|
65
63
|
answer:
|
66
64
|
invalid: Er is een fout opgetreden bij het opslaan van de pagina.
|
67
|
-
spam_detected: Er was een probleem bij het beantwoorden van het formulier. Misschien bent u te snel geweest, kunt u het opnieuw proberen?
|
68
65
|
success: Enquête met succes beantwoord.
|
data/config/locales/no.yml
CHANGED
@@ -59,10 +59,7 @@
|
|
59
59
|
update:
|
60
60
|
invalid: Det oppstod et problem med å lagre undersøkelsen.
|
61
61
|
success: Undersøkelsen ble lagret.
|
62
|
-
last_activity:
|
63
|
-
new_survey_at_html: "<span>Ny undersøkelse på %{link}</span>"
|
64
62
|
surveys:
|
65
63
|
answer:
|
66
64
|
invalid: Det oppstod et problem med å svare på undersøkelsen.
|
67
|
-
spam_detected: Det oppstod et problem med å svare på skjemaet. Kanskje du har vært for rask, kan du prøve igjen?
|
68
65
|
success: Undersøkelsen ble besvart.
|
data/config/locales/pl.yml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
pl:
|
3
3
|
activemodel:
|
4
4
|
models:
|
5
|
-
decidim/surveys/closed_survey_event: Ankieta
|
5
|
+
decidim/surveys/closed_survey_event: Ankieta zamknięta
|
6
6
|
decidim/surveys/opened_survey_event: Rozpoczęto ankietę
|
7
7
|
activerecord:
|
8
8
|
models:
|
@@ -35,7 +35,6 @@ pl:
|
|
35
35
|
step:
|
36
36
|
allow_answers: Pozwól na wypełnianie
|
37
37
|
allow_unregistered: Pozwól niezarejestrowanym użytkownikom wypełnić ankietę
|
38
|
-
allow_unregistered_help: Jeśli to ustawienie jest w użyciu, logowanie nie jest wymagane aby odpowiedzieć na ankietę. Może to prowadzić do słabych lub nierzetelnych danych i będzie bardziej podatne na zautomatyzowane ataki. Należy zachować ostrożność! Pamiętaj, że uczestnik może odpowiedzieć na to samo badanie wielokrotnie, korzystając z różnych przeglądarek lub funkcji "prywatne przeglądanie" swojej przeglądarki internetowej.
|
39
38
|
announcement: Ogłoszenie
|
40
39
|
events:
|
41
40
|
surveys:
|
@@ -58,19 +57,13 @@ pl:
|
|
58
57
|
answers_count: Odpowiedzi
|
59
58
|
surveys:
|
60
59
|
admin:
|
61
|
-
component:
|
62
|
-
actions:
|
63
|
-
answers_alert: Po opublikowaniu komponentu wszystkie wyniki zostaną usunięte.
|
64
60
|
exports:
|
65
61
|
survey_user_answers: Odpowiedzi użytkowników na pytania z ankiety
|
66
62
|
surveys:
|
67
63
|
update:
|
68
64
|
invalid: Podczas zapisywania ankiety wystąpił błąd.
|
69
65
|
success: Ankieta została zapisana pomyślnie.
|
70
|
-
last_activity:
|
71
|
-
new_survey_at_html: "<span>Nowa ankieta %{link}</span>"
|
72
66
|
surveys:
|
73
67
|
answer:
|
74
68
|
invalid: Podczas wypełniania ankiety wystąpił błąd.
|
75
|
-
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?
|
76
69
|
success: Twoja ankieta została wypełniona.
|
data/config/locales/pt-BR.yml
CHANGED
@@ -31,7 +31,6 @@ pt-BR:
|
|
31
31
|
step:
|
32
32
|
allow_answers: Permitir respostas
|
33
33
|
allow_unregistered: Permitir que usuários não registrados respondam à pesquisa
|
34
|
-
allow_unregistered_help: Se ativo, nenhum login será necessário para responder a pesquisa. Isso pode levar a dados ruins ou não confiáveis e será mais vulnerável a ataques automatizados. Usar com cuidado! Lembre-se de que um usuário pode responder à mesma pesquisa várias vezes, usando navegadores diferentes ou a função "navegação privada" de seu navegador.
|
35
34
|
announcement: Anúncio
|
36
35
|
events:
|
37
36
|
surveys:
|
@@ -54,19 +53,13 @@ pt-BR:
|
|
54
53
|
answers_count: Respostas
|
55
54
|
surveys:
|
56
55
|
admin:
|
57
|
-
component:
|
58
|
-
actions:
|
59
|
-
answers_alert: Se você publicar o componente, todos os resultados serão removidos.
|
60
56
|
exports:
|
61
57
|
survey_user_answers: Avalie as respostas dos usuários
|
62
58
|
surveys:
|
63
59
|
update:
|
64
60
|
invalid: Houve erros ao salvar a pesquisa.
|
65
61
|
success: Pesquisa salva com sucesso.
|
66
|
-
last_activity:
|
67
|
-
new_survey_at_html: "<span>Nova pesquisa em %{link}</span>"
|
68
62
|
surveys:
|
69
63
|
answer:
|
70
64
|
invalid: Houve erros ao responder a pesquisa.
|
71
|
-
spam_detected: Houve algum problema ao responder ao formulário. Talvez você tenha sido rápido demais, pode tentar novamente?
|
72
65
|
success: Pesquisa respondida com sucesso.
|
data/config/locales/pt.yml
CHANGED
@@ -59,10 +59,7 @@ pt:
|
|
59
59
|
update:
|
60
60
|
invalid: Ocorreu um problema ao guardar o inquérito.
|
61
61
|
success: Inquérito guardado corretamente.
|
62
|
-
last_activity:
|
63
|
-
new_survey_at_html: "<span>Novo inquérito em %{link}</span>"
|
64
62
|
surveys:
|
65
63
|
answer:
|
66
64
|
invalid: Ocorreu um problema ao responder ao inquérito.
|
67
|
-
spam_detected: Ocorreu um problema ao responder ao formulário. Talvez tenha sido demasiado rápido, pode tentar novamente?
|
68
65
|
success: Inquérito respondido corretamente.
|
data/config/locales/ro-RO.yml
CHANGED
@@ -63,9 +63,9 @@ ro:
|
|
63
63
|
invalid: A apărut o eroare la salvarea sondajului.
|
64
64
|
success: Sondajul a fost salvat cu succes.
|
65
65
|
last_activity:
|
66
|
-
|
66
|
+
new_survey: 'Sondaj nou:'
|
67
67
|
surveys:
|
68
68
|
answer:
|
69
69
|
invalid: A apărut o problemă în timpul răspunsului pentru sondaj.
|
70
|
-
spam_detected: A apărut o problemă
|
70
|
+
spam_detected: A apărut o problemă la completarea formularului. Poate că ați fost prea rapid(ă), puteți încerca din nou?
|
71
71
|
success: Răspunsul pentru sondaj a fost înregistrat cu succes.
|
data/config/locales/sk.yml
CHANGED
@@ -54,10 +54,7 @@ sk:
|
|
54
54
|
update:
|
55
55
|
invalid: Vyskytol sa problém s ukladaním prieskumu.
|
56
56
|
success: Prieskum úspešne uložený.
|
57
|
-
last_activity:
|
58
|
-
new_survey_at_html: "<span>Nový prieskum na %{link}</span>"
|
59
57
|
surveys:
|
60
58
|
answer:
|
61
59
|
invalid: Vyskytol sa problém s odpovedaním na prieskum.
|
62
|
-
spam_detected: Vyskytol sa problém s odpovedaním na formulár. Možno ste boli príliš rýchli, skúste prosíme znovu.
|
63
60
|
success: Odpoveď úspešne zaznamenaná.
|
data/config/locales/sv.yml
CHANGED
@@ -23,9 +23,9 @@ sv:
|
|
23
23
|
announcement: Meddelande
|
24
24
|
clean_after_publish: Ta bort svar vid publicering av enkäten
|
25
25
|
ends_at: Svar accepterade tills
|
26
|
-
ends_at_help: Lämna tomt för
|
27
|
-
scope_id:
|
28
|
-
scopes_enabled:
|
26
|
+
ends_at_help: Lämna tomt för inget slutdatum
|
27
|
+
scope_id: Omfång
|
28
|
+
scopes_enabled: Omfång aktiverade
|
29
29
|
starts_at: Svar accepterade från
|
30
30
|
starts_at_help: Lämna tomt för inget startdatum
|
31
31
|
step:
|
@@ -54,19 +54,13 @@ sv:
|
|
54
54
|
answers_count: Svar
|
55
55
|
surveys:
|
56
56
|
admin:
|
57
|
-
component:
|
58
|
-
actions:
|
59
|
-
answers_alert: Om du publicerar komponenten kommer alla resultat att tas bort.
|
60
57
|
exports:
|
61
58
|
survey_user_answers: Svar från enkätdeltagarna
|
62
59
|
surveys:
|
63
60
|
update:
|
64
61
|
invalid: Det gick inte att spara enkäten.
|
65
62
|
success: Enkäten har sparats.
|
66
|
-
last_activity:
|
67
|
-
new_survey_at_html: "<span>Ny enkät på %{link}</span>"
|
68
63
|
surveys:
|
69
64
|
answer:
|
70
65
|
invalid: Det gick inte att besvara enkäten.
|
71
|
-
spam_detected: Det gick inte att svara på formuläret. Du hade kanske för bråttom, kan du försöka igen?
|
72
66
|
success: Enkäten har besvarats.
|
data/config/locales/tr-TR.yml
CHANGED
@@ -57,10 +57,7 @@ tr:
|
|
57
57
|
update:
|
58
58
|
invalid: Anketi kaydederken bir sorun oluştu.
|
59
59
|
success: Anket başarıyla kaydedildi.
|
60
|
-
last_activity:
|
61
|
-
new_survey_at_html: "<span> %{link}</span> linkinde yeni anket"
|
62
60
|
surveys:
|
63
61
|
answer:
|
64
62
|
invalid: Anketi cevaplarken bir sorun oluştu.
|
65
|
-
spam_detected: Formu yanıtlarken bir sorun oluştu. Belki çok hızlı davrandın, tekrar deneyebilir misin?
|
66
63
|
success: Anket başarıyla cevaplandı.
|
data/config/locales/zh-CN.yml
CHANGED
data/config/locales/zh-TW.yml
CHANGED
@@ -59,9 +59,9 @@ zh-TW:
|
|
59
59
|
invalid: 儲存問卷時出現問題。
|
60
60
|
success: 問卷成功儲存
|
61
61
|
last_activity:
|
62
|
-
|
62
|
+
new_survey: '新問卷調查'
|
63
63
|
surveys:
|
64
64
|
answer:
|
65
65
|
invalid: 回答問卷時出現問題。
|
66
|
-
spam_detected:
|
66
|
+
spam_detected: 回答表單時出現問題。也許您回答太快了,可以再試一次嗎?
|
67
67
|
success: 問卷回答成功。
|
@@ -28,7 +28,7 @@ class CheckLegacyTables < ActiveRecord::Migration[5.2]
|
|
28
28
|
puts "Migrate or backup your data and then remove the following raise statement to continue with the migrations (that will remove surveys legacy tables)"
|
29
29
|
puts "For migrating your data you can do that with the command:"
|
30
30
|
puts "bundle exec rake decidim_surveys:migrate_data_to_decidim_forms"
|
31
|
-
raise "ERROR: there
|
31
|
+
raise "ERROR: there is the risk to loose legacy information from old surveys!"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -61,7 +61,7 @@ class CheckLegacyTables < ActiveRecord::Migration[5.2]
|
|
61
61
|
puts "Migrating question #{survey_question.id}..."
|
62
62
|
|
63
63
|
question = ::Decidim::Forms::Question.create!(
|
64
|
-
questionnaire
|
64
|
+
questionnaire:,
|
65
65
|
position: survey_question.position,
|
66
66
|
question_type: survey_question.question_type,
|
67
67
|
mandatory: survey_question.mandatory,
|
@@ -77,7 +77,7 @@ class CheckLegacyTables < ActiveRecord::Migration[5.2]
|
|
77
77
|
|
78
78
|
AnswerOption.where(decidim_survey_question_id: survey_question.id).find_each do |survey_answer_option|
|
79
79
|
answer_option_mapping[survey_answer_option.id] = ::Decidim::Forms::AnswerOption.create!(
|
80
|
-
question
|
80
|
+
question:,
|
81
81
|
body: survey_answer_option.body,
|
82
82
|
free_text: survey_answer_option.free_text
|
83
83
|
)
|
@@ -85,8 +85,8 @@ class CheckLegacyTables < ActiveRecord::Migration[5.2]
|
|
85
85
|
|
86
86
|
Answer.where(decidim_survey_id: survey.id, decidim_survey_question_id: survey_question.id).find_each do |survey_answer|
|
87
87
|
answer = ::Decidim::Forms::Answer.new(
|
88
|
-
questionnaire
|
89
|
-
question
|
88
|
+
questionnaire:,
|
89
|
+
question:,
|
90
90
|
decidim_user_id: survey_answer.decidim_user_id,
|
91
91
|
body: survey_answer.body,
|
92
92
|
created_at: survey_answer.created_at,
|
@@ -18,7 +18,7 @@ module Decidim
|
|
18
18
|
root to: "surveys#edit"
|
19
19
|
end
|
20
20
|
|
21
|
-
initializer "
|
21
|
+
initializer "decidim_surveys_admin.notifications.components" do
|
22
22
|
config.to_prepare do
|
23
23
|
Decidim::EventsManager.subscribe(/^decidim\.events\.components/) do |event_name, data|
|
24
24
|
CleanSurveyAnswersJob.perform_later(event_name, data)
|
@@ -1,11 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "decidim/components/namer"
|
4
|
-
|
5
3
|
Decidim.register_component(:surveys) do |component|
|
6
4
|
component.engine = Decidim::Surveys::Engine
|
7
5
|
component.admin_engine = Decidim::Surveys::AdminEngine
|
8
6
|
component.icon = "media/images/decidim_surveys.svg"
|
7
|
+
component.icon_key = "survey-line"
|
9
8
|
component.stylesheet = "decidim/surveys/surveys"
|
10
9
|
component.permissions_class_name = "Decidim::Surveys::Permissions"
|
11
10
|
component.serializes_specific_data = true
|
@@ -15,13 +14,13 @@ Decidim.register_component(:surveys) do |component|
|
|
15
14
|
|
16
15
|
component.on(:copy) do |context|
|
17
16
|
Decidim::Surveys::CreateSurvey.call(context[:new_component]) do
|
18
|
-
on(:invalid) { raise "
|
17
|
+
on(:invalid) { raise "Cannot create survey" }
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
21
|
component.on(:create) do |instance|
|
23
22
|
Decidim::Surveys::CreateSurvey.call(instance) do
|
24
|
-
on(:invalid) { raise "
|
23
|
+
on(:invalid) { raise "Cannot create survey" }
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
@@ -33,7 +32,7 @@ Decidim.register_component(:surveys) do |component|
|
|
33
32
|
survey = Decidim::Surveys::Survey.find_by(decidim_component_id: instance.id)
|
34
33
|
survey_answers_for_component = Decidim::Forms::Answer.where(questionnaire: survey.questionnaire)
|
35
34
|
|
36
|
-
raise "
|
35
|
+
raise "Cannot destroy this component when there are survey answers" if survey_answers_for_component.any?
|
37
36
|
end
|
38
37
|
|
39
38
|
component.register_resource(:survey) do |resource|
|
@@ -85,90 +84,8 @@ Decidim.register_component(:surveys) do |component|
|
|
85
84
|
end
|
86
85
|
|
87
86
|
component.seeds do |participatory_space|
|
88
|
-
|
89
|
-
organization: participatory_space.organization,
|
90
|
-
email: "admin@example.org"
|
91
|
-
)
|
92
|
-
|
93
|
-
params = {
|
94
|
-
name: Decidim::Components::Namer.new(participatory_space.organization.available_locales, :surveys).i18n_name,
|
95
|
-
manifest_name: :surveys,
|
96
|
-
published_at: Time.current,
|
97
|
-
participatory_space: participatory_space
|
98
|
-
}
|
99
|
-
|
100
|
-
component = Decidim.traceability.perform_action!(
|
101
|
-
"publish",
|
102
|
-
Decidim::Component,
|
103
|
-
admin_user,
|
104
|
-
visibility: "all"
|
105
|
-
) do
|
106
|
-
Decidim::Component.create!(params)
|
107
|
-
end
|
108
|
-
|
109
|
-
questionnaire = Decidim::Forms::Questionnaire.new(
|
110
|
-
title: Decidim::Faker::Localized.paragraph,
|
111
|
-
description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
112
|
-
Decidim::Faker::Localized.paragraph(sentence_count: 3)
|
113
|
-
end,
|
114
|
-
tos: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
115
|
-
Decidim::Faker::Localized.paragraph(sentence_count: 2)
|
116
|
-
end
|
117
|
-
)
|
118
|
-
|
119
|
-
params = {
|
120
|
-
component: component,
|
121
|
-
questionnaire: questionnaire
|
122
|
-
}
|
123
|
-
|
124
|
-
Decidim.traceability.create!(
|
125
|
-
Decidim::Surveys::Survey,
|
126
|
-
admin_user,
|
127
|
-
params,
|
128
|
-
visibility: "all"
|
129
|
-
)
|
130
|
-
|
131
|
-
%w(short_answer long_answer).each_with_index do |text_question_type, index|
|
132
|
-
Decidim::Forms::Question.create!(
|
133
|
-
questionnaire: questionnaire,
|
134
|
-
body: Decidim::Faker::Localized.paragraph,
|
135
|
-
question_type: text_question_type,
|
136
|
-
position: index
|
137
|
-
)
|
138
|
-
end
|
87
|
+
require "decidim/surveys/seeds"
|
139
88
|
|
140
|
-
|
141
|
-
question = Decidim::Forms::Question.create!(
|
142
|
-
questionnaire: questionnaire,
|
143
|
-
body: Decidim::Faker::Localized.paragraph,
|
144
|
-
question_type: multiple_choice_question_type,
|
145
|
-
position: index + 2
|
146
|
-
)
|
147
|
-
|
148
|
-
3.times do
|
149
|
-
question.answer_options.create!(body: Decidim::Faker::Localized.sentence)
|
150
|
-
end
|
151
|
-
|
152
|
-
question.display_conditions.create!(
|
153
|
-
condition_question: questionnaire.questions.find_by(position: question.position - 2),
|
154
|
-
question: question,
|
155
|
-
condition_type: :answered,
|
156
|
-
mandatory: true
|
157
|
-
)
|
158
|
-
end
|
159
|
-
|
160
|
-
%w(matrix_single matrix_multiple).each_with_index do |matrix_question_type, index|
|
161
|
-
question = Decidim::Forms::Question.create!(
|
162
|
-
questionnaire: questionnaire,
|
163
|
-
body: Decidim::Faker::Localized.paragraph,
|
164
|
-
question_type: matrix_question_type,
|
165
|
-
position: index
|
166
|
-
)
|
167
|
-
|
168
|
-
3.times do |position|
|
169
|
-
question.answer_options.create!(body: Decidim::Faker::Localized.sentence)
|
170
|
-
question.matrix_rows.create!(body: Decidim::Faker::Localized.sentence, position: position)
|
171
|
-
end
|
172
|
-
end
|
89
|
+
Decidim::Surveys::Seeds.new(participatory_space:).call
|
173
90
|
end
|
174
91
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "decidim/core"
|
4
|
+
require "decidim/templates"
|
4
5
|
|
5
6
|
module Decidim
|
6
7
|
module Surveys
|
@@ -17,7 +18,7 @@ module Decidim
|
|
17
18
|
root to: "surveys#show"
|
18
19
|
end
|
19
20
|
|
20
|
-
initializer "
|
21
|
+
initializer "decidim_surveys.settings_changes" do
|
21
22
|
config.to_prepare do
|
22
23
|
Decidim::SettingsChange.subscribe "surveys" do |changes|
|
23
24
|
Decidim::Surveys::SettingsChangeJob.perform_later(
|
@@ -49,6 +50,24 @@ module Decidim
|
|
49
50
|
initializer "decidim_surveys.webpacker.assets_path" do
|
50
51
|
Decidim.register_assets_path File.expand_path("app/packs", root)
|
51
52
|
end
|
53
|
+
|
54
|
+
initializer "decidim_surveys.answers_email" do
|
55
|
+
config.to_prepare do
|
56
|
+
ActiveSupport::Notifications.subscribe("decidim.forms.answer_questionnaire:after") do |_event_name, data|
|
57
|
+
extra_data = data[:extra]
|
58
|
+
if data[:resource].questionnaire_for.instance_of?(::Decidim::Surveys::Survey)
|
59
|
+
component = data[:resource].questionnaire_for.component
|
60
|
+
|
61
|
+
answers = Decidim::Forms::QuestionnaireUserAnswers.for(data[:resource])
|
62
|
+
user_answers = answers.select { |a| a.first.session_token == extra_data[:session_token] }
|
63
|
+
|
64
|
+
if component.manifest_name == "surveys" && user_answers.present?
|
65
|
+
Decidim::Surveys::SurveyConfirmationMailer.confirmation(extra_data[:event_author], extra_data[:questionnaire], user_answers).deliver_later
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
52
71
|
end
|
53
72
|
end
|
54
73
|
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/components/namer"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Surveys
|
7
|
+
class Seeds
|
8
|
+
attr_reader :participatory_space
|
9
|
+
|
10
|
+
def initialize(participatory_space:)
|
11
|
+
@participatory_space = participatory_space
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
admin_user = Decidim::User.find_by(
|
16
|
+
organization: participatory_space.organization,
|
17
|
+
email: "admin@example.org"
|
18
|
+
)
|
19
|
+
|
20
|
+
params = {
|
21
|
+
name: Decidim::Components::Namer.new(participatory_space.organization.available_locales, :surveys).i18n_name,
|
22
|
+
manifest_name: :surveys,
|
23
|
+
published_at: Time.current,
|
24
|
+
participatory_space:
|
25
|
+
}
|
26
|
+
|
27
|
+
component = Decidim.traceability.perform_action!(
|
28
|
+
"publish",
|
29
|
+
Decidim::Component,
|
30
|
+
admin_user,
|
31
|
+
visibility: "all"
|
32
|
+
) do
|
33
|
+
Decidim::Component.create!(params)
|
34
|
+
end
|
35
|
+
|
36
|
+
questionnaire = Decidim::Forms::Questionnaire.new(
|
37
|
+
title: Decidim::Faker::Localized.paragraph,
|
38
|
+
description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
39
|
+
Decidim::Faker::Localized.paragraph(sentence_count: 3)
|
40
|
+
end,
|
41
|
+
tos: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
42
|
+
Decidim::Faker::Localized.paragraph(sentence_count: 2)
|
43
|
+
end
|
44
|
+
)
|
45
|
+
|
46
|
+
params = {
|
47
|
+
component:,
|
48
|
+
questionnaire:
|
49
|
+
}
|
50
|
+
|
51
|
+
Decidim.traceability.create!(
|
52
|
+
Decidim::Surveys::Survey,
|
53
|
+
admin_user,
|
54
|
+
params,
|
55
|
+
visibility: "all"
|
56
|
+
)
|
57
|
+
|
58
|
+
%w(short_answer long_answer).each_with_index do |text_question_type, index|
|
59
|
+
Decidim::Forms::Question.create!(
|
60
|
+
questionnaire:,
|
61
|
+
body: Decidim::Faker::Localized.paragraph,
|
62
|
+
question_type: text_question_type,
|
63
|
+
position: index
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
%w(single_option multiple_option).each_with_index do |multiple_choice_question_type, index|
|
68
|
+
question = Decidim::Forms::Question.create!(
|
69
|
+
questionnaire:,
|
70
|
+
body: Decidim::Faker::Localized.paragraph,
|
71
|
+
question_type: multiple_choice_question_type,
|
72
|
+
position: index + 2
|
73
|
+
)
|
74
|
+
|
75
|
+
3.times do
|
76
|
+
question.answer_options.create!(body: Decidim::Faker::Localized.sentence)
|
77
|
+
end
|
78
|
+
|
79
|
+
question.display_conditions.create!(
|
80
|
+
condition_question: questionnaire.questions.find_by(position: question.position - 2),
|
81
|
+
question:,
|
82
|
+
condition_type: :answered,
|
83
|
+
mandatory: true
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
%w(matrix_single matrix_multiple).each_with_index do |matrix_question_type, index|
|
88
|
+
question = Decidim::Forms::Question.create!(
|
89
|
+
questionnaire:,
|
90
|
+
body: Decidim::Faker::Localized.paragraph,
|
91
|
+
question_type: matrix_question_type,
|
92
|
+
position: index
|
93
|
+
)
|
94
|
+
|
95
|
+
3.times do |position|
|
96
|
+
question.answer_options.create!(body: Decidim::Faker::Localized.sentence)
|
97
|
+
question.matrix_rows.create!(body: Decidim::Faker::Localized.sentence, position:)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|