decidim-surveys 0.11.2 → 0.12.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/decidim/surveys/admin/surveys_controller.rb +4 -2
  3. data/app/controllers/decidim/surveys/surveys_controller.rb +2 -1
  4. data/app/permissions/decidim/surveys/admin/permissions.rb +24 -0
  5. data/app/permissions/decidim/surveys/permissions.rb +20 -0
  6. data/app/views/decidim/surveys/admin/surveys/_form.html.erb +1 -1
  7. data/app/views/decidim/surveys/surveys/_answer.html.erb +5 -5
  8. data/app/views/decidim/surveys/surveys/show.html.erb +12 -3
  9. data/config/locales/ca.yml +14 -0
  10. data/config/locales/en.yml +14 -0
  11. data/config/locales/es.yml +14 -0
  12. data/config/locales/eu.yml +14 -0
  13. data/config/locales/fi.yml +14 -0
  14. data/config/locales/fr.yml +14 -0
  15. data/config/locales/gl.yml +14 -0
  16. data/config/locales/it.yml +14 -0
  17. data/config/locales/nl.yml +14 -0
  18. data/config/locales/pl.yml +18 -0
  19. data/config/locales/pt-BR.yml +14 -0
  20. data/config/locales/pt.yml +14 -0
  21. data/config/locales/ru.yml +18 -0
  22. data/config/locales/sv.yml +14 -0
  23. data/config/locales/uk.yml +18 -0
  24. data/lib/decidim/surveys/admin_engine.rb +0 -9
  25. data/lib/decidim/surveys/component.rb +1 -10
  26. data/lib/decidim/surveys/engine.rb +0 -6
  27. data/lib/decidim/surveys/survey_user_answers_serializer.rb +7 -1
  28. data/lib/decidim/surveys/test/factories.rb +3 -0
  29. data/lib/decidim/surveys/version.rb +1 -1
  30. metadata +14 -15
  31. data/app/models/decidim/surveys/abilities/admin_ability.rb +0 -17
  32. data/app/models/decidim/surveys/abilities/current_user_ability.rb +0 -47
  33. data/app/models/decidim/surveys/abilities/participatory_process_admin_ability.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0be4875b9ab07672f1c189bfdebe08acba2767091c49b29d5bf3b5be1b5d42f8
4
- data.tar.gz: 2009bad5150ee963366fadf976629d58cde2072ebf80adc2ccca0d83cb9c7d68
3
+ metadata.gz: fa90ef787f2d9e0d55a9f3e75ec4f80ff7530c7c757dfe8579465899e60b48eb
4
+ data.tar.gz: 64cec3d696cbbfb71c8baee70dbb8a10de4ee3f27398de591cc0f1442206361d
5
5
  SHA512:
6
- metadata.gz: d1063014fa04c86e22c7c4c8f89f3cb79b8f7729b5cd4bce17740bdbde20d935cfc1a35ffd9657711b9fd2735e244cb8caa2555a1046b793186c779dec73a8a6
7
- data.tar.gz: 75c02334404c53a3f5e04fa74054ed071b637eb703409174b589bc078bc61b06b2359fb030cb0eebdf3469151d4507c4d2065b9e426f3c3aea1400a77d565665
6
+ metadata.gz: 6f98c689bcc4384b3beab4c870db252c9e1dd5456f654274a69cc8968cb23a9ec02b5180b9305d75eb8c1ddc177088784e2f6b652911049971e89b435119b926
7
+ data.tar.gz: 5886539b3f65602097c7e8989c2d9cca98f97ffcef8875ae611828f01b381d99cdc7bbc90d8d4c0912f38121c9dbeef8ee524c91e4283dbd145a1d47cd2737ab
@@ -8,12 +8,14 @@ module Decidim
8
8
  helper_method :survey, :blank_question, :blank_answer_option, :question_types
9
9
 
10
10
  def edit
11
- authorize! :edit, Survey
11
+ enforce_permission_to :update, :survey, survey: survey
12
+
12
13
  @form = form(Admin::SurveyForm).from_model(survey)
13
14
  end
14
15
 
15
16
  def update
