decidim-meetings 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 (105) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/admin/decidim_meetings_manifest.js +2 -0
  3. data/app/assets/javascripts/decidim/meetings/admin/agendas.js.es6 +158 -0
  4. data/app/assets/javascripts/decidim/meetings/admin/meetings_form.js.es6 +19 -0
  5. data/app/cells/decidim/meetings/join_meeting_button/registration_confirm.erb +15 -0
  6. data/app/cells/decidim/meetings/join_meeting_button/show.erb +27 -0
  7. data/app/cells/decidim/meetings/join_meeting_button_cell.rb +37 -0
  8. data/app/cells/decidim/meetings/meeting_cell.rb +2 -13
  9. data/app/cells/decidim/meetings/meeting_list_item_cell.rb +8 -0
  10. data/app/cells/decidim/meetings/meeting_m/address.erb +14 -0
  11. data/app/cells/decidim/meetings/meeting_m/data.erb +2 -0
  12. data/app/cells/decidim/meetings/meeting_m/date.erb +8 -0
  13. data/app/cells/decidim/meetings/meeting_m/footer.erb +9 -0
  14. data/app/cells/decidim/meetings/meeting_m/multiple_dates.erb +17 -0
  15. data/app/cells/decidim/meetings/meeting_m/single_date.erb +9 -0
  16. data/app/cells/decidim/meetings/meeting_m/tags.erb +1 -0
  17. data/app/cells/decidim/meetings/meeting_m_cell.rb +37 -4
  18. data/app/commands/decidim/meetings/admin/copy_meeting.rb +3 -0
  19. data/app/commands/decidim/meetings/admin/create_agenda.rb +93 -0
  20. data/app/commands/decidim/meetings/admin/create_meeting.rb +3 -0
  21. data/app/commands/decidim/meetings/admin/create_minutes.rb +55 -0
  22. data/app/commands/decidim/meetings/admin/update_agenda.rb +90 -0
  23. data/app/commands/decidim/meetings/admin/update_meeting.rb +4 -1
  24. data/app/commands/decidim/meetings/admin/update_minutes.rb +62 -0
  25. data/app/controllers/decidim/meetings/admin/agenda_controller.rb +75 -0
  26. data/app/controllers/decidim/meetings/admin/attachments_controller.rb +1 -1
  27. data/app/controllers/decidim/meetings/admin/invites_controller.rb +4 -0
  28. data/app/controllers/decidim/meetings/admin/meeting_closes_controller.rb +4 -0
  29. data/app/controllers/decidim/meetings/admin/meeting_copies_controller.rb +4 -0
  30. data/app/controllers/decidim/meetings/admin/meetings_controller.rb +10 -0
  31. data/app/controllers/decidim/meetings/admin/minutes_controller.rb +69 -0
  32. data/app/controllers/decidim/meetings/admin/registrations_controller.rb +6 -0
  33. data/app/controllers/decidim/meetings/meetings_controller.rb +7 -1
  34. data/app/controllers/decidim/meetings/registrations_controller.rb +12 -6
  35. data/app/forms/decidim/meetings/admin/meeting_agenda_form.rb +54 -0
  36. data/app/forms/decidim/meetings/admin/meeting_agenda_items_form.rb +33 -0
  37. data/app/forms/decidim/meetings/admin/meeting_copy_form.rb +8 -0
  38. data/app/forms/decidim/meetings/admin/meeting_form.rb +8 -0
  39. data/app/forms/decidim/meetings/admin/meeting_registration_invite_form.rb +2 -1
  40. data/app/forms/decidim/meetings/admin/minutes_form.rb +20 -0
  41. data/app/helpers/decidim/meetings/admin/application_helper.rb +13 -0
  42. data/{lib/decidim/meetings/view_model.rb → app/helpers/decidim/meetings/meeting_cells_helper.rb} +7 -1
  43. data/app/helpers/decidim/meetings/meetings_helper.rb +67 -0
  44. data/app/models/decidim/meetings/agenda.rb +19 -0
  45. data/app/models/decidim/meetings/agenda_item.rb +35 -0
  46. data/app/models/decidim/meetings/meeting.rb +52 -3
  47. data/app/models/decidim/meetings/minutes.rb +19 -0
  48. data/app/permissions/decidim/meetings/admin/permissions.rb +69 -0
  49. data/app/permissions/decidim/meetings/permissions.rb +41 -0
  50. data/app/presenters/decidim/meetings/admin_log/meeting_presenter.rb +4 -1
  51. data/app/presenters/decidim/meetings/admin_log/minutes_presenter.rb +42 -0
  52. data/app/presenters/decidim/meetings/admin_log/value_types/organizer_presenter.rb +69 -0
  53. data/app/types/decidim/meetings/meeting_type.rb +4 -4
  54. data/app/views/decidim/meetings/admin/agenda/_agenda_item.html.erb +50 -0
  55. data/app/views/decidim/meetings/admin/agenda/_agenda_item_child.html.erb +26 -0
  56. data/app/views/decidim/meetings/admin/agenda/_agenda_item_fields.html.erb +19 -0
  57. data/app/views/decidim/meetings/admin/agenda/_form.html.erb +66 -0
  58. data/app/views/decidim/meetings/admin/agenda/edit.html.erb +7 -0
  59. data/app/views/decidim/meetings/admin/agenda/new.html.erb +8 -0
  60. data/app/views/decidim/meetings/admin/agenda/show.html.erb +0 -0
  61. data/app/views/decidim/meetings/admin/meeting_copies/_form.html.erb +15 -1
  62. data/app/views/decidim/meetings/admin/meetings/_form.html.erb +15 -0
  63. data/app/views/decidim/meetings/admin/meetings/index.html.erb +9 -7
  64. data/app/views/decidim/meetings/admin/minutes/_form.html.erb +23 -0
  65. data/app/views/decidim/meetings/admin/minutes/edit.html.erb +7 -0
  66. data/app/views/decidim/meetings/admin/minutes/new.html.erb +7 -0
  67. data/app/views/decidim/meetings/admin/registrations/_form.html.erb +11 -9
  68. data/app/views/decidim/meetings/meetings/_linked_meetings.html.erb +0 -1
  69. data/app/views/decidim/meetings/meetings/_meeting_agenda.html.erb +31 -0
  70. data/app/views/decidim/meetings/meetings/_meeting_minutes.html.erb +48 -0
  71. data/app/views/decidim/meetings/meetings/_meetings.html.erb +1 -1
  72. data/app/views/decidim/meetings/meetings/show.html.erb +23 -12
  73. data/app/views/decidim/participatory_spaces/_meeting.html.erb +1 -1
  74. data/app/views/decidim/participatory_spaces/_upcoming_meeting_for_card.html.erb +6 -0
  75. data/config/locales/ca.yml +106 -4
  76. data/config/locales/en.yml +106 -4
  77. data/config/locales/es.yml +106 -4
  78. data/config/locales/eu.yml +106 -4
  79. data/config/locales/fi.yml +106 -4
  80. data/config/locales/fr.yml +106 -4
  81. data/config/locales/gl.yml +106 -4
  82. data/config/locales/it.yml +106 -4
  83. data/config/locales/nl.yml +106 -4
  84. data/config/locales/pl.yml +112 -4
  85. data/config/locales/pt-BR.yml +106 -4
  86. data/config/locales/pt.yml +106 -4
  87. data/config/locales/ru.yml +97 -4
  88. data/config/locales/sv.yml +106 -4
  89. data/config/locales/uk.yml +112 -4
  90. data/db/migrate/20180403145218_add_meeting_types.rb +8 -0
  91. data/db/migrate/20180404075312_add_organizer_to_meetings.rb +7 -0
  92. data/db/migrate/20180406080619_create_meetings_minutes.rb +15 -0
  93. data/db/migrate/20180419131924_create_decidim_agendas.rb +13 -0
  94. data/db/migrate/20180419132104_create_decidim_agenda_items.rb +16 -0
  95. data/db/migrate/20180516102301_index_meetings_as_searchable_resources.rb +24 -0
  96. data/lib/decidim/meetings/admin_engine.rb +2 -0
  97. data/lib/decidim/meetings/component.rb +3 -2
  98. data/lib/decidim/meetings/engine.rb +16 -6
  99. data/lib/decidim/meetings/test/factories.rb +44 -0
  100. data/lib/decidim/meetings/version.rb +1 -1
  101. metadata +63 -21
  102. data/app/cells/decidim/meetings/meeting_m/header.erb +0 -5
  103. data/app/cells/decidim/meetings/meeting_m/show.erb +0 -21
  104. data/app/models/decidim/meetings/abilities/current_user_ability.rb +0 -43
  105. data/app/views/decidim/meetings/meetings/_registration_confirm.html.erb +0 -15
