decidim-meetings 0.10.1 → 0.11.0.pre1
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/assets/config/admin/decidim_meetings_manifest.js +1 -0
- data/app/assets/javascripts/decidim/meetings/admin/meetings_form.js.es6 +78 -0
- data/app/assets/javascripts/decidim/meetings/admin/registrations_form.js.es6 +9 -7
- data/app/cells/decidim/meetings/meeting_cell.rb +71 -0
- data/app/cells/decidim/meetings/meeting_list_item/show.erb +14 -0
- data/app/cells/decidim/meetings/meeting_list_item_cell.rb +26 -0
- data/app/cells/decidim/meetings/meeting_m/header.erb +5 -0
- data/app/cells/decidim/meetings/meeting_m/show.erb +21 -0
- data/app/cells/decidim/meetings/meeting_m_cell.rb +17 -0
- data/app/commands/decidim/meetings/admin/copy_meeting.rb +82 -0
- data/app/commands/decidim/meetings/admin/create_meeting.rb +3 -1
- data/app/commands/decidim/meetings/admin/export_meeting_registrations.rb +44 -0
- data/app/commands/decidim/meetings/admin/update_meeting.rb +1 -0
- data/app/commands/decidim/meetings/admin/update_registrations.rb +1 -0
- data/app/commands/decidim/meetings/join_meeting.rb +1 -1
- data/app/commands/decidim/meetings/leave_meeting.rb +1 -1
- data/app/controllers/decidim/meetings/admin/application_controller.rb +3 -3
- data/app/controllers/decidim/meetings/admin/attachment_collections_controller.rb +2 -2
- data/app/controllers/decidim/meetings/admin/attachments_controller.rb +1 -1
- data/app/controllers/decidim/meetings/admin/invites_controller.rb +1 -1
- data/app/controllers/decidim/meetings/admin/meeting_closes_controller.rb +1 -1
- data/app/controllers/decidim/meetings/admin/meeting_copies_controller.rb +43 -0
- data/app/controllers/decidim/meetings/admin/meetings_controller.rb +10 -2
- data/app/controllers/decidim/meetings/admin/registrations_controller.rb +6 -5
- data/app/controllers/decidim/meetings/application_controller.rb +2 -2
- data/app/controllers/decidim/meetings/meeting_widgets_controller.rb +1 -1
- data/app/controllers/decidim/meetings/meetings_controller.rb +2 -2
- data/app/controllers/decidim/meetings/registrations_controller.rb +1 -1
- data/app/forms/decidim/meetings/admin/meeting_copy_form.rb +54 -0
- data/app/forms/decidim/meetings/admin/meeting_form.rb +17 -6
- data/app/forms/decidim/meetings/admin/meeting_registrations_form.rb +10 -1
- data/app/forms/decidim/meetings/admin/meeting_service_form.rb +23 -0
- data/app/helpers/decidim/meetings/admin/application_helper.rb +4 -0
- data/app/mailers/decidim/meetings/admin/invite_join_meeting_mailer.rb +1 -1
- data/app/models/decidim/meetings/abilities/current_user_ability.rb +6 -6
- data/app/models/decidim/meetings/meeting.rb +14 -8
- data/app/presenters/decidim/meetings/admin_log/meeting_presenter.rb +1 -1
- data/app/services/decidim/meetings/meeting_search.rb +2 -2
- data/app/types/decidim/meetings/meeting_type.rb +38 -0
- data/app/types/decidim/meetings/meetings_type.rb +32 -0
- data/app/views/decidim/meetings/admin/invite_join_meeting_mailer/invite.html.erb +1 -1
- data/app/views/decidim/meetings/admin/invites/new.html.erb +3 -3
- data/app/views/decidim/meetings/admin/meeting_closes/_form.html.erb +2 -3
- data/app/views/decidim/meetings/admin/meeting_closes/edit.html.erb +2 -2
- data/app/views/decidim/meetings/admin/meeting_copies/_form.html.erb +42 -0
- data/app/views/decidim/meetings/admin/meeting_copies/new.html.erb +7 -0
- data/app/views/decidim/meetings/admin/meetings/_form.html.erb +15 -11
- data/app/views/decidim/meetings/admin/meetings/_service.html.erb +48 -0
- data/app/views/decidim/meetings/admin/meetings/_services.html.erb +25 -0
- data/app/views/decidim/meetings/admin/meetings/edit.html.erb +2 -3
- data/app/views/decidim/meetings/admin/meetings/index.html.erb +13 -9
- data/app/views/decidim/meetings/admin/meetings/new.html.erb +2 -2
- data/app/views/decidim/meetings/admin/registrations/_form.html.erb +7 -2
- data/app/views/decidim/meetings/admin/registrations/edit.html.erb +2 -3
- data/app/views/decidim/meetings/meetings/_filters.html.erb +2 -2
- data/app/views/decidim/meetings/meetings/_filters_small_view.html.erb +1 -1
- data/app/views/decidim/meetings/meetings/_meetings.html.erb +1 -18
- data/app/views/decidim/meetings/meetings/_registration_confirm.html.erb +2 -2
- data/app/views/decidim/meetings/meetings/index.html.erb +3 -3
- data/app/views/decidim/meetings/meetings/show.html.erb +21 -4
- data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_meetings.html.erb +2 -2
- data/app/views/decidim/participatory_spaces/_highlighted_meetings.html.erb +4 -4
- data/app/views/decidim/participatory_spaces/_meeting.html.erb +1 -14
- data/app/views/devise/mailer/join_meeting.html.erb +1 -1
- data/app/views/devise/mailer/join_meeting.text.erb +1 -1
- data/config/locales/ca.yml +35 -12
- data/config/locales/en.yml +35 -12
- data/config/locales/es.yml +35 -12
- data/config/locales/eu.yml +35 -12
- data/config/locales/fi.yml +35 -12
- data/config/locales/fr.yml +35 -12
- data/config/locales/gl.yml +35 -12
- data/config/locales/it.yml +35 -12
- data/config/locales/nl.yml +73 -50
- data/config/locales/pl.yml +35 -12
- data/config/locales/pt-BR.yml +35 -12
- data/config/locales/pt.yml +35 -12
- data/config/locales/ru.yml +0 -3
- data/config/locales/sv.yml +35 -12
- data/config/locales/uk.yml +0 -3
- data/db/migrate/20180305133634_rename_features_to_components_at_meetings.rb +11 -0
- data/db/migrate/20180326082611_add_fields_for_registrations.rb +7 -0
- data/db/migrate/20180407110934_add_services_to_meetings.rb +7 -0
- data/lib/decidim/meetings.rb +2 -1
- data/lib/decidim/meetings/admin_engine.rb +1 -0
- data/lib/decidim/meetings/{feature.rb → component.rb} +27 -19
- data/lib/decidim/meetings/engine.rb +27 -4
- data/lib/decidim/meetings/test/factories.rb +10 -3
- data/lib/decidim/meetings/version.rb +1 -1
- data/lib/decidim/meetings/view_model.rb +12 -0
- metadata +65 -15
@@ -42,6 +42,7 @@ module Decidim
|
|
42
42
|
category: form.category,
|
43
43
|
title: form.title,
|
44
44
|
description: form.description,
|
45
|
+
services: form.services_to_persist.map { |service| { "title" => service.title, "description" => service.description } },
|
45
46
|
end_time: form.end_time,
|
46
47
|
start_time: form.start_time,
|
47
48
|
address: form.address,
|
@@ -28,7 +28,7 @@ module Decidim
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def registration
|
31
|
-
@registration ||= Decidim::Meetings::Registration.
|
31
|
+
@registration ||= Decidim::Meetings::Registration.find_by(meeting: @meeting, user: @user)
|
32
32
|
end
|
33
33
|
|
34
34
|
def destroy_registration
|
@@ -6,13 +6,13 @@ module Decidim
|
|
6
6
|
# This controller is the abstract class from which all other controllers of
|
7
7
|
# this engine inherit.
|
8
8
|
#
|
9
|
-
# Note that it inherits from `Decidim::
|
9
|
+
# Note that it inherits from `Decidim::Components::BaseController`, which
|
10
10
|
# override its layout and provide all kinds of useful methods.
|
11
|
-
class ApplicationController < Decidim::Admin::
|
11
|
+
class ApplicationController < Decidim::Admin::Components::BaseController
|
12
12
|
helper_method :meetings, :meeting
|
13
13
|
|
14
14
|
def meetings
|
15
|
-
@meetings ||= Meeting.where(
|
15
|
+
@meetings ||= Meeting.where(component: current_component).page(params[:page]).per(15)
|
16
16
|
end
|
17
17
|
|
18
18
|
def meeting
|
@@ -9,7 +9,7 @@ module Decidim
|
|
9
9
|
include Decidim::Admin::Concerns::HasAttachmentCollections
|
10
10
|
|
11
11
|
def after_destroy_path
|
12
|
-
meeting_attachment_collections_path(meeting, meeting.
|
12
|
+
meeting_attachment_collections_path(meeting, meeting.component, current_participatory_space)
|
13
13
|
end
|
14
14
|
|
15
15
|
def collection_for
|
@@ -21,7 +21,7 @@ module Decidim
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def authorization_object
|
24
|
-
meeting.
|
24
|
+
meeting.component
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
module Admin
|
6
|
+
# Controller that allows managing meetings.
|
7
|
+
#
|
8
|
+
class MeetingCopiesController < Admin::ApplicationController
|
9
|
+
helper_method :meeting, :blank_service
|
10
|
+
|
11
|
+
def new
|
12
|
+
@form = form(MeetingCopyForm).from_model(meeting)
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@form = form(MeetingCopyForm).from_params(params, current_component: current_component)
|
17
|
+
|
18
|
+
CopyMeeting.call(@form, meeting) do
|
19
|
+
on(:ok) do
|
20
|
+
flash[:notice] = I18n.t("meeting_copies.create.success", scope: "decidim.admin")
|
21
|
+
redirect_to meetings_path
|
22
|
+
end
|
23
|
+
|
24
|
+
on(:invalid) do
|
25
|
+
flash.now[:alert] = I18n.t("meeting_copies.create.error", scope: "decidim.admin")
|
26
|
+
render :new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def blank_service
|
34
|
+
@blank_service ||= Admin::MeetingServiceForm.new
|
35
|
+
end
|
36
|
+
|
37
|
+
def meeting
|
38
|
+
@meeting ||= Meeting.where(component: current_component).find(params[:meeting_id])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -5,12 +5,14 @@ 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
|
+
helper_method :blank_service
|
9
|
+
|
8
10
|
def new
|
9
11
|
@form = form(MeetingForm).instance
|
10
12
|
end
|
11
13
|
|
12
14
|
def create
|
13
|
-
@form = form(MeetingForm).from_params(params,
|
15
|
+
@form = form(MeetingForm).from_params(params, current_component: current_component)
|
14
16
|
|
15
17
|
CreateMeeting.call(@form) do
|
16
18
|
on(:ok) do
|
@@ -30,7 +32,7 @@ module Decidim
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def update
|
33
|
-
@form = form(MeetingForm).from_params(params,
|
35
|
+
@form = form(MeetingForm).from_params(params, current_component: current_component)
|
34
36
|
|
35
37
|
UpdateMeeting.call(@form, meeting) do
|
36
38
|
on(:ok) do
|
@@ -54,6 +56,12 @@ module Decidim
|
|
54
56
|
end
|
55
57
|
end
|
56
58
|
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def blank_service
|
63
|
+
@blank_service ||= Admin::MeetingServiceForm.new
|
64
|
+
end
|
57
65
|
end
|
58
66
|
end
|
59
67
|
end
|
@@ -26,16 +26,17 @@ module Decidim
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def export
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
ExportMeetingRegistrations.call(meeting, params[:format], current_user) do
|
30
|
+
on(:ok) do |export_data|
|
31
|
+
send_data export_data.read, type: "text/#{export_data.extension}", filename: export_data.filename("registrations")
|
32
|
+
end
|
33
|
+
end
|
33
34
|
end
|
34
35
|
|
35
36
|
private
|
36
37
|
|
37
38
|
def meeting
|
38
|
-
@meeting ||= Meeting.where(
|
39
|
+
@meeting ||= Meeting.where(component: current_component).find(params[:meeting_id])
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
@@ -5,9 +5,9 @@ module Decidim
|
|
5
5
|
# This controller is the abstract class from which all other controllers of
|
6
6
|
# this engine inherit.
|
7
7
|
#
|
8
|
-
# Note that it inherits from `Decidim::
|
8
|
+
# Note that it inherits from `Decidim::Components::BaseController`, which
|
9
9
|
# override its layout and provide all kinds of useful methods.
|
10
|
-
class ApplicationController < Decidim::
|
10
|
+
class ApplicationController < Decidim::Components::BaseController
|
11
11
|
helper Decidim::Meetings::ApplicationHelper
|
12
12
|
end
|
13
13
|
end
|
@@ -25,7 +25,7 @@ module Decidim
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def meeting
|
28
|
-
@meeting ||= Meeting.where(
|
28
|
+
@meeting ||= Meeting.where(component: current_component).find(params[:id])
|
29
29
|
end
|
30
30
|
|
31
31
|
def meetings
|
@@ -50,7 +50,7 @@ module Decidim
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def context_params
|
53
|
-
{
|
53
|
+
{ component: current_component, organization: current_organization }
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
module Admin
|
6
|
+
# A form object used to copy a meeting from the admin
|
7
|
+
# dashboard.
|
8
|
+
#
|
9
|
+
class MeetingCopyForm < Form
|
10
|
+
include TranslatableAttributes
|
11
|
+
|
12
|
+
translatable_attribute :title, String
|
13
|
+
translatable_attribute :description, String
|
14
|
+
translatable_attribute :location, String
|
15
|
+
translatable_attribute :location_hints, String
|
16
|
+
|
17
|
+
attribute :address, String
|
18
|
+
attribute :latitude, Float
|
19
|
+
attribute :longitude, Float
|
20
|
+
attribute :start_time, Decidim::Attributes::TimeWithZone
|
21
|
+
attribute :end_time, Decidim::Attributes::TimeWithZone
|
22
|
+
attribute :services, Array[MeetingServiceForm]
|
23
|
+
|
24
|
+
mimic :meeting
|
25
|
+
|
26
|
+
validates :current_component, presence: true
|
27
|
+
|
28
|
+
validates :title, translatable_presence: true
|
29
|
+
validates :description, translatable_presence: true
|
30
|
+
validates :location, translatable_presence: true
|
31
|
+
validates :address, presence: true
|
32
|
+
validates :address, geocoding: true, if: -> { Decidim.geocoder.present? }
|
33
|
+
validates :start_time, presence: true, date: { before: :end_time }
|
34
|
+
validates :end_time, presence: true, date: { after: :start_time }
|
35
|
+
|
36
|
+
def map_model(model)
|
37
|
+
self.services = model.services.map do |service|
|
38
|
+
MeetingServiceForm.new(service)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def services_to_persist
|
43
|
+
services.reject(&:deleted)
|
44
|
+
end
|
45
|
+
|
46
|
+
def number_of_services
|
47
|
+
services.size
|
48
|
+
end
|
49
|
+
|
50
|
+
alias component current_component
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -17,6 +17,7 @@ module Decidim
|
|
17
17
|
attribute :longitude, Float
|
18
18
|
attribute :start_time, Decidim::Attributes::TimeWithZone
|
19
19
|
attribute :end_time, Decidim::Attributes::TimeWithZone
|
20
|
+
attribute :services, Array[MeetingServiceForm]
|
20
21
|
attribute :decidim_scope_id, Integer
|
21
22
|
attribute :decidim_category_id, Integer
|
22
23
|
|
@@ -28,21 +29,31 @@ module Decidim
|
|
28
29
|
validates :start_time, presence: true, date: { before: :end_time }
|
29
30
|
validates :end_time, presence: true, date: { after: :start_time }
|
30
31
|
|
31
|
-
validates :
|
32
|
+
validates :current_component, presence: true
|
32
33
|
validates :category, presence: true, if: ->(form) { form.decidim_category_id.present? }
|
33
34
|
validates :scope, presence: true, if: ->(form) { form.decidim_scope_id.present? }
|
34
35
|
|
35
36
|
validate :scope_belongs_to_participatory_space_scope
|
36
37
|
|
37
|
-
delegate :categories, to: :
|
38
|
+
delegate :categories, to: :current_component
|
38
39
|
|
39
40
|
def map_model(model)
|
40
|
-
|
41
|
+
self.services = model.services.map do |service|
|
42
|
+
MeetingServiceForm.new(service)
|
43
|
+
end
|
41
44
|
|
42
|
-
self.decidim_category_id = model.categorization.decidim_category_id
|
45
|
+
self.decidim_category_id = model.categorization.decidim_category_id if model.categorization
|
43
46
|
end
|
44
47
|
|
45
|
-
|
48
|
+
def services_to_persist
|
49
|
+
services.reject(&:deleted)
|
50
|
+
end
|
51
|
+
|
52
|
+
def number_of_services
|
53
|
+
services.size
|
54
|
+
end
|
55
|
+
|
56
|
+
alias component current_component
|
46
57
|
|
47
58
|
# Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.
|
48
59
|
#
|
@@ -59,7 +70,7 @@ module Decidim
|
|
59
70
|
end
|
60
71
|
|
61
72
|
def category
|
62
|
-
return unless
|
73
|
+
return unless current_component
|
63
74
|
@category ||= categories.find_by(id: decidim_category_id)
|
64
75
|
end
|
65
76
|
|
@@ -11,12 +11,16 @@ module Decidim
|
|
11
11
|
|
12
12
|
attribute :registrations_enabled, Boolean
|
13
13
|
attribute :available_slots, Integer
|
14
|
+
attribute :reserved_slots, Integer
|
14
15
|
translatable_attribute :registration_terms, String
|
15
16
|
|
16
17
|
validates :registration_terms, translatable_presence: true, if: ->(form) { form.registrations_enabled? }
|
17
18
|
validates :available_slots, numericality: { greater_than_or_equal_to: 0 }, if: ->(form) { form.registrations_enabled? }
|
18
|
-
|
19
|
+
validates :reserved_slots, numericality: { greater_than_or_equal_to: 0 }, if: ->(form) { form.registrations_enabled? }
|
20
|
+
validates :reserved_slots, numericality: { less_than_or_equal_to: :available_slots }, if: ->(form) { form.registrations_enabled? }
|
19
21
|
|
22
|
+
validate :available_slots_greater_than_or_equal_to_registrations_count, if: ->(form) { form.registrations_enabled? && form.available_slots.positive? }
|
23
|
+
validate :reserved_slots_lower_than_or_equal_to_rest_available_slots_and_registrations_count, if: ->(form) { form.registrations_enabled? && form.reserved_slots.positive? }
|
20
24
|
# We need this method to ensure the form object will always have an ID,
|
21
25
|
# and thus its `to_param` method will always return a significant value.
|
22
26
|
# If we remove this method, get an error onn the `update` action and try
|
@@ -37,6 +41,11 @@ module Decidim
|
|
37
41
|
errors.add(:available_slots, :invalid) if available_slots < meeting.registrations.count
|
38
42
|
end
|
39
43
|
|
44
|
+
def reserved_slots_lower_than_or_equal_to_rest_available_slots_and_registrations_count
|
45
|
+
total_slots = available_slots - meeting.registrations.count
|
46
|
+
errors.add(:reserved_slots, I18n.t("decidim.meetings.admin.registrations.form.reserved_slots_less_than", count: total_slots)) if reserved_slots > total_slots
|
47
|
+
end
|
48
|
+
|
40
49
|
def meeting
|
41
50
|
@meeting ||= context[:meeting]
|
42
51
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
module Admin
|
6
|
+
# This class holds a Form to update meeting services
|
7
|
+
class MeetingServiceForm < Decidim::Form
|
8
|
+
include TranslatableAttributes
|
9
|
+
|
10
|
+
attribute :deleted, Boolean, default: false
|
11
|
+
|
12
|
+
translatable_attribute :title, String
|
13
|
+
translatable_attribute :description, String
|
14
|
+
|
15
|
+
validates :title, translatable_presence: true, unless: :deleted
|
16
|
+
|
17
|
+
def to_param
|
18
|
+
id || "meeting-service-id"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|