16
- authorize! :update, Survey
17
+ enforce_permission_to :update, :survey, survey: survey
18
+
17
19
  params["published_at"] = Time.current if params.has_key? "save_and_publish"
18
20
  @form = form(Admin::SurveyForm).from_params(params)
19
21
 
@@ -13,7 +13,8 @@ module Decidim
13
13
  end
14
14
 
15
15
  def answer
16
- authorize! :answer, Survey
16
+ enforce_permission_to :answer, :survey
17
+
17
18
  @form = form(SurveyForm).from_params(params)
18
19
 
19
20
  AnswerSurvey.call(@form, current_user, survey) do
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Surveys
5
+ module Admin
6
+ class Permissions < Decidim::DefaultPermissions
7
+ def permissions
8
+ return permission_action unless user
9
+
10
+ return permission_action if permission_action.scope != :admin
11
+
12
+ return permission_action if permission_action.subject != :survey
13
+
14
+ case permission_action.action
15
+ when :export_answers, :update
16
+ permission_action.allow!
17
+ end
18
+
19
+ permission_action
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Surveys
5
+ class Permissions < Decidim::DefaultPermissions
6
+ def permissions
7
+ return permission_action unless user
8
+
9
+ return Decidim::Surveys::Admin::Permissions.new(user, permission_action, context).permissions if permission_action.scope == :admin
10
+ return permission_action if permission_action.scope != :public
11
+
12
+ return permission_action if permission_action.subject != :survey
13
+
14
+ permission_action.allow! if permission_action.action == :answer
15
+
16
+ permission_action
17
+ end
18
+ end
19
+ end
20
+ end
@@ -3,7 +3,7 @@
3
3
  <h2 class="card-title">
4
4
  <%= title %>
5
5
  <div class="button--title">
6
- <%= export_dropdown %>
6
+ <%= export_dropdown if allowed_to? :export_answers, :survey %>
7
7
  </div>
8
8
  </h2>
9
9
  </div>
@@ -9,9 +9,9 @@
9
9
 
10
10
  <% case answer.question.question_type %>
11
11
  <% when "short_answer" %>
12
- <%= answer_form.text_field :body, label: false, id: field_id %>
12
+ <%= answer_form.text_field :body, label: false, id: field_id, disabled: disabled %>
13
13
  <% when "long_answer" %>
14
- <%= answer_form.text_area :body, label: false, id: field_id, rows: 10 %>
14
+ <%= answer_form.text_area :body, label: false, id: field_id, rows: 10, disabled: disabled %>
15
15
  <% when "single_option" %>
16
16
  <div class="radio-button-collection">
17
17
  <% choice = answer.choices.first %>
@@ -23,7 +23,7 @@
23
23
  <%= radio_button_tag "survey[survey_answers][#{answer_idx}][choices][][body]",
24
24
  translated_attribute(answer_option.body),
25
25
  choice.try(:body),
26
- id: "#{choice_id}_body" %>
26
+ id: "#{choice_id}_body", disabled: disabled %>
27
27
 
28
28
  <%= translated_attribute(answer_option.body) %>
29
29
 
@@ -49,7 +49,7 @@
49
49
  <%= label_tag do %>
50
50
  <%= check_box_tag "survey[survey_answers][#{answer_idx}][choices][#{idx}][body]",
51
51
  translated_attribute(answer_option.body),
52
- choice.present? %>
52
+ choice.present?, disabled: disabled %>
53
53
 
54
54
  <%= translated_attribute(answer_option.body) %>
55
55
 
@@ -71,7 +71,7 @@
71
71
  <%= label_tag do %>
72
72
  <%= check_box_tag "survey[survey_answers][#{answer_idx}][choices][#{idx}][body]",
73
73
  translated_attribute(answer_option.body),
74
- choice.present? %>
74
+ choice.present?, disabled: disabled %>
75
75
 
76
76
  <span class="position"><%= choice.try(:position) %></span>
77
77
 
@@ -29,24 +29,33 @@
29
29
  </div>
30
30
  <% else %>
31
31
  <div class="answer-survey">