@@ -54,6 +54,9 @@ module Decidim
54
54
  location_hints: @form.location_hints,
55
55
  services: @form.services_to_persist.map { |service| { "title" => service.title, "description" => service.description } },
56
56
  component: @meeting.component,
57
+ private_meeting: @form.private_meeting,
58
+ transparent: @form.transparent,
59
+ organizer: @form.organizer,
57
60
  registrations_enabled: @meeting.registrations_enabled,
58
61
  available_slots: @meeting.available_slots,
59
62
  registration_terms: @meeting.registration_terms
@@ -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 creates a Meeting from the admin
7
+ # panel.
8
+ class CreateAgenda < Rectify::Command
9
+ def initialize(form, meeting)
10
+ @form = form
11
+ @meeting = meeting
12
+ @agenda = nil
13
+ end
14
+
15
+ # Creates the agenda if valid.
16
+ #
17
+ # Broadcasts :ok if successful, :invalid otherwise.
18
+ def call
19
+ return broadcast(:invalid) if @form.invalid?
20
+
21
+ transaction do
22
+ create_agenda!
23
+ create_agenda_items
24
+ end
25
+
26
+ broadcast(:ok, @agenda)
27
+ end
28
+
29
+ private
30
+
31
+ attr_reader :form, :meeting
32
+
33
+ def create_agenda_items
34
+ @form.agenda_items.each do |form_agenda_item|
35
+ create_agenda_item(form_agenda_item)
36
+ end
37
+ end
38
+
39
+ def create_agenda_item(form_agenda_item)
40
+ agenda_item_attributes = {
41
+ title: form_agenda_item.title,
42
+ description: form_agenda_item.description,
43
+ position: form_agenda_item.position,
44
+ duration: form_agenda_item.duration,
45
+ parent_id: form_agenda_item.parent_id,
46
+ agenda: @agenda
47
+ }
48
+
49
+ create_nested_model(form_agenda_item, agenda_item_attributes, @form.agenda_items) do |agenda_item|
50
+ form_agenda_item.agenda_item_children.each do |form_agenda_item_child|
51
+ agenda_item_child_attributes = {
52
+ title: form_agenda_item_child.title,
53
+ description: form_agenda_item_child.description,
54
+ position: form_agenda_item_child.position,
55
+ duration: form_agenda_item_child.duration,
56
+ parent_id: agenda_item.id,
57
+ agenda: @agenda
58
+ }
59
+
60
+ create_nested_model(form_agenda_item_child, agenda_item_child_attributes, agenda_item.agenda_item_children)
61
+ end
62
+ end
63
+ end
64
+
65
+ def create_nested_model(form, attributes, _agenda_item_children)
66
+ record = Decidim::Meetings::AgendaItem.find_or_create_by!(attributes)
67
+
68
+ yield record if block_given?
69
+
70
+ if record.persisted?
71
+ if form.deleted?
72
+ record.destroy!
73
+ else
74
+ record.update!(attributes)
75
+ end
76
+ else
77
+ record.save!
78
+ end
79
+ end
80
+
81
+ def create_agenda!
82
+ @agenda = Decidim.traceability.create!(
83
+ Agenda,
84
+ @form.current_user,
85
+ title: @form.title,
86
+ visible: @form.visible,
87
+ meeting: @meeting
88
+ )
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -43,6 +43,9 @@ module Decidim
43
43
  longitude: @form.longitude,
