decidim-meetings 0.24.3 → 0.25.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/meetings/join_meeting_button/registration_confirm.erb +6 -0
- data/app/cells/decidim/meetings/join_meeting_button/show.erb +8 -6
- data/app/cells/decidim/meetings/meeting_m_cell.rb +4 -0
- data/app/cells/decidim/meetings/meeting_url/show.erb +7 -2
- data/app/cells/decidim/meetings/meeting_url_cell.rb +14 -2
- data/app/cells/decidim/meetings/meetings_map/show.erb +1 -1
- data/app/cells/decidim/meetings/online_meeting_cell.rb +36 -0
- data/app/cells/decidim/meetings/online_meeting_link/show.erb +44 -0
- data/app/cells/decidim/meetings/online_meeting_link_cell.rb +27 -0
- data/app/cells/decidim/meetings/public_participants_list/show.erb +16 -0
- data/app/cells/decidim/meetings/public_participants_list_cell.rb +31 -0
- data/app/cells/decidim/meetings/question_responses/show.erb +7 -0
- data/app/cells/decidim/meetings/question_responses_cell.rb +72 -0
- data/app/commands/decidim/meetings/admin/close_meeting.rb +3 -0
- data/app/commands/decidim/meetings/admin/copy_meeting.rb +0 -9
- data/app/commands/decidim/meetings/admin/create_meeting.rb +4 -20
- data/app/commands/decidim/meetings/admin/destroy_meeting.rb +2 -0
- data/app/commands/decidim/meetings/admin/publish_meeting.rb +72 -0
- data/app/commands/decidim/meetings/admin/unpublish_meeting.rb +45 -0
- data/app/commands/decidim/meetings/admin/update_meeting.rb +6 -3
- data/app/commands/decidim/meetings/admin/update_question_status.rb +57 -0
- data/app/commands/decidim/meetings/admin/update_questionnaire.rb +93 -0
- data/app/commands/decidim/meetings/close_meeting.rb +2 -0
- data/app/commands/decidim/meetings/create_answer.rb +52 -0
- data/app/commands/decidim/meetings/create_meeting.rb +3 -1
- data/app/commands/decidim/meetings/join_meeting.rb +2 -1
- data/app/commands/decidim/meetings/update_meeting.rb +2 -1
- data/app/controllers/concerns/decidim/meetings/admin/filterable.rb +55 -0
- data/app/controllers/concerns/decidim/meetings/polls_resources.rb +29 -0
- data/app/controllers/decidim/meetings/admin/application_controller.rb +6 -2
- data/app/controllers/decidim/meetings/admin/invites_controller.rb +0 -2
- data/app/controllers/decidim/meetings/admin/meeting_closes_controller.rb +1 -1
- data/app/controllers/decidim/meetings/admin/meetings_controller.rb +46 -1
- data/app/controllers/decidim/meetings/admin/meetings_poll_controller.rb +107 -0
- data/app/controllers/decidim/meetings/calendars_controller.rb +8 -0
- data/app/controllers/decidim/meetings/live_events_controller.rb +29 -0
- data/app/controllers/decidim/meetings/meeting_closes_controller.rb +1 -1
- data/app/controllers/decidim/meetings/polls/answers_controller.rb +37 -0
- data/app/controllers/decidim/meetings/polls/questions_controller.rb +45 -0
- data/app/events/decidim/meetings/create_meeting_event.rb +16 -0
- data/app/forms/decidim/meetings/admin/answer_option_form.rb +24 -0
- data/app/forms/decidim/meetings/admin/close_meeting_form.rb +3 -1
- data/app/forms/decidim/meetings/admin/meeting_form.rb +12 -1
- data/app/forms/decidim/meetings/admin/question_form.rb +44 -0
- data/app/forms/decidim/meetings/admin/questionnaire_form.rb +19 -0
- data/app/forms/decidim/meetings/answer_choice_form.rb +14 -0
- data/app/forms/decidim/meetings/answer_form.rb +65 -0
- data/app/forms/decidim/meetings/close_meeting_form.rb +4 -0
- data/app/forms/decidim/meetings/join_meeting_form.rb +1 -0
- data/app/forms/decidim/meetings/meeting_form.rb +9 -0
- data/app/helpers/decidim/meetings/admin/filterable_helper.rb +13 -0
- data/app/helpers/decidim/meetings/application_helper.rb +3 -2
- data/app/helpers/decidim/meetings/meetings_helper.rb +21 -0
- data/app/models/decidim/meetings/answer.rb +48 -0
- data/app/models/decidim/meetings/answer_choice.rb +15 -0
- data/app/models/decidim/meetings/answer_option.rb +24 -0
- data/app/models/decidim/meetings/meeting.rb +88 -42
- data/app/models/decidim/meetings/poll.rb +19 -0
- data/app/models/decidim/meetings/question.rb +54 -0
- data/app/models/decidim/meetings/questionnaire.rb +23 -0
- data/app/models/decidim/meetings/registration.rb +2 -0
- data/app/packs/entrypoints/decidim_meetings.js +6 -0
- data/app/packs/entrypoints/decidim_meetings_admin.js +5 -0
- data/app/{assets/images/decidim/gamification/badges/attended_meetings.svg → packs/images/decidim/gamification/badges/decidim_gamification_badges_attended_meetings.svg} +0 -0
- data/app/{assets/images/decidim/meetings/icon.svg → packs/images/decidim/meetings/decidim_meetings.svg} +0 -0
- data/app/packs/src/decidim/meetings/admin/agendas.js +159 -0
- data/app/{assets/javascripts/decidim/meetings/admin/destroy_meeting_alert.js.es6 → packs/src/decidim/meetings/admin/destroy_meeting_alert.js} +0 -0
- data/app/{assets/javascripts/decidim/meetings/admin/meetings_form.js.es6 → packs/src/decidim/meetings/admin/meetings_form.js} +7 -4
- data/app/{assets/javascripts/decidim/meetings/admin/registrations_form.js.es6 → packs/src/decidim/meetings/admin/registrations_form.js} +0 -0
- data/app/{assets/javascripts/decidim/meetings/admin/registrations_invite_form.es6 → packs/src/decidim/meetings/admin/registrations_invite_form.js} +3 -3
- data/app/packs/src/decidim/meetings/meetings_form.js +54 -0
- data/app/packs/src/decidim/meetings/meetings_polls.js +41 -0
- data/app/packs/src/decidim/meetings/poll.component.js +166 -0
- data/app/packs/stylesheets/decidim/meetings/_header.scss +52 -0
- data/app/packs/stylesheets/decidim/meetings/_main.scss +178 -0
- data/app/packs/stylesheets/decidim/meetings/_meetings.scss +2 -0
- data/app/permissions/decidim/meetings/admin/permissions.rb +16 -8
- data/app/permissions/decidim/meetings/permissions.rb +42 -17
- data/app/presenters/decidim/meetings/admin_log/meeting_presenter.rb +5 -1
- data/app/presenters/decidim/meetings/meeting_presenter.rb +25 -25
- data/app/queries/decidim/meetings/filtered_meetings.rb +1 -1
- data/app/queries/decidim/meetings/metrics/meetings_metric_manage.rb +1 -1
- data/app/queries/decidim/meetings/questionnaire_user_answers.rb +29 -0
- data/app/serializers/decidim/meetings/data_portability_invite_serializer.rb +2 -1
- data/app/serializers/decidim/meetings/data_portability_registration_serializer.rb +2 -1
- data/app/serializers/decidim/meetings/registration_serializer.rb +3 -12
- data/app/services/decidim/meetings/calendar/component_calendar.rb +2 -2
- data/app/services/decidim/meetings/calendar/meeting_calendar.rb +33 -0
- data/app/services/decidim/meetings/calendar_renderer.rb +2 -0
- data/app/services/decidim/meetings/meeting_iframe_embedder.rb +86 -0
- data/app/services/decidim/meetings/meeting_search.rb +2 -2
- data/app/views/decidim/meetings/admin/agenda/_form.html.erb +1 -1
- data/app/views/decidim/meetings/admin/invite_join_meeting_mailer/invite.html.erb +4 -4
- data/app/views/decidim/meetings/admin/invites/_form.html.erb +1 -1
- data/app/views/decidim/meetings/admin/meeting_closes/_form.html.erb +16 -1
- data/app/views/decidim/meetings/admin/meeting_copies/_form.html.erb +1 -1
- data/app/views/decidim/meetings/admin/meetings/_form.html.erb +16 -1
- data/app/views/decidim/meetings/admin/meetings/index.html.erb +39 -11
- data/app/views/decidim/meetings/admin/poll/_answer_option.html.erb +34 -0
- data/app/views/decidim/meetings/admin/poll/_answer_option_template.html.erb +7 -0
- data/app/views/decidim/meetings/admin/poll/_form.html.erb +63 -0
- data/app/views/decidim/meetings/admin/poll/_question.html.erb +96 -0
- data/app/views/decidim/meetings/admin/poll/edit.html.erb +9 -0
- data/app/views/decidim/meetings/admin/registrations/_form.html.erb +1 -1
- data/app/views/decidim/meetings/directory/meetings/index.html.erb +4 -4
- data/app/views/decidim/meetings/directory/meetings/index.js.erb +2 -0
- data/app/views/decidim/meetings/layouts/live_event.html.erb +50 -0
- data/app/views/decidim/meetings/live_events/show.html.erb +12 -0
- data/app/views/decidim/meetings/meeting_closes/_form.html.erb +8 -1
- data/app/views/decidim/meetings/meeting_closes/edit.html.erb +1 -1
- data/app/views/decidim/meetings/meetings/_calendar_modal.html.erb +26 -0
- data/app/views/decidim/meetings/meetings/_filters.html.erb +1 -1
- data/app/views/decidim/meetings/meetings/_form.html.erb +6 -1
- data/app/views/decidim/meetings/meetings/_linked_meetings.html.erb +1 -1
- data/app/views/decidim/meetings/meetings/_meeting_minutes.html.erb +7 -18
- data/app/views/decidim/meetings/meetings/edit.html.erb +1 -1
- data/app/views/decidim/meetings/meetings/index.html.erb +4 -4
- data/app/views/decidim/meetings/meetings/new.html.erb +1 -1
- data/app/views/decidim/meetings/meetings/show.html.erb +13 -14
- data/app/views/decidim/meetings/polls/answers/_multiple_option.html.erb +13 -0
- data/app/views/decidim/meetings/polls/answers/_single_option.html.erb +19 -0
- data/app/views/decidim/meetings/polls/answers/create.js.erb +5 -0
- data/app/views/decidim/meetings/polls/questions/_closed_question.html.erb +7 -0
- data/app/views/decidim/meetings/polls/questions/_index.html.erb +5 -0
- data/app/views/decidim/meetings/polls/questions/_index_admin.html.erb +43 -0
- data/app/views/decidim/meetings/polls/questions/_published_question.html.erb +29 -0
- data/app/views/decidim/meetings/polls/questions/_question.html.erb +7 -0
- data/app/views/decidim/meetings/polls/questions/index.js.erb +5 -0
- data/app/views/decidim/meetings/polls/questions/index_admin.js.erb +5 -0
- data/app/views/decidim/meetings/registration_mailer/confirmation.html.erb +5 -2
- data/app/views/devise/mailer/join_meeting.html.erb +6 -6
- data/config/assets.rb +11 -0
- data/config/locales/ar.yml +3 -24
- data/config/locales/ca.yml +36 -27
- data/config/locales/cs.yml +72 -26
- data/config/locales/de.yml +22 -27
- data/config/locales/el.yml +3 -24
- data/config/locales/en.yml +112 -26
- data/config/locales/es-MX.yml +13 -27
- data/config/locales/es-PY.yml +13 -27
- data/config/locales/es.yml +13 -27
- data/config/locales/eu.yml +3 -24
- data/config/locales/fi-plain.yml +70 -26
- data/config/locales/fi.yml +70 -26
- data/config/locales/fr-CA.yml +19 -26
- data/config/locales/fr-LU.yml +534 -0
- data/config/locales/fr.yml +19 -26
- data/config/locales/gl.yml +46 -24
- data/config/locales/hu.yml +5 -24
- data/config/locales/id-ID.yml +3 -24
- data/config/locales/is-IS.yml +2 -22
- data/config/locales/it.yml +117 -23
- data/config/locales/ja.yml +148 -58
- data/config/locales/lb-LU.yml +1 -0
- data/config/locales/lv.yml +3 -24
- data/config/locales/nl.yml +70 -25
- data/config/locales/no.yml +5 -26
- data/config/locales/pl.yml +22 -33
- data/config/locales/pt-BR.yml +178 -23
- data/config/locales/pt.yml +3 -24
- data/config/locales/ro-RO.yml +38 -27
- data/config/locales/ru.yml +3 -24
- data/config/locales/sk.yml +3 -24
- data/config/locales/sv.yml +36 -27
- data/config/locales/tr-TR.yml +5 -27
- data/config/locales/uk.yml +3 -24
- data/config/locales/zh-CN.yml +3 -24
- data/db/migrate/20210217124802_add_registration_custom_content_to_meetings.rb +8 -0
- data/db/migrate/20210413050756_add_published_at_to_meetings.rb +7 -0
- data/db/migrate/20210413050917_update_published_at_to_existing_meetings.rb +20 -0
- data/db/migrate/20210430123416_add_public_participation_to_decidim_meetings_registrations.rb +7 -0
- data/db/migrate/20210506180226_merge_meetings_minutes_into_meetings_table.rb +48 -0
- data/db/migrate/20210512055802_create_decidim_meetings_polls.rb +10 -0
- data/db/migrate/20210512100333_drop_decidim_meetings_minutes_table.rb +77 -0
- data/db/migrate/20210518133236_merge_minutes_with_closing_report_in_meetings_table.rb +57 -0
- data/db/migrate/20210520084247_create_decidim_meetings_questionnaires.rb +11 -0
- data/db/migrate/20210520084253_create_decidim_meetings_questions.rb +15 -0
- data/db/migrate/20210520084321_create_decidim_meetings_answers.rb +13 -0
- data/db/migrate/20210520084330_create_decidim_meetings_answer_options.rb +10 -0
- data/db/migrate/20210520084337_create_decidim_meetings_answer_choices.rb +13 -0
- data/db/migrate/20210520134834_add_status_to_meetings_questions.rb +7 -0
- data/db/migrate/20210602040614_add_setting_embed_iframe_to_meetings.rb +7 -0
- data/lib/decidim/api/linked_resources_interface.rb +8 -1
- data/lib/decidim/api/meeting_type.rb +19 -4
- data/lib/decidim/api/meetings_type.rb +2 -2
- data/lib/decidim/meetings/admin_engine.rb +5 -1
- data/lib/decidim/meetings/api.rb +0 -1
- data/lib/decidim/meetings/component.rb +41 -6
- data/lib/decidim/meetings/data_portability_user_answers_serializer.rb +33 -0
- data/lib/decidim/meetings/engine.rb +10 -11
- data/lib/decidim/meetings/meeting_serializer.rb +1 -0
- data/lib/decidim/meetings/polls.rb +10 -0
- data/lib/decidim/meetings/test/factories.rb +85 -9
- data/lib/decidim/meetings/user_answers_serializer.rb +47 -0
- data/lib/decidim/meetings/version.rb +1 -1
- data/lib/decidim/meetings.rb +10 -0
- metadata +103 -113
- data/app/assets/config/decidim_meetings_manifest.js +0 -9
- data/app/assets/javascripts/decidim/meetings/admin/agendas.js.es6 +0 -158
- data/app/assets/javascripts/decidim/meetings/meetings_form.js.es6 +0 -54
- data/app/commands/decidim/meetings/admin/create_minutes.rb +0 -55
- data/app/commands/decidim/meetings/admin/update_minutes.rb +0 -63
- data/app/controllers/decidim/meetings/admin/minutes_controller.rb +0 -69
- data/app/forms/decidim/meetings/admin/minutes_form.rb +0 -20
- data/app/models/decidim/meetings/minutes.rb +0 -22
- data/app/presenters/decidim/meetings/admin_log/minutes_presenter.rb +0 -42
- data/app/views/decidim/meetings/admin/minutes/_form.html.erb +0 -23
- data/app/views/decidim/meetings/admin/minutes/edit.html.erb +0 -7
- data/app/views/decidim/meetings/admin/minutes/new.html.erb +0 -7
- data/app/views/decidim/meetings/meetings/_online_meeting_link.html.erb +0 -11
- data/config/locales/ja-JP.yml +0 -494
- data/lib/decidim/api/minutes_type.rb +0 -20
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
module Admin
|
6
|
+
# This command is executed when the user changes a Questionnaire from the admin
|
7
|
+
# panel.
|
8
|
+
class UpdateQuestionnaire < Rectify::Command
|
9
|
+
# Initializes a UpdateQuestionnaire Command.
|
10
|
+
#
|
11
|
+
# form - The form from which to get the data.
|
12
|
+
# questionnaire - The current instance of the questionnaire to be updated.
|
13
|
+
def initialize(form, questionnaire)
|
14
|
+
@form = form
|
15
|
+
@questionnaire = questionnaire
|
16
|
+
end
|
17
|
+
|
18
|
+
# Updates the questionnaire if valid.
|
19
|
+
#
|
20
|
+
# Broadcasts :ok if successful, :invalid otherwise.
|
21
|
+
def call
|
22
|
+
return broadcast(:invalid) if @form.invalid?
|
23
|
+
|
24
|
+
Decidim::Meetings::Questionnaire.transaction do
|
25
|
+
create_questionnaire_for
|
26
|
+
create_questionaire
|
27
|
+
if @questionnaire.questions_editable?
|
28
|
+
update_questionnaire_questions
|
29
|
+
delete_answers
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
broadcast(:ok)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def create_questionnaire_for
|
39
|
+
@questionnaire.questionnaire_for.save! if @questionnaire.questionnaire_for.new_record?
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_questionaire
|
43
|
+
@questionnaire.save! if @questionnaire.new_record?
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_questionnaire_questions
|
47
|
+
@form.questions.each do |form_question|
|
48
|
+
update_questionnaire_question(form_question)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def update_questionnaire_question(form_question)
|
53
|
+
question_attributes = {
|
54
|
+
body: form_question.body,
|
55
|
+
position: form_question.position,
|
56
|
+
question_type: form_question.question_type,
|
57
|
+
max_choices: form_question.max_choices
|
58
|
+
}
|
59
|
+
|
60
|
+
update_nested_model(form_question, question_attributes, @questionnaire.questions) do |question|
|
61
|
+
form_question.answer_options.each do |form_answer_option|
|
62
|
+
answer_option_attributes = {
|
63
|
+
body: form_answer_option.body
|
64
|
+
}
|
65
|
+
|
66
|
+
update_nested_model(form_answer_option, answer_option_attributes, question.answer_options)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def update_nested_model(form, attributes, parent_association)
|
72
|
+
record = parent_association.find_by(id: form.id) || parent_association.build(attributes)
|
73
|
+
|
74
|
+
yield record if block_given?
|
75
|
+
|
76
|
+
if record.persisted?
|
77
|
+
if form.deleted?
|
78
|
+
record.destroy!
|
79
|
+
else
|
80
|
+
record.update!(attributes)
|
81
|
+
end
|
82
|
+
else
|
83
|
+
record.save!
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def delete_answers
|
88
|
+
@questionnaire.answers.destroy_all
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
# This command is executed when the user creates an Answer in a meeting poll.
|
6
|
+
class CreateAnswer < Rectify::Command
|
7
|
+
def initialize(form, current_user, questionnaire)
|
8
|
+
@form = form
|
9
|
+
@current_user = current_user
|
10
|
+
@questionnaire = questionnaire
|
11
|
+
end
|
12
|
+
|
13
|
+
# Creates the answer if valid.
|
14
|
+
#
|
15
|
+
# Broadcasts :ok if successful, :invalid otherwise.
|
16
|
+
def call
|
17
|
+
return broadcast(:invalid) if form.invalid?
|
18
|
+
|
19
|
+
transaction do
|
20
|
+
answer_question
|
21
|
+
end
|
22
|
+
|
23
|
+
broadcast(:ok)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :form, :answer
|
29
|
+
|
30
|
+
def invalid?
|
31
|
+
form.invalid?
|
32
|
+
end
|
33
|
+
|
34
|
+
def answer_question
|
35
|
+
answer = Answer.new(
|
36
|
+
user: @current_user,
|
37
|
+
questionnaire: @questionnaire,
|
38
|
+
question: form.question
|
39
|
+
)
|
40
|
+
|
41
|
+
form.selected_choices.each do |choice|
|
42
|
+
answer.choices.build(
|
43
|
+
body: choice.body,
|
44
|
+
decidim_answer_option_id: choice.answer_option_id
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
answer.save!
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -52,7 +52,9 @@ module Decidim
|
|
52
52
|
registration_terms: { I18n.locale => form.registration_terms },
|
53
53
|
registrations_enabled: form.registrations_enabled,
|
54
54
|
type_of_meeting: form.clean_type_of_meeting,
|
55
|
-
component: form.current_component
|
55
|
+
component: form.current_component,
|
56
|
+
published_at: Time.current,
|
57
|
+
show_embedded_iframe: form.show_embedded_iframe
|
56
58
|
}
|
57
59
|
|
58
60
|
@meeting = Decidim.traceability.create!(
|
@@ -62,7 +62,8 @@ module Decidim
|
|
62
62
|
registration_terms: { I18n.locale => form.registration_terms },
|
63
63
|
registrations_enabled: form.registrations_enabled,
|
64
64
|
type_of_meeting: form.clean_type_of_meeting,
|
65
|
-
online_meeting_url: form.online_meeting_url
|
65
|
+
online_meeting_url: form.online_meeting_url,
|
66
|
+
show_embedded_iframe: form.show_embedded_iframe
|
66
67
|
},
|
67
68
|
visibility: "public-only"
|
68
69
|
)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Meetings
|
7
|
+
module Admin
|
8
|
+
module Filterable
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
include Decidim::Admin::Filterable
|
13
|
+
|
14
|
+
helper Decidim::Meetings::Admin::FilterableHelper
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def base_query
|
19
|
+
Meeting.not_hidden.where(component: current_component).order(start_time: :desc).page(params[:page]).per(15)
|
20
|
+
end
|
21
|
+
|
22
|
+
def filters
|
23
|
+
[
|
24
|
+
:type_eq,
|
25
|
+
:is_upcoming_true,
|
26
|
+
:scope_id_eq,
|
27
|
+
:category_id_eq,
|
28
|
+
:origin_eq,
|
29
|
+
:closed_at_present
|
30
|
+
]
|
31
|
+
end
|
32
|
+
|
33
|
+
def filters_with_values
|
34
|
+
{
|
35
|
+
type_eq: meeting_types,
|
36
|
+
scope_id_eq: scope_ids_hash(scopes.top_level),
|
37
|
+
category_id_eq: category_ids_hash(categories.first_class),
|
38
|
+
closed_at_present: %w(true false),
|
39
|
+
is_upcoming_true: %w(true false),
|
40
|
+
origin_eq: %w(citizen official user_group)
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def search_field_predicate
|
45
|
+
:id_string_or_title_cont
|
46
|
+
end
|
47
|
+
|
48
|
+
def meeting_types
|
49
|
+
Meeting::TYPE_OF_MEETING
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
# This module, when injected into a controller, loads all the resources
|
6
|
+
# to display and interact with meeting polls.
|
7
|
+
module PollsResources
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
helper_method :meeting, :poll, :questionnaire
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def meeting
|
17
|
+
@meeting ||= Meeting.not_hidden.where(component: current_component).find(params[:meeting_id])
|
18
|
+
end
|
19
|
+
|
20
|
+
def poll
|
21
|
+
@poll ||= meeting&.poll
|
22
|
+
end
|
23
|
+
|
24
|
+
def questionnaire
|
25
|
+
@questionnaire ||= Decidim::Meetings::Questionnaire.find_by(questionnaire_for: poll) if poll
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -10,15 +10,19 @@ module Decidim
|
|
10
10
|
# override its layout and provide all kinds of useful methods.
|
11
11
|
class ApplicationController < Decidim::Admin::Components::BaseController
|
12
12
|
helper Decidim::ApplicationHelper
|
13
|
-
helper_method :meetings, :meeting
|
13
|
+
helper_method :meetings, :meeting, :maps_enabled?
|
14
14
|
|
15
15
|
def meetings
|
16
|
-
@meetings ||= Meeting.where(component: current_component).order(start_time: :desc).page(params[:page]).per(15)
|
16
|
+
@meetings ||= Meeting.not_hidden.where(component: current_component).order(start_time: :desc).page(params[:page]).per(15)
|
17
17
|
end
|
18
18
|
|
19
19
|
def meeting
|
20
20
|
@meeting ||= meetings.find(params[:id]) if params[:id]
|
21
21
|
end
|
22
|
+
|
23
|
+
def maps_enabled?
|
24
|
+
@maps_enabled ||= current_component.settings.maps_enabled?
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# This controller allows an admin to manage meetings from a Participatory Process
|
7
7
|
class MeetingClosesController < Admin::ApplicationController
|
8
|
-
include Decidim::Proposals::Admin::Picker
|
8
|
+
include Decidim::Proposals::Admin::Picker if Decidim::Meetings.enable_proposal_linking
|
9
9
|
|
10
10
|
helper_method :meeting
|
11
11
|
|
@@ -5,6 +5,8 @@ module Decidim
|
|
5
5
|
module Admin
|
6
6
|
# This controller allows an admin to manage meetings from a Participatory Process
|
7
7
|
class MeetingsController < Admin::ApplicationController
|
8
|
+
include Decidim::Meetings::Admin::Filterable
|
9
|
+
|
8
10
|
helper_method :blank_service
|
9
11
|
|
10
12
|
def new
|
@@ -61,7 +63,6 @@ module Decidim
|
|
61
63
|
Decidim::Meetings::Admin::DestroyMeeting.call(meeting, current_user) do
|
62
64
|
on(:ok) do
|
63
65
|
flash[:notice] = I18n.t("meetings.destroy.success", scope: "decidim.meetings.admin")
|
64
|
-
|
65
66
|
redirect_to meetings_path
|
66
67
|
end
|
67
68
|
|
@@ -77,8 +78,52 @@ module Decidim
|
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
81
|
+
def publish
|
82
|
+
enforce_permission_to :update, :meeting, meeting: meeting
|
83
|
+
|
84
|
+
Decidim::Meetings::Admin::PublishMeeting.call(meeting, current_user) do
|
85
|
+
on(:ok) do
|
86
|
+
flash[:notice] = I18n.t("meetings.publish.success", scope: "decidim.meetings.admin")
|
87
|
+
redirect_to meetings_path
|
88
|
+
end
|
89
|
+
|
90
|
+
on(:invalid) do
|
91
|
+
flash.now[:alert] = I18n.t("meetings.publish.invalid", scope: "decidim.meetings.admin")
|
92
|
+
render action: "index"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def unpublish
|
98
|
+
enforce_permission_to :update, :meeting, meeting: meeting
|
99
|
+
|
100
|
+
Decidim::Meetings::Admin::UnpublishMeeting.call(meeting, current_user) do
|
101
|
+
on(:ok) do
|
102
|
+
flash[:notice] = I18n.t("meetings.unpublish.success", scope: "decidim.meetings.admin")
|
103
|
+
redirect_to meetings_path
|
104
|
+
end
|
105
|
+
|
106
|
+
on(:invalid) do
|
107
|
+
flash.now[:alert] = I18n.t("meetings.unpublish.invalid", scope: "decidim.meetings.admin")
|
108
|
+
render action: "index"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
80
113
|
private
|
81
114
|
|
115
|
+
def meetings
|
116
|
+
@meetings ||= filtered_collection
|
117
|
+
end
|
118
|
+
|
119
|
+
def meeting
|
120
|
+
@meeting ||= meetings.find(params[:id])
|
121
|
+
end
|
122
|
+
|
123
|
+
def collection
|
124
|
+
@collection ||= Meeting.where(component: current_component).published.not_hidden
|
125
|
+
end
|
126
|
+
|
82
127
|
def meeting_form
|
83
128
|
form(Decidim::Meetings::Admin::MeetingForm)
|
84
129
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
module Admin
|
6
|
+
class MeetingsPollController < Admin::ApplicationController
|
7
|
+
include Decidim::TranslatableAttributes
|
8
|
+
|
9
|
+
helper_method :questionnaire_for, :questionnaire, :blank_question, :blank_answer_option,
|
10
|
+
:question_types, :update_url, :answer_options_url, :edit_questionnaire_title,
|
11
|
+
:meeting, :poll
|
12
|
+
|
13
|
+
helper Decidim::Forms::Admin::ApplicationHelper
|
14
|
+
|
15
|
+
def edit
|
16
|
+
enforce_permission_to :update, :poll, meeting: meeting, poll: poll
|
17
|
+
|
18
|
+
@form = form(Admin::QuestionnaireForm).from_model(questionnaire)
|
19
|
+
|
20
|
+
render template: "decidim/meetings/admin/poll/edit"
|
21
|
+
end
|
22
|
+
|
23
|
+
def update
|
24
|
+
enforce_permission_to :update, :poll, meeting: meeting, poll: poll
|
25
|
+
|
26
|
+
@form = form(Admin::QuestionnaireForm).from_params(params)
|
27
|
+
|
28
|
+
Admin::UpdateQuestionnaire.call(@form, questionnaire) do
|
29
|
+
on(:ok) do
|
30
|
+
# i18n-tasks-use t("decidim.forms.admin.questionnaires.update.success")
|
31
|
+
flash[:notice] = I18n.t("update.success", scope: "decidim.meetings.admin.meetings_poll")
|
32
|
+
redirect_to after_update_url
|
33
|
+
end
|
34
|
+
|
35
|
+
on(:invalid) do
|
36
|
+
# i18n-tasks-use t("decidim.forms.admin.questionnaires.update.invalid")
|
37
|
+
flash.now[:alert] = I18n.t("update.invalid", scope: "decidim.meetings.admin.meetings_poll")
|
38
|
+
render template: "decidim/meetings/admin/poll/edit"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def answer_options
|
44
|
+
respond_to do |format|
|
45
|
+
format.json do
|
46
|
+
question_id = params["id"]
|
47
|
+
question = Decidim::Meetings::Question.find_by(id: question_id)
|
48
|
+
render json: question.answer_options.map { |answer_option| AnswerOptionPresenter.new(answer_option).as_json } if question.present?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def questionnaire_for
|
54
|
+
poll
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns the url to get the answer options json (for the display conditions form)
|
58
|
+
# for the question with id = params[:id]
|
59
|
+
def answer_options_url(params)
|
60
|
+
url_for([questionnaire.questionnaire_for, { action: :answer_options, format: :json, **params }])
|
61
|
+
end
|
62
|
+
|
63
|
+
# Implement this method in your controller to set the title
|
64
|
+
# of the edit form.
|
65
|
+
def edit_questionnaire_title
|
66
|
+
t(:title, scope: "decidim.meetings.admin.meetings_poll.form", questionnaire_for: translated_attribute(meeting.try(:title)))
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def questionnaire
|
72
|
+
@questionnaire ||= Decidim::Meetings::Questionnaire.find_or_initialize_by(questionnaire_for: questionnaire_for)
|
73
|
+
end
|
74
|
+
|
75
|
+
def blank_question
|
76
|
+
@blank_question ||= Decidim::Meetings::Admin::QuestionForm.new
|
77
|
+
end
|
78
|
+
|
79
|
+
def blank_answer_option
|
80
|
+
@blank_answer_option ||= Decidim::Meetings::Admin::AnswerOptionForm.new
|
81
|
+
end
|
82
|
+
|
83
|
+
def question_types
|
84
|
+
@question_types ||= Decidim::Meetings::Poll::QUESTION_TYPES.map do |question_type|
|
85
|
+
[question_type, I18n.t("decidim.forms.question_types.#{question_type}")]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def update_url
|
90
|
+
meeting_poll_path(meeting_id: meeting.id)
|
91
|
+
end
|
92
|
+
|
93
|
+
def after_update_url
|
94
|
+
edit_meeting_poll_path(meeting_id: meeting.id)
|
95
|
+
end
|
96
|
+
|
97
|
+
def meeting
|
98
|
+
@meeting ||= Meeting.where(component: current_component).find(params[:meeting_id])
|
99
|
+
end
|
100
|
+
|
101
|
+
def poll
|
102
|
+
@poll ||= Poll.find_or_initialize_by(meeting: meeting)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -14,8 +14,16 @@ module Decidim
|
|
14
14
|
render plain: CalendarRenderer.for(current_component), content_type: "type/calendar"
|
15
15
|
end
|
16
16
|
|
17
|
+
def meeting_calendar
|
18
|
+
send_data CalendarRenderer.for(meeting), content_type: "type/calendar", filename: "#{meeting.reference}.ics"
|
19
|
+
end
|
20
|
+
|
17
21
|
private
|
18
22
|
|
23
|
+
def meeting
|
24
|
+
@meeting ||= Decidim::Meetings::Meeting.where(component: current_component).find(params[:id])
|
25
|
+
end
|
26
|
+
|
19
27
|
def set_default_request_format
|
20
28
|
request.format = :text
|
21
29
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
# Exposes the live event of the meeting
|
6
|
+
class LiveEventsController < Decidim::Meetings::ApplicationController
|
7
|
+
layout "decidim/meetings/layouts/live_event"
|
8
|
+
|
9
|
+
include Decidim::Meetings::PollsResources
|
10
|
+
|
11
|
+
helper_method :live_meeting_embed_code
|
12
|
+
|
13
|
+
def show
|
14
|
+
raise ActionController::RoutingError, "Not Found" unless meeting
|
15
|
+
|
16
|
+
return if meeting.current_user_can_visit_meeting?(current_user)
|
17
|
+
|
18
|
+
flash[:alert] = I18n.t("meeting.not_allowed", scope: "decidim.meetings")
|
19
|
+
redirect_to(ResourceLocatorPresenter.new(meeting).index)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def live_meeting_embed_code
|
25
|
+
MeetingIframeEmbedder.new(meeting.online_meeting_url).embed_code(request.host)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -4,7 +4,7 @@ module Decidim
|
|
4
4
|
module Meetings
|
5
5
|
# This controller allows a participant to update the closing_report and the linked proposals of a closed meeting
|
6
6
|
class MeetingClosesController < Decidim::Meetings::ApplicationController
|
7
|
-
include Decidim::Proposals::Admin::Picker
|
7
|
+
include Decidim::Proposals::Admin::Picker if Decidim::Meetings.enable_proposal_linking
|
8
8
|
include FormFactory
|
9
9
|
|
10
10
|
helper_method :meeting
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
module Polls
|
6
|
+
class AnswersController < Decidim::Meetings::ApplicationController
|
7
|
+
include Decidim::Meetings::PollsResources
|
8
|
+
include FormFactory
|
9
|
+
|
10
|
+
helper_method :question
|
11
|
+
|
12
|
+
def create
|
13
|
+
enforce_permission_to :create, :answer, question: question
|
14
|
+
@form = form(AnswerForm).from_params(params, question: question, current_user: current_user)
|
15
|
+
|
16
|
+
CreateAnswer.call(@form, current_user, questionnaire) do
|
17
|
+
# Both :ok and :invalid render the same template, because
|
18
|
+
# validation errors are displayed in the template
|
19
|
+
respond_to do |format|
|
20
|
+
format.js
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def question
|
28
|
+
@question ||= questionnaire.questions.find(answer_params[:question_id]) if questionnaire
|
29
|
+
end
|
30
|
+
|
31
|
+
def answer_params
|
32
|
+
params.require(:answer).permit(:question_id, choices: [:body, :answer_option_id])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
module Polls
|
6
|
+
class QuestionsController < Decidim::Meetings::ApplicationController
|
7
|
+
include Decidim::Meetings::PollsResources
|
8
|
+
|
9
|
+
def index
|
10
|
+
respond_to do |format|
|
11
|
+
format.js do
|
12
|
+
render template: pick_index_template, locals: { open_question: nil }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def update
|
18
|
+
enforce_permission_to :update, :question, question: question
|
19
|
+
|
20
|
+
Decidim::Meetings::Admin::UpdateQuestionStatus.call(question, current_user) do
|
21
|
+
respond_to do |format|
|
22
|
+
format.js do
|
23
|
+
render template: admin_index_template, locals: { open_question: question.id }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def question
|
32
|
+
@question ||= questionnaire.questions.find(params[:id]) if questionnaire
|
33
|
+
end
|
34
|
+
|
35
|
+
def admin_index_template
|
36
|
+
"decidim/meetings/polls/questions/index_admin"
|
37
|
+
end
|
38
|
+
|
39
|
+
def pick_index_template
|
40
|
+
params[:admin] ? admin_index_template : "decidim/meetings/polls/questions/index"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -3,9 +3,25 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Meetings
|
5
5
|
class CreateMeetingEvent < Decidim::Events::SimpleEvent
|
6
|
+
delegate :organization, to: :user, prefix: false
|
7
|
+
|
6
8
|
def resource_text
|
7
9
|
translated_attribute(resource.description)
|
8
10
|
end
|
11
|
+
|
12
|
+
def button_text
|
13
|
+
I18n.t("meeting_created.button_text", scope: "decidim.events.meetings") if resource.can_be_joined_by?(user)
|
14
|
+
end
|
15
|
+
|
16
|
+
def button_url
|
17
|
+
if resource.can_be_joined_by?(user)
|
18
|
+
if resource.registration_form_enabled?
|
19
|
+
Decidim::EngineRouter.main_proxy(component).join_meeting_registration_url(meeting_id: resource.id, host: organization.host)
|
20
|
+
else
|
21
|
+
Decidim::EngineRouter.main_proxy(component).meeting_url(id: resource.id, host: organization.host)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
9
25
|
end
|
10
26
|
end
|
11
27
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
module Admin
|
6
|
+
# This class holds a Form to update answer options
|
7
|
+
class AnswerOptionForm < Decidim::Form
|
8
|
+
include TranslatableAttributes
|
9
|
+
|
10
|
+
attribute :deleted, Boolean, default: false
|
11
|
+
|
12
|
+
translatable_attribute :body, String
|
13
|
+
|
14
|
+
validates :body, translatable_presence: true, unless: :deleted
|
15
|
+
|
16
|
+
def to_param
|
17
|
+
return id if id.present?
|
18
|
+
|
19
|
+
"questionnaire-question-answer-option-id"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|