32
+ <% unless current_participatory_space.can_participate?(current_user) %>
33
+ <div class="section">
34
+ <div class="callout alert">
35
+ <h5><%= t(".survey_for_private_users.title") %></h5>
36
+ <p><%= t(".survey_for_private_users.body") %></p>
37
+ </div>
38
+ </div>
39
+ <% end %>
40
+
32
41
  <%= decidim_form_for(@form, url: answer_survey_path(survey), method: :post, html: { class: "form answer-survey" }) do |form| %>
33
42
  <% @form.survey_answers.each_with_index do |answer, answer_idx| %>
34
43
  <div class="row column">
35
44
  <%= fields_for "survey[survey_answers][#{answer_idx}]", answer do |answer_form| %>
36
- <%= render "answer", answer_form: answer_form, answer: answer, answer_idx: answer_idx %>
45
+ <%= render "answer", answer_form: answer_form, answer: answer, answer_idx: answer_idx, disabled: !current_participatory_space.can_participate?(current_user) %>
37
46
  <% end %>
38
47
  </div>
39
48
  <% end %>
40
49
 
41
50
  <div class="row column tos-agreement">
42
- <%= form.check_box :tos_agreement, label: t(".tos_agreement"), id: "survey_tos_agreement" %>
51
+ <%= form.check_box :tos_agreement, label: t(".tos_agreement"), id: "survey_tos_agreement", disabled: !current_participatory_space.can_participate?(current_user) %>
43
52
  <div class="help-text">
44
53
  <%= decidim_sanitize translated_attribute survey.tos %>
45
54
  </div>
46
55
  </div>
47
56
 
48
57
  <div class="button--double form-general-submit">
49
- <%= form.submit t(".submit"), class: "button", data: { confirm: t(".are_you_sure"), disable: true } %>
58
+ <%= form.submit t(".submit"), class: "button", disabled: !current_participatory_space.can_participate?(current_user), data: { confirm: t(".are_you_sure"), disable: true } %>
50
59
  </div>
51
60
  <% end %>
52
61
  </div>
@@ -14,6 +14,17 @@ ca:
14
14
  choices:
15
15
  missing: no estan complets
16
16
  too_many: són massa
17
+ models:
18
+ decidim/surveys/closed_survey_event: S'ha acabat l'enquesta
19
+ decidim/surveys/opened_survey_event: S'ha iniciat l'enquesta
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Enquesta
24
+ other: Enquestes
25
+ decidim/surveys/survey_answer:
26
+ one: Resposta
27
+ other: Respostes
17
28
  decidim:
18
29
  components:
19
30
  surveys:
@@ -98,4 +109,7 @@ ca:
98
109
  survey_closed:
99
110
  body: L'enquesta està tancada i no s'hi pot participar.
100
111
  title: Enquesta tancada
112
+ survey_for_private_users:
113
+ body: L'enquesta només està disponible per a usuaris privats
114
+ title: Enquesta tancada
101
115
  tos_agreement: En participar en aquesta enquesta acceptes els Termes de Servei
@@ -15,6 +15,17 @@ en:
15
15
  choices:
16
16
  missing: are not complete
17
17
  too_many: are too many
18
+ models:
19
+ decidim/surveys/closed_survey_event: Survey ended
20
+ decidim/surveys/opened_survey_event: Survey started
21
+ activerecord:
22
+ models:
23
+ decidim/surveys/survey:
24
+ one: Survey
25
+ other: Surveys
26
+ decidim/surveys/survey_answer:
27
+ one: Answer
28
+ other: Answers
18
29
  decidim:
19
30
  components:
20
31
  surveys:
@@ -99,4 +110,7 @@ en:
99
110
  survey_closed:
100
111
  body: The survey is closed and cannot be answered.
101
112
  title: Survey closed
113
+ survey_for_private_users:
114
+ body: The survey is available only for private users
115
+ title: Survey closed
102
116
  tos_agreement: By participating in this survey you accept its Terms of Service
@@ -14,6 +14,17 @@ es:
14
14
  choices:
15
15
  missing: no están completos
16
16
  too_many: son demasiados
17
+ models:
18
+ decidim/surveys/closed_survey_event: Encuesta terminada
19
+ decidim/surveys/opened_survey_event: La encuesta ha empezado
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Encuesta
24
+ other: Encuestas
25
+ decidim/surveys/survey_answer:
26
+ one: Respuesta
27
+ other: Respuestas
17
28
  decidim:
18
29
  components:
19
30
  surveys:
@@ -98,4 +109,7 @@ es:
98
109
  survey_closed:
99
110
  body: La encuesta está cerrada y no se puede responder.
100
111
  title: Encuesta cerrada
112
+ survey_for_private_users:
113
+ body: La encuesta está disponible solo para usuarios privados
114
+ title: Encuesta cerrada
101
115
  tos_agreement: Al participar en esta encuesta, aceptas sus términos de servicio
@@ -14,6 +14,17 @@ eu:
14
14
  choices:
15
15
  missing: ez dira osatu
16
16
  too_many: gehiegi dira
17
+ models:
18
+ decidim/surveys/closed_survey_event: Inkesta amaitu da
19
+ decidim/surveys/opened_survey_event: Inkesta hasi zen
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Inkesta
24
+ other: Inkestak
25
+ decidim/surveys/survey_answer:
26
+ one: Erantzuna
27
+ other: Erantzunak
17
28
  decidim:
18
29
  components:
19
30
  surveys:
@@ -98,4 +109,7 @@ eu:
98
109
  survey_closed:
99
110
  body: Inkesta itxita dago eta ezin da erantzun.
100
111
  title: Inkesta itxia
112
+ survey_for_private_users:
113
+ body: Iragarkia erabiltzaile pribatuentzako soilik dago erabilgarri
114
+ title: Inkesta itxia
101
115
  tos_agreement: Inkestan parte hartuz, Zerbitzu-baldintzak onartzen dituzu
@@ -14,6 +14,17 @@ fi:
14
14
  choices:
15
15
  missing: eivät ole täydellisiä
16
16
  too_many: ovat liian monta
17
+ models:
18
+ decidim/surveys/closed_survey_event: Tutkimus päättyi
19
+ decidim/surveys/opened_survey_event: Tutkimus alkoi
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: tutkimus
24
+ other: tutkimukset
25
+ decidim/surveys/survey_answer:
26
+ one: Vastaus
27
+ other: vastaukset
17
28
  decidim:
18
29
  components:
19
30
  surveys:
@@ -98,4 +109,7 @@ fi:
98
109
  survey_closed:
99
110
  body: Kysely on suljettu ja siihen ei voi vastata.
100
111
  title: Kysely suljettu
112
+ survey_for_private_users:
113
+ body: Kysely on käytettävissä vain yksityisille käyttäjille
114
+ title: Kysely on suljettu
101
115
  tos_agreement: Osallistumalla tähän kyselyyn hyväksyt sen käyttöehdot
@@ -14,6 +14,17 @@ fr:
14
14
  choices:
15
15
  missing: ne sont pas complets
16
16
  too_many: sont trop nombreux
17
+ models:
18
+ decidim/surveys/closed_survey_event: Enquête terminée
19
+ decidim/surveys/opened_survey_event: Enquête commencée
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Enquête
24
+ other: Enquêtes
25
+ decidim/surveys/survey_answer:
26
+ one: Réponse
27
+ other: Réponses
17
28
  decidim:
18
29
  components:
19
30
  surveys:
@@ -98,4 +109,7 @@ fr:
98
109
  survey_closed:
99
110
  body: L'enquête est terminée et n'accepte plus de réponse.
100
111
  title: Enquête terminée
112
+ survey_for_private_users:
113
+ body: L'enquête est disponible uniquement pour les utilisateurs privés
114
+ title: Enquête terminée
101
115
  tos_agreement: En participant à cette enquête, vous acceptez ses conditions d'utilisation
@@ -14,6 +14,17 @@ gl:
14
14
  choices:
15
15
  missing: non están completos
16
16
  too_many: son demasiados
17
+ models:
18
+ decidim/surveys/closed_survey_event: A investigación finalizou
19
+ decidim/surveys/opened_survey_event: Iniciouse a enquisa
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Enquisa
24
+ other: Enquisas
25
+ decidim/surveys/survey_answer:
26
+ one: Resposta
27
+ other: Respostas
17
28
  decidim:
18
29
  components:
19
30
  surveys:
@@ -98,4 +109,7 @@ gl:
98
109
  survey_closed:
99
110
  body: A enquisa está pechada e non se pode responder.
100
111
  title: Enquisa pechada
112
+ survey_for_private_users:
113
+ body: A enquisa só está dispoñible para usuarios privados
114
+ title: Enquisa pechada
101
115
  tos_agreement: Ao participar nesta enquisa aceptas as Condicións de servizo
@@ -14,6 +14,17 @@ it:
14
14
  choices:
15
15
  missing: non sono completi
16
16
  too_many: sono troppi
17
+ models:
18
+ decidim/surveys/closed_survey_event: Sondaggio terminato
19
+ decidim/surveys/opened_survey_event: Sondaggio iniziato
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Sondaggio
24
+ other: indagini
25
+ decidim/surveys/survey_answer:
26
+ one: Risposta
27
+ other: risposte
17
28
  decidim:
18
29
  components:
19
30
  surveys:
@@ -98,4 +109,7 @@ it:
98
109
  survey_closed:
99
110
  body: L'indagine è chiusa e non è più possibile rispondere.
100
111
  title: Questionario chiuso
112
+ survey_for_private_users:
113
+ body: Il sondaggio è disponibile solo per gli utenti privati
114
+ title: Sondaggio chiuso
101
115
  tos_agreement: Partecipando a questo sondaggio, accetti le sue condizioni di servizio
@@ -14,6 +14,17 @@ nl:
14
14
  choices:
15
15
  missing: zijn niet compleet
16
16
  too_many: zijn te veel
17
+ models:
18
+ decidim/surveys/closed_survey_event: Enquête beëindigd
19
+ decidim/surveys/opened_survey_event: Enquête is gestart
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Enquête
24
+ other: onderzoeken
25
+ decidim/surveys/survey_answer:
26
+ one: Antwoord
27
+ other: antwoorden
17
28
  decidim:
18
29
  components:
19
30
  surveys:
@@ -98,4 +109,7 @@ nl:
98
109
  survey_closed:
99
110
  body: De enquête is gesloten en kan niet worden beantwoord.
100
111
  title: Enquête gesloten
112
+ survey_for_private_users:
113
+ body: De enquête is alleen beschikbaar voor privé-gebruikers
114
+ title: Enquête gesloten
101
115
  tos_agreement: Door deel te nemen aan dit onderzoek accepteert u de gebruiksvoorwaarden
@@ -14,6 +14,21 @@ pl:
14
14
  choices:
15
15
  missing: nie są kompletne
16
16
  too_many: jest zbyt wiele
17
+ models:
18
+ decidim/surveys/closed_survey_event: Ankieta zakończyła się
19
+ decidim/surveys/opened_survey_event: Rozpoczęto ankietę
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Ankieta
24
+ few: Ankiety
25
+ many: Ankiety
26
+ other: Ankiety
27
+ decidim/surveys/survey_answer:
28
+ one: Odpowiedź
29
+ few: Odpowiedzi
30
+ many: Odpowiedzi
31
+ other: Odpowiedzi
17
32
  decidim:
18
33
  components:
19
34
  surveys:
@@ -98,4 +113,7 @@ pl:
98
113
  survey_closed:
99
114
  body: Ankieta jest zamknięta i nie można jej odpowiedzieć.
100
115
  title: Ankieta zamknięta
116
+ survey_for_private_users:
117
+ body: Ankieta jest dostępna tylko dla użytkowników prywatnych
118
+ title: Ankieta została zamknięta
101
119
  tos_agreement: Uczestnicząc w tym ankiecie akceptujesz Warunki korzystania z usługi
@@ -14,6 +14,17 @@ pt-BR:
14
14
  choices:
15
15
  missing: não estão completos
16
16
  too_many: são muitos
17
+ models:
18
+ decidim/surveys/closed_survey_event: Estudo finalizado
19
+ decidim/surveys/opened_survey_event: Enquete iniciada
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Enquete
24
+ other: Enquetes
25
+ decidim/surveys/survey_answer:
26
+ one: Resposta
27
+ other: Respostas
17
28
  decidim:
18
29
  components:
19
30
  surveys:
@@ -98,4 +109,7 @@ pt-BR:
98
109
  survey_closed:
99
110
  body: A pesquisa está fechada e não pode ser respondida.
100
111
  title: Pesquisa fechada
112
+ survey_for_private_users:
113
+ body: A pesquisa está disponível apenas para usuários particulares
114
+ title: Inquérito encerrado
101
115
  tos_agreement: Ao participar desta pesquisa você aceita seus Termos de Serviço
@@ -14,6 +14,17 @@ pt:
14
14
  choices:
15
15
  missing: não estão completos
16
16
  too_many: são muitos
17
+ models:
18
+ decidim/surveys/closed_survey_event: Pesquisa finalizada
19
+ decidim/surveys/opened_survey_event: Inquérito iniciado
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Pesquisa
24
+ other: pesquisas
25
+ decidim/surveys/survey_answer:
26
+ one: Responda
27
+ other: Respostas
17
28
  decidim:
18
29
  components:
19
30
  surveys:
@@ -98,4 +109,7 @@ pt:
98
109
  survey_closed:
99
110
  body: A pesquisa está fechada e não pode ser respondida.
100
111
  title: Pesquisa fechada
112
+ survey_for_private_users:
113
+ body: A pesquisa está disponível apenas para usuários particulares
114
+ title: Inquérito encerrado
101
115
  tos_agreement: Ao participar desta pesquisa você aceita seus Termos de Serviço
@@ -14,6 +14,21 @@ ru:
14
14
  choices:
15
15
  missing: приведены не все
16
16
  too_many: слишком много
17
+ models:
18
+ decidim/surveys/closed_survey_event: Опрос закончился
19
+ decidim/surveys/opened_survey_event: Опрос начался
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Опрос
24
+ few: Опроса
25
+ many: Опросов
26
+ other: Опросов
27
+ decidim/surveys/survey_answer:
28
+ one: Ответ
29
+ few: Ответа
30
+ many: Ответов
31
+ other: Ответов
17
32
  decidim:
18
33
  components:
19
34
  surveys:
@@ -98,4 +113,7 @@ ru:
98
113
  survey_closed:
99
114
  body: Опрос завершен и его уже нельзя проходить.
100
115
  title: Опрос завершен
116
+ survey_for_private_users:
117
+ body: Опрос доступен только для частных участников
118
+ title: Опрос завершен
101
119
  tos_agreement: Участвуя в этом опросе, вы принимаете его "Условия использования"
@@ -14,6 +14,17 @@ sv:
14
14
  choices:
15
15
  missing: är inte fullständiga
16
16
  too_many: är för många
17
+ models:
18
+ decidim/surveys/closed_survey_event: Undersökningen slutade
19
+ decidim/surveys/opened_survey_event: Undersökningen startade
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Undersökning
24
+ other: Undersökningar
25
+ decidim/surveys/survey_answer:
26
+ one: Svar
27
+ other: svar
17
28
  decidim:
18
29
  components:
19
30
  surveys:
@@ -98,4 +109,7 @@ sv:
98
109
  survey_closed:
99
110
  body: Undersökningen är stängd och kan inte besvaras.
100
111
  title: Undersökningen stängd
112
+ survey_for_private_users:
113
+ body: Undersökningen är endast tillgänglig för privata användare
114
+ title: Undersökningen stängd
101
115
  tos_agreement: Genom att delta i denna undersökning accepterar du användarvillkoren
@@ -14,6 +14,21 @@ uk:
14
14
  choices:
15
15
  missing: наведені не всі
16
16
  too_many: занадто багато
17
+ models:
18
+ decidim/surveys/closed_survey_event: Опитування закінчилося
19
+ decidim/surveys/opened_survey_event: Опитування почалося
20
+ activerecord:
21
+ models:
22
+ decidim/surveys/survey:
23
+ one: Опитування
24
+ few: Опитування
25
+ many: Опитувань
26
+ other: Опитувань
27
+ decidim/surveys/survey_answer:
28
+ one: Відповідь
29
+ few: Відповіді
30
+ many: Відповідей
31
+ other: Відповідей
17
32
  decidim:
18
33
  components:
19
34
  surveys:
@@ -98,4 +113,7 @@ uk:
98
113
  survey_closed:
99
114
  body: Опитування завершене, дати відповіді на нього не можна.
100
115
  title: Опитування завершене
116
+ survey_for_private_users:
117
+ body: Це опитування доступне лише для приватних учасників
118
+ title: Опитування завершене
101
119
  tos_agreement: Беручи участь у цьому опитуванні, ви приймаєте його умови використання
@@ -17,15 +17,6 @@ module Decidim
17
17
  app.config.assets.precompile += %w(admin/decidim_surveys_manifest.js)
18
18
  end
19
19
 
20
- initializer "decidim_surveys.inject_abilities_to_user" do |_app|
21
- Decidim.configure do |config|
22
- config.admin_abilities += [
23
- "Decidim::Surveys::Abilities::AdminAbility",
24
- "Decidim::Surveys::Abilities::ParticipatoryProcessAdminAbility"
25
- ]
26
- end
27
- end
28
-
29
20
  def load_seed
30
21
  nil
31
22
  end
@@ -7,6 +7,7 @@ Decidim.register_component(:surveys) do |component|
7
7
  component.admin_engine = Decidim::Surveys::AdminEngine
8
8
  component.icon = "decidim/surveys/icon.svg"
9
9
  component.stylesheet = "decidim/surveys/surveys"
10
+ component.permissions_class_name = "Decidim::Surveys::Permissions"
10
11
 
11
12
  component.on(:create) do |instance|
12
13
  Decidim::Surveys::CreateSurvey.call(instance) do
@@ -45,16 +46,6 @@ Decidim.register_component(:surveys) do |component|
45
46
  settings.attribute :announcement, type: :text, translated: true, editor: true
46
47
  end
47
48
 
48
- # component.register_resource do |resource|
49
- # # Register a optional resource that can be references from other resources.
50
- # resource.model_class_name = "Decidim::Surveys::SomeResource"
51
- # resource.template = "decidim/surveys/some_resources/linked_some_resources"
52
- # end
53
-
54
- # component.register_stat :some_stat do |context, start_at, end_at|
55
- # # Register some stat number to the application
56
- # end
57
-
58
49
  component.exports :survey_user_answers do |exports|
59
50
  exports.collection do |f|
60
51
  survey = Decidim::Surveys::Survey.find_by(component: f)
@@ -19,12 +19,6 @@ module Decidim
19
19
  app.config.assets.precompile += %w(decidim_surveys_manifest.js)
20
20
  end
21
21
 
22
- initializer "decidim_surveys.inject_abilities_to_user" do |_app|
23
- Decidim.configure do |config|
24
- config.abilities += ["Decidim::Surveys::Abilities::CurrentUserAbility"]
25
- end
26
- end
27
-
28
22
  initializer "decidim_changes" do
29
23
  Decidim::SettingsChange.subscribe "surveys" do |changes|