44
44
  location: @form.location,
45
45
  location_hints: @form.location_hints,
46
+ private_meeting: @form.private_meeting,
47
+ transparent: @form.transparent,
48
+ organizer: @form.organizer,
46
49
  registration_terms: @form.current_component.settings.default_registration_terms,
47
50
  component: @form.current_component
48
51
  )
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ module Admin
6
+ # This command is executed when the user creates a Minutes from the admin
7
+ # panel.
8
+ class CreateMinutes < Rectify::Command
9
+ def initialize(form, meeting)
10
+ @form = form
11
+ @meeting = meeting
12
+ end
13
+
14
+ # Creates the meeting if valid.
15
+ #
16
+ # Broadcasts :ok if successful, :invalid otherwise.
17
+ def call
18
+ return broadcast(:invalid) if @form.invalid?
19
+
20
+ transaction do
21
+ create_minutes!
22
+ end
23
+
24
+ broadcast(:ok, @minutes)
25
+ end
26
+
27
+ private
28
+
29
+ def create_minutes!
30
+ log_info = {
31
+ resource: {
32
+ title: @meeting.title
33
+ },
34
+ participatory_space: {
35
+ title: @meeting.participatory_space.title
36
+ }
37
+ }
38
+
39
+ @minutes = Decidim.traceability.create!(
40
+ Minutes,
41
+ @form.current_user,
42
+ {
43
+ description: @form.description,
44
+ video_url: @form.video_url,
45
+ audio_url: @form.audio_url,
46
+ visible: @form.visible,
47
+ meeting: @meeting
48
+ },
49
+ log_info
50
+ )
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ module Admin
6
+ # This command is executed when the user creates a Meeting from the admin
7
+ # panel.
8
+ class UpdateAgenda < Rectify::Command
9
+ def initialize(form, agenda)
10
+ @form = form
11
+ @agenda = agenda
12
+ end
13
+
14
+ # Creates the agenda if valid.
15
+ #
16
+ # Broadcasts :ok if successful, :invalid otherwise.
17
+ def call
18
+ return broadcast(:invalid) if @form.invalid?
19
+
20
+ transaction do
21
+ update_agenda!
22
+ update_agenda_items
23
+ end
24
+
25
+ broadcast(:ok, @agenda)
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :form
31
+
32
+ def update_agenda_items
33
+ @form.agenda_items.each do |form_agenda_item|
34
+ update_agenda_item(form_agenda_item)
35
+ end
36
+ end
37
+
38
+ def update_agenda_item(form_agenda_item)
39
+ agenda_item_attributes = {
40
+ title: form_agenda_item.title,
41
+ description: form_agenda_item.description,
42
+ position: form_agenda_item.position,
43
+ duration: form_agenda_item.duration,
44
+ parent_id: form_agenda_item.parent_id
45
+ }
46
+
47
+ update_nested_model(form_agenda_item, agenda_item_attributes, @agenda.agenda_items) do |agenda_item|
48
+ form_agenda_item.agenda_item_children.each do |form_agenda_item_child|
49
+ agenda_item_child_attributes = {
50
+ title: form_agenda_item_child.title,
51
+ description: form_agenda_item_child.description,
52
+ position: form_agenda_item_child.position,
53
+ duration: form_agenda_item_child.duration,
54
+ parent_id: agenda_item.id,
55
+ agenda: @agenda
56
+ }
57
+
58
+ update_nested_model(form_agenda_item_child, agenda_item_child_attributes, agenda_item.agenda_item_children)
59
+ end
60
+ end
61
+ end
62
+
63
+ def update_nested_model(form, attributes, agenda_item_children)
64
+ record = agenda_item_children.find_by(id: form.id) || agenda_item_children.build(attributes)
65
+
66
+ yield record if block_given?
67
+
68
+ if record.persisted?
69
+ if form.deleted?
70
+ record.destroy!
71
+ else
72
+ record.update!(attributes)
73
+ end
74
+ else
75
+ record.save!
76
+ end
77
+ end
78
+
79
+ def update_agenda!
80
+ Decidim.traceability.update!(
81
+ @agenda,
82
+ form.current_user,
83
+ title: form.title,
84
+ visible: form.visible
85
+ )
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -49,7 +49,10 @@ module Decidim
49
49
  latitude: form.latitude,