30
24
  Decidim::Surveys::SettingsChangeJob.perform_later(
@@ -15,9 +15,15 @@ module Decidim
15
15
  # Public: Exports a hash with the serialized data for the user answers.
16
16
  def serialize
17
17
  @survey_answers.each_with_index.inject({}) do |serialized, (answer, idx)|
18
- serialized.update("#{idx + 1}. #{translated_attribute(answer.question.body)}" => answer.body)
18
+ serialized.update("#{idx + 1}. #{translated_attribute(answer.question.body)}" => normalize_body(answer))
19
19
  end
20
20
  end
21
+
22
+ private
23
+
24
+ def normalize_body(answer)
25
+ answer.body || answer.choices.pluck(:body)
26
+ end
21
27
  end
22
28
  end
23
29
  end
@@ -52,4 +52,7 @@ FactoryBot.define do
52
52
  factory :survey_answer_option, class: Decidim::Surveys::SurveyAnswerOption do
53
53
  body { Decidim::Faker::Localized.sentence }
54
54
  end
55
+
56
+ factory :survey_answer_choice, class: Decidim::Surveys::SurveyAnswerChoice do
57
+ end
55
58
  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.11.2"
7
+ "0.12.0.pre"
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.11.2
4
+ version: 0.12.0.pre
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-06-13 00:00:00.000000000 Z
13
+ date: 2018-06-06 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.11.2
21
+ version: 0.12.0.pre
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.11.2
28
+ version: 0.12.0.pre
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.11.2
35
+ version: 0.12.0.pre
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.11.2
42
+ version: 0.12.0.pre
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.11.2
49
+ version: 0.12.0.pre
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.11.2
56
+ version: 0.12.0.pre
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.11.2
63
+ version: 0.12.0.pre
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.11.2
70
+ version: 0.12.0.pre
71
71
  description: A surveys component for decidim's participatory spaces.
72
72
  email:
73
73
  - josepjaume@gmail.com
@@ -106,15 +106,14 @@ files:
106
106
  - app/forms/decidim/surveys/survey_form.rb
107
107
  - app/helpers/decidim/surveys/admin/application_helper.rb
108
108
  - app/jobs/decidim/surveys/settings_change_job.rb
109
- - app/models/decidim/surveys/abilities/admin_ability.rb
110
- - app/models/decidim/surveys/abilities/current_user_ability.rb
111
- - app/models/decidim/surveys/abilities/participatory_process_admin_ability.rb
112
109
  - app/models/decidim/surveys/application_record.rb
113
110
  - app/models/decidim/surveys/survey.rb
114
111
  - app/models/decidim/surveys/survey_answer.rb
115
112
  - app/models/decidim/surveys/survey_answer_choice.rb
116
113
  - app/models/decidim/surveys/survey_answer_option.rb
117
114
  - app/models/decidim/surveys/survey_question.rb
115
+ - app/permissions/decidim/surveys/admin/permissions.rb
116
+ - app/permissions/decidim/surveys/permissions.rb
118
117
  - app/queries/decidim/surveys/survey_user_answers.rb
119
118
  - app/views/decidim/surveys/admin/surveys/_answer_option.html.erb
120
119
  - app/views/decidim/surveys/admin/surveys/_form.html.erb
@@ -176,9 +175,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
175
  version: '2.3'
177
176
  required_rubygems_version: !ruby/object:Gem::Requirement
178
177
  requirements:
179
- - - ">="
178
+ - - ">"
180
179
  - !ruby/object:Gem::Version
181
- version: '0'
180
+ version: 1.3.1
182
181
  requirements: []
183
182
  rubyforge_project:
184
183
  rubygems_version: 2.7.6
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Surveys
5
- module Abilities
6
- # Defines the abilities related to surveys for a logged in admin user.
7
- # Intended to be used with `cancancan`.
8
- class AdminAbility < Decidim::Abilities::AdminAbility
9
- def define_abilities
10
- super
11
-
12
- can :manage, Survey
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Surveys
5
- module Abilities
6
- # Defines the abilities related to surveys for a logged in user.
7
- # Intended to be used with `cancancan`.
8
- class CurrentUserAbility
9
- include CanCan::Ability
10
-
11
- attr_reader :user, :context
12
-
13
- def initialize(user, context)
14
- return unless user
15
-
16
- @user = user
17
- @context = context
18
-
19
- can :answer, Survey if authorized?(:answer)
20
- end
21
-
22
- private
23
-
24
- def authorized?(action)
25
- return unless component
26
-
27
- ActionAuthorizer.new(user, component, action).authorize.ok?
28
- end
29
-
30
- def current_settings
31
- context.fetch(:current_settings, nil)
32
- end
33
-
34
- def component_settings
35
- context.fetch(:component_settings, nil)
36
- end
37
-
38
- def component
39
- component = context.fetch(:current_component, nil)
40
- return nil unless component && component.manifest.name == :surveys
41
-
42
- component
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Surveys
5
- module Abilities
6
- # Defines the abilities related to surveys for a logged in process admin user.
7
- # Intended to be used with `cancancan`.
8
- class ParticipatoryProcessAdminAbility < Decidim::Abilities::ParticipatoryProcessAdminAbility
9
- def define_participatory_process_abilities
10
- super
11
-
12
- can :manage, Survey do |survey|
13
- can_manage_process?(survey.component.participatory_space)
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end