50
50
  longitude: form.longitude,
51
51
  location: form.location,
52
- location_hints: form.location_hints
52
+ location_hints: form.location_hints,
53
+ private_meeting: form.private_meeting,
54
+ transparent: form.transparent,
55
+ organizer: form.organizer
53
56
  )
54
57
  end
55
58
 
@@ -0,0 +1,62 @@
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 Minutes from the admin
7
+ # panel.
8
+ class UpdateMinutes < Rectify::Command
9
+ # Initializes a UpdateMinutes Command.
10
+ #
11
+ # form - The form from which to get the data.
12
+ # current_meeting - The current instance of the meeting.
13
+ # minutes - The current instance of the minutes to be updated.
14
+ def initialize(form, current_meeting, minutes)
15
+ @form = form
16
+ @current_meeting = current_meeting
17
+ @minutes = minutes
18
+ end
19
+
20
+ # Updates the minute if valid.
21
+ #
22
+ # Broadcasts :ok if successful, :invalid otherwise.
23
+ def call
24
+ return broadcast(:invalid) if form.invalid?
25
+ transaction do
26
+ update_minutes!
27
+ end
28
+
29
+ broadcast(:ok, minutes)
30
+ end
31
+
32
+ private
33
+
34
+ attr_reader :form, :current_meeting, :minutes
35
+
36
+ def update_minutes!
37
+ log_info = {
38
+ resource: {
39
+ title: @current_meeting.title
40
+ },
41
+ participatory_space: {
42
+ title: @current_meeting.participatory_space.title
43
+ }
44
+ }
45
+
46
+ @minutes = Decidim.traceability.update!(
47
+ minutes,
48
+ form.current_user,
49
+ {
50
+ description: form.description,
51
+ video_url: form.video_url,
52
+ audio_url: form.audio_url,
53
+ visible: form.visible,
54
+ meeting: current_meeting
55
+ },
56
+ log_info
57
+ )
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ module Admin
6
+ # Controller that allows managing the agendas for the given meeting
7
+ #
8
+ class AgendaController < Admin::ApplicationController
9
+ helper_method :meeting, :agenda, :blank_agenda_item, :blank_agenda_item_child
10
+
11
+ def new
12
+ enforce_permission_to :create, :agenda, meeting: meeting
13
+
14
+ @form = form(MeetingAgendaForm).instance
15
+ end
16
+
17
+ def create
18
+ enforce_permission_to :create, :agenda, meeting: meeting
19
+
20
+ @form = form(MeetingAgendaForm).from_params(params, meeting: meeting)
21
+
22
+ CreateAgenda.call(@form, meeting) do
23
+ on(:ok) do
24
+ flash[:notice] = I18n.t("agenda.create.success", scope: "decidim.meetings.admin")
25
+ redirect_to meetings_path
26
+ end
27
+
28
+ on(:invalid) do
29
+ flash.now[:alert] = I18n.t("agenda.create.invalid", scope: "decidim.meetings.admin")
30
+ render action: "new"
31
+ end
32
+ end
33
+ end
34
+
35
+ def edit
36
+ enforce_permission_to :update, :agenda, agenda: agenda, meeting: meeting
37
+
38
+ @form = form(MeetingAgendaForm).from_model(agenda)
39
+ end
40
+
41
+ def update
42
+ enforce_permission_to :update, :agenda, agenda: agenda, meeting: meeting
43
+
44
+ @form = form(MeetingAgendaForm).from_params(params, meeting: meeting)
45
+
46
+ UpdateAgenda.call(@form, agenda) do
47
+ on(:ok) do
48
+ flash[:notice] = I18n.t("agenda.update.success", scope: "decidim.meetings.admin")
49
+ redirect_to meetings_path
50
+ end
51
+
52
+ on(:invalid) do
53
+ flash.now[:alert] = I18n.t("agenda.update.invalid", scope: "decidim.meetings.admin")
54
+ render action: "edit"
55
+ end
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ def meeting
62
+ @meeting ||= Meeting.where(component: current_component).find(params[:meeting_id])
63
+ end
64
+
65
+ def agenda
66
+ @agenda ||= meeting.agenda
67
+ end
68
+
69
+ def blank_agenda_item
70
+ @blank_agenda_item ||= Admin::MeetingAgendaItemsForm.new
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -6,7 +6,7 @@ module Decidim
6
6
  # Controller that allows managing all the attachments for a participatory
7
7
  # process.
8
8
  #
9
- class AttachmentsController < Admin::ApplicationController
9
+ class AttachmentsController < Decidim::Meetings::Admin::ApplicationController
10
10
  include Decidim::Admin::Concerns::HasAttachments
11
11
 
12
12
  def after_destroy_path
@@ -9,10 +9,14 @@ module Decidim
9
9
  #
10
10
  class InvitesController < Admin::ApplicationController
11
11
  def new
12
+ enforce_permission_to :invite_user, :meeting, meeting: meeting
13
+
12
14
  @form = form(MeetingRegistrationInviteForm).instance
13
15
  end
14
16
 
15
17
  def create
18
+ enforce_permission_to :invite_user, :meeting, meeting: meeting
19
+
16
20
  @form = form(MeetingRegistrationInviteForm).from_params(params)
17
21
 
18
22
  InviteUserToJoinMeeting.call(@form, meeting, current_user) do
@@ -8,10 +8,14 @@ module Decidim
8
8
  helper_method :meeting
9
9
 
10
10
  def edit
11
+ enforce_permission_to :close, :meeting, meeting: meeting
12
+
11
13
  @form = form(CloseMeetingForm).from_model(meeting)
12
14
  end
13
15
 
14
16
  def update
17
+ enforce_permission_to :close, :meeting, meeting: meeting
18
+
15
19
  @form = form(CloseMeetingForm).from_params(params.merge(proposals: meeting.sibling_scope(:proposals)))
16
20
 
17
21
  CloseMeeting.call(@form, meeting) do