decidim-meetings 0.22.0 → 0.23.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/decidim_meetings_manifest.js +1 -0
- data/app/assets/javascripts/decidim/meetings/admin/meetings_form.js.es6 +3 -0
- data/app/assets/javascripts/decidim/meetings/meetings_form.js.es6 +9 -0
- data/app/cells/decidim/meetings/content_blocks/upcoming_events_cell.rb +2 -1
- data/app/cells/decidim/meetings/highlighted_meetings_for_component_cell.rb +1 -1
- data/app/cells/decidim/meetings/meeting_cell.rb +1 -1
- data/app/cells/decidim/meetings/meeting_list_item_cell.rb +2 -2
- data/app/cells/decidim/meetings/meeting_m_cell.rb +9 -1
- data/app/cells/decidim/meetings/meetings_map/show.erb +0 -2
- data/app/cells/decidim/meetings/meetings_map_cell.rb +3 -1
- data/app/commands/decidim/meetings/admin/close_meeting.rb +1 -2
- data/app/commands/decidim/meetings/admin/copy_meeting.rb +38 -28
- data/app/commands/decidim/meetings/admin/create_meeting.rb +36 -24
- data/app/commands/decidim/meetings/admin/invite_user_to_join_meeting.rb +2 -1
- data/app/commands/decidim/meetings/admin/update_meeting.rb +9 -3
- data/app/commands/decidim/meetings/create_meeting.rb +78 -0
- data/app/commands/decidim/meetings/update_meeting.rb +94 -0
- data/app/controllers/decidim/meetings/admin/application_controller.rb +1 -1
- data/app/controllers/decidim/meetings/admin/meetings_controller.rb +11 -7
- data/app/controllers/decidim/meetings/admin/registration_form_controller.rb +4 -0
- data/app/controllers/decidim/meetings/meetings_controller.rb +76 -13
- data/app/controllers/decidim/meetings/registrations_controller.rb +1 -1
- data/app/controllers/decidim/meetings/versions_controller.rb +14 -0
- data/app/controllers/decidim/meetings/{meeting_widgets_controller.rb → widgets_controller.rb} +2 -2
- data/app/forms/decidim/meetings/admin/meeting_copy_form.rb +2 -8
- data/app/forms/decidim/meetings/admin/meeting_form.rb +24 -23
- data/app/forms/decidim/meetings/meeting_form.rb +78 -0
- data/app/helpers/decidim/meetings/admin/application_helper.rb +1 -6
- data/app/helpers/decidim/meetings/application_helper.rb +25 -0
- data/app/helpers/decidim/meetings/meetings_helper.rb +12 -0
- data/app/models/decidim/meetings/agenda.rb +3 -0
- data/app/models/decidim/meetings/agenda_item.rb +3 -0
- data/app/models/decidim/meetings/meeting.rb +69 -23
- data/app/models/decidim/meetings/minutes.rb +3 -0
- data/app/models/decidim/meetings/service.rb +13 -0
- data/app/permissions/decidim/meetings/admin/permissions.rb +2 -0
- data/app/permissions/decidim/meetings/permissions.rb +20 -0
- data/app/presenters/decidim/meetings/admin_log/invite_presenter.rb +5 -1
- data/app/presenters/decidim/meetings/admin_log/meeting_presenter.rb +3 -4
- data/app/presenters/decidim/meetings/meeting_presenter.rb +7 -3
- data/app/presenters/decidim/meetings/official_author_presenter.rb +14 -0
- data/app/queries/decidim/meetings/filtered_meetings.rb +1 -1
- data/app/services/decidim/meetings/diff_renderer.rb +21 -0
- data/app/services/decidim/meetings/meeting_search.rb +3 -25
- data/app/types/decidim/meetings/meeting_type.rb +1 -1
- data/app/views/decidim/meetings/admin/meeting_copies/_form.html.erb +2 -9
- data/app/views/decidim/meetings/admin/meetings/_form.html.erb +4 -11
- data/app/views/decidim/meetings/admin/meetings/edit.html.erb +1 -1
- data/app/views/decidim/meetings/admin/meetings/index.html.erb +4 -2
- data/app/views/decidim/meetings/directory/meetings/index.js.erb +11 -4
- data/app/views/decidim/meetings/meetings/_count.html.erb +1 -0
- data/app/views/decidim/meetings/meetings/_filters.html.erb +8 -10
- data/app/views/decidim/meetings/meetings/_form.html.erb +51 -0
- data/app/views/decidim/meetings/meetings/edit.html.erb +25 -0
- data/app/views/decidim/meetings/meetings/index.html.erb +15 -0
- data/app/views/decidim/meetings/meetings/index.js.erb +13 -4
- data/app/views/decidim/meetings/meetings/new.html.erb +25 -0
- data/app/views/decidim/meetings/meetings/show.html.erb +24 -9
- data/app/views/decidim/meetings/versions/index.html.erb +8 -0
- data/app/views/decidim/meetings/versions/show.html.erb +10 -0
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +0 -8
- data/config/locales/bg-BG.yml +0 -8
- data/config/locales/bg.yml +21 -0
- data/config/locales/ca.yml +49 -7
- data/config/locales/cs.yml +57 -13
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +113 -71
- data/config/locales/el.yml +2 -7
- data/config/locales/en.yml +49 -7
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +49 -7
- data/config/locales/es-PY.yml +50 -8
- data/config/locales/es.yml +50 -8
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +0 -8
- data/config/locales/fi-plain.yml +49 -7
- data/config/locales/fi.yml +168 -126
- data/config/locales/fr-CA.yml +57 -7
- data/config/locales/fr.yml +57 -7
- data/config/locales/gl.yml +3 -7
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +2 -7
- data/config/locales/id-ID.yml +0 -8
- data/config/locales/is-IS.yml +0 -7
- data/config/locales/is.yml +228 -0
- data/config/locales/it.yml +47 -7
- data/config/locales/ja-JP.yml +48 -9
- data/config/locales/ja.yml +496 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/{lv-LV.yml → lv.yml} +2 -2
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +49 -7
- data/config/locales/no.yml +34 -8
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +193 -149
- data/config/locales/pt-BR.yml +1 -9
- data/config/locales/pt.yml +47 -7
- data/config/locales/ro-RO.yml +48 -7
- data/config/locales/ru.yml +0 -8
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk.yml +2 -7
- data/config/locales/sl.yml +25 -2
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sv.yml +56 -8
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +154 -98
- data/config/locales/uk.yml +0 -7
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +496 -0
- data/config/locales/zh-TW.yml +1 -0
- data/db/migrate/20200526110940_add_author_to_meetings.rb +30 -0
- data/db/migrate/20200702123209_create_meeting_services_table.rb +13 -0
- data/db/migrate/20200702123210_move_meeting_services_to_own_model.rb +31 -0
- data/db/migrate/20200827153856_add_commentable_counter_cache_to_meetings.rb +9 -0
- data/db/migrate/20201016065302_fix_meetings_registration_terms.rb +29 -0
- data/db/migrate/20201111133246_add_salt_to_decidim_meetings.rb +8 -0
- data/lib/decidim/api/services_interface.rb +1 -7
- data/lib/decidim/meetings/admin_engine.rb +2 -0
- data/lib/decidim/meetings/component.rb +63 -11
- data/lib/decidim/meetings/engine.rb +3 -2
- data/lib/decidim/meetings/meeting_serializer.rb +1 -1
- data/lib/decidim/meetings/test/factories.rb +45 -8
- data/lib/decidim/meetings/version.rb +1 -1
- metadata +62 -22
- data/app/presenters/decidim/meetings/admin_log/value_types/organizer_presenter.rb +0 -70
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
# This command is executed when the user changes a Meeting from the admin
|
6
|
+
# panel.
|
7
|
+
class UpdateMeeting < Rectify::Command
|
8
|
+
# Initializes a UpdateMeeting Command.
|
9
|
+
#
|
10
|
+
# form - The form from which to get the data.
|
11
|
+
# current_user - The current user.
|
12
|
+
# meeting - The current instance of the page to be updated.
|
13
|
+
def initialize(form, current_user, meeting)
|
14
|
+
@form = form
|
15
|
+
@current_user = current_user
|
16
|
+
@meeting = meeting
|
17
|
+
end
|
18
|
+
|
19
|
+
# Updates the meeting if valid.
|
20
|
+
#
|
21
|
+
# Broadcasts :ok if successful, :invalid otherwise.
|
22
|
+
def call
|
23
|
+
return broadcast(:invalid) if form.invalid?
|
24
|
+
|
25
|
+
transaction do
|
26
|
+
update_meeting!
|
27
|
+
send_notification if should_notify_followers?
|
28
|
+
schedule_upcoming_meeting_notification if start_time_changed?
|
29
|
+
end
|
30
|
+
|
31
|
+
broadcast(:ok, meeting)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :form, :current_user, :meeting
|
37
|
+
|
38
|
+
def update_meeting!
|
39
|
+
parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
|
40
|
+
parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite
|
41
|
+
|
42
|
+
Decidim.traceability.update!(
|
43
|
+
meeting,
|
44
|
+
form.current_user,
|
45
|
+
{
|
46
|
+
scope: form.scope,
|
47
|
+
category: form.category,
|
48
|
+
title: { I18n.locale => parsed_title },
|
49
|
+
description: { I18n.locale => parsed_description },
|
50
|
+
end_time: form.end_time,
|
51
|
+
start_time: form.start_time,
|
52
|
+
address: form.address,
|
53
|
+
latitude: form.latitude,
|
54
|
+
longitude: form.longitude,
|
55
|
+
location: { I18n.locale => form.location },
|
56
|
+
location_hints: { I18n.locale => form.location_hints },
|
57
|
+
author: form.current_user,
|
58
|
+
decidim_user_group_id: form.user_group_id
|
59
|
+
},
|
60
|
+
visibility: "public-only"
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
def send_notification
|
65
|
+
Decidim::EventsManager.publish(
|
66
|
+
event: "decidim.events.meetings.meeting_updated",
|
67
|
+
event_class: Decidim::Meetings::UpdateMeetingEvent,
|
68
|
+
resource: meeting,
|
69
|
+
followers: meeting.followers
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
def should_notify_followers?
|
74
|
+
important_attributes.any? { |attr| meeting.previous_changes[attr].present? }
|
75
|
+
end
|
76
|
+
|
77
|
+
def important_attributes
|
78
|
+
%w(start_time end_time address)
|
79
|
+
end
|
80
|
+
|
81
|
+
def start_time_changed?
|
82
|
+
meeting.previous_changes["start_time"].present?
|
83
|
+
end
|
84
|
+
|
85
|
+
def schedule_upcoming_meeting_notification
|
86
|
+
checksum = Decidim::Meetings::UpcomingMeetingNotificationJob.generate_checksum(meeting)
|
87
|
+
|
88
|
+
Decidim::Meetings::UpcomingMeetingNotificationJob
|
89
|
+
.set(wait_until: meeting.start_time - 2.days)
|
90
|
+
.perform_later(meeting.id, checksum)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -10,15 +10,15 @@ module Decidim
|
|
10
10
|
def new
|
11
11
|
enforce_permission_to :create, :meeting
|
12
12
|
|
13
|
-
@form =
|
13
|
+
@form = meeting_form.instance
|
14
14
|
end
|
15
15
|
|
16
16
|
def create
|
17
17
|
enforce_permission_to :create, :meeting
|
18
18
|
|
19
|
-
@form =
|
19
|
+
@form = meeting_form.from_params(params, current_component: current_component)
|
20
20
|
|
21
|
-
CreateMeeting.call(@form) do
|
21
|
+
Decidim::Meetings::Admin::CreateMeeting.call(@form) do
|
22
22
|
on(:ok) do
|
23
23
|
flash[:notice] = I18n.t("meetings.create.success", scope: "decidim.meetings.admin")
|
24
24
|
redirect_to meetings_path
|
@@ -34,15 +34,15 @@ module Decidim
|
|
34
34
|
def edit
|
35
35
|
enforce_permission_to :update, :meeting, meeting: meeting
|
36
36
|
|
37
|
-
@form =
|
37
|
+
@form = meeting_form.from_model(meeting)
|
38
38
|
end
|
39
39
|
|
40
40
|
def update
|
41
41
|
enforce_permission_to :update, :meeting, meeting: meeting
|
42
42
|
|
43
|
-
@form =
|
43
|
+
@form = meeting_form.from_params(params, current_component: current_component)
|
44
44
|
|
45
|
-
UpdateMeeting.call(@form, meeting) do
|
45
|
+
Decidim::Meetings::Admin::UpdateMeeting.call(@form, meeting) do
|
46
46
|
on(:ok) do
|
47
47
|
flash[:notice] = I18n.t("meetings.update.success", scope: "decidim.meetings.admin")
|
48
48
|
redirect_to meetings_path
|
@@ -58,7 +58,7 @@ module Decidim
|
|
58
58
|
def destroy
|
59
59
|
enforce_permission_to :destroy, :meeting, meeting: meeting
|
60
60
|
|
61
|
-
DestroyMeeting.call(meeting, current_user) do
|
61
|
+
Decidim::Meetings::Admin::DestroyMeeting.call(meeting, current_user) do
|
62
62
|
on(:ok) do
|
63
63
|
flash[:notice] = I18n.t("meetings.destroy.success", scope: "decidim.meetings.admin")
|
64
64
|
|
@@ -79,6 +79,10 @@ module Decidim
|
|
79
79
|
|
80
80
|
private
|
81
81
|
|
82
|
+
def meeting_form
|
83
|
+
form(Decidim::Meetings::Admin::MeetingForm)
|
84
|
+
end
|
85
|
+
|
82
86
|
def blank_service
|
83
87
|
@blank_service ||= Admin::MeetingServiceForm.new
|
84
88
|
end
|
@@ -5,39 +5,94 @@ module Decidim
|
|
5
5
|
# Exposes the meeting resource so users can view them
|
6
6
|
class MeetingsController < Decidim::Meetings::ApplicationController
|
7
7
|
include FilterResource
|
8
|
+
include Flaggable
|
9
|
+
include FormFactory
|
8
10
|
include Paginable
|
9
11
|
helper Decidim::WidgetUrlsHelper
|
12
|
+
helper Decidim::ResourceVersionsHelper
|
10
13
|
|
11
14
|
helper_method :meetings, :meeting, :registration, :search
|
12
15
|
|
16
|
+
def new
|
17
|
+
enforce_permission_to :create, :meeting
|
18
|
+
|
19
|
+
@form = meeting_form.instance
|
20
|
+
end
|
21
|
+
|
22
|
+
def create
|
23
|
+
enforce_permission_to :create, :meeting
|
24
|
+
|
25
|
+
@form = meeting_form.from_params(params, current_component: current_component)
|
26
|
+
|
27
|
+
CreateMeeting.call(@form) do
|
28
|
+
on(:ok) do |meeting|
|
29
|
+
flash[:notice] = I18n.t("meetings.create.success", scope: "decidim.meetings")
|
30
|
+
redirect_to meeting_path(meeting)
|
31
|
+
end
|
32
|
+
|
33
|
+
on(:invalid) do
|
34
|
+
flash.now[:alert] = I18n.t("meetings.create.invalid", scope: "decidim.meetings")
|
35
|
+
render action: "new"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
13
40
|
def index
|
14
|
-
return unless search.results.blank? && params.dig("filter", "date") !=
|
41
|
+
return unless search.results.blank? && params.dig("filter", "date") != %w(past)
|
15
42
|
|
16
|
-
@past_meetings = search_klass.new(search_params.merge(date:
|
43
|
+
@past_meetings = search_klass.new(search_params.merge(date: %w(past)))
|
17
44
|
|
18
45
|
if @past_meetings.results.present?
|
19
46
|
params[:filter] ||= {}
|
20
|
-
params[:filter][:date] =
|
47
|
+
params[:filter][:date] = %w(past)
|
21
48
|
@forced_past_meetings = true
|
22
49
|
@search = @past_meetings
|
23
50
|
end
|
24
51
|
end
|
25
52
|
|
26
53
|
def show
|
54
|
+
raise ActionController::RoutingError, "Not Found" unless meeting
|
55
|
+
|
56
|
+
@report_form = form(Decidim::ReportForm).from_params(reason: "spam")
|
57
|
+
|
27
58
|
return if meeting.current_user_can_visit_meeting?(current_user)
|
28
59
|
|
29
60
|
flash[:alert] = I18n.t("meeting.not_allowed", scope: "decidim.meetings")
|
30
|
-
redirect_to
|
61
|
+
redirect_to(ResourceLocatorPresenter.new(meeting).index)
|
62
|
+
end
|
63
|
+
|
64
|
+
def edit
|
65
|
+
enforce_permission_to :update, :meeting, meeting: meeting
|
66
|
+
|
67
|
+
@form = meeting_form.from_model(meeting)
|
68
|
+
end
|
69
|
+
|
70
|
+
def update
|
71
|
+
enforce_permission_to :update, :meeting, meeting: meeting
|
72
|
+
|
73
|
+
@form = meeting_form.from_params(params)
|
74
|
+
|
75
|
+
UpdateMeeting.call(@form, current_user, meeting) do
|
76
|
+
on(:ok) do |meeting|
|
77
|
+
flash[:notice] = I18n.t("meetings.update.success", scope: "decidim.meetings")
|
78
|
+
redirect_to Decidim::ResourceLocatorPresenter.new(meeting).path
|
79
|
+
end
|
80
|
+
|
81
|
+
on(:invalid) do
|
82
|
+
flash.now[:alert] = I18n.t("meetings.update.invalid", scope: "decidim.meetings")
|
83
|
+
render :edit
|
84
|
+
end
|
85
|
+
end
|
31
86
|
end
|
32
87
|
|
33
88
|
private
|
34
89
|
|
35
90
|
def meeting
|
36
|
-
@meeting ||= Meeting.where(component: current_component).find(params[:id])
|
91
|
+
@meeting ||= Meeting.not_hidden.where(component: current_component).find(params[:id])
|
37
92
|
end
|
38
93
|
|
39
94
|
def meetings
|
40
|
-
@meetings ||= paginate(search.results)
|
95
|
+
@meetings ||= paginate(search.results.not_hidden)
|
41
96
|
end
|
42
97
|
|
43
98
|
def registration
|
@@ -48,24 +103,32 @@ module Decidim
|
|
48
103
|
MeetingSearch
|
49
104
|
end
|
50
105
|
|
106
|
+
def meeting_form
|
107
|
+
form(Decidim::Meetings::MeetingForm)
|
108
|
+
end
|
109
|
+
|
51
110
|
def default_filter_params
|
52
111
|
{
|
53
|
-
date: "upcoming",
|
54
112
|
search_text: "",
|
55
|
-
|
56
|
-
|
113
|
+
date: %w(upcoming),
|
114
|
+
scope_id: default_filter_scope_params,
|
115
|
+
category_id: default_filter_category_params,
|
116
|
+
origin: default_filter_origin_params
|
57
117
|
}
|
58
118
|
end
|
59
119
|
|
120
|
+
def default_filter_origin_params
|
121
|
+
filter_origin_params = %w(citizens)
|
122
|
+
filter_origin_params << "official"
|
123
|
+
filter_origin_params << "user_group" if current_organization.user_groups_enabled?
|
124
|
+
filter_origin_params
|
125
|
+
end
|
126
|
+
|
60
127
|
def default_search_params
|
61
128
|
{
|
62
129
|
scope: Meeting.visible_meeting_for(current_user)
|
63
130
|
}
|
64
131
|
end
|
65
|
-
|
66
|
-
def context_params
|
67
|
-
{ component: current_component, organization: current_organization }
|
68
|
-
end
|
69
132
|
end
|
70
133
|
end
|
71
134
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
# Exposes the meeting resource so users can view them
|
6
|
+
class VersionsController < Decidim::Meetings::ApplicationController
|
7
|
+
include Decidim::ResourceVersionsConcern
|
8
|
+
|
9
|
+
def versioned_resource
|
10
|
+
@versioned_resource ||= Meeting.not_hidden.where(component: current_component).find(params[:meeting_id])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/app/controllers/decidim/meetings/{meeting_widgets_controller.rb → widgets_controller.rb}
RENAMED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Meetings
|
5
|
-
class
|
5
|
+
class WidgetsController < Decidim::WidgetsController
|
6
6
|
helper MeetingsHelper
|
7
7
|
helper Decidim::SanitizeHelper
|
8
8
|
|
@@ -13,7 +13,7 @@ module Decidim
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def iframe_url
|
16
|
-
@iframe_url ||=
|
16
|
+
@iframe_url ||= meeting_widget_url(model)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -21,7 +21,6 @@ module Decidim
|
|
21
21
|
attribute :end_time, Decidim::Attributes::TimeWithZone
|
22
22
|
attribute :private_meeting, Boolean
|
23
23
|
attribute :transparent, Boolean
|
24
|
-
attribute :organizer_id, Integer
|
25
24
|
attribute :services, Array[MeetingServiceForm]
|
26
25
|
|
27
26
|
mimic :meeting
|
@@ -32,14 +31,13 @@ module Decidim
|
|
32
31
|
validates :description, translatable_presence: true
|
33
32
|
validates :location, translatable_presence: true
|
34
33
|
validates :address, presence: true
|
35
|
-
validates :address, geocoding: true, if: -> { Decidim.
|
34
|
+
validates :address, geocoding: true, if: -> { Decidim::Map.available?(:geocoding) }
|
36
35
|
validates :start_time, presence: true, date: { before: :end_time }
|
37
36
|
validates :end_time, presence: true, date: { after: :start_time }
|
38
|
-
validates :organizer, presence: true, if: ->(form) { form.organizer_id.present? }
|
39
37
|
|
40
38
|
def map_model(model)
|
41
39
|
self.services = model.services.map do |service|
|
42
|
-
MeetingServiceForm.new(service)
|
40
|
+
MeetingServiceForm.new(service.attributes)
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
@@ -53,10 +51,6 @@ module Decidim
|
|
53
51
|
|
54
52
|
alias component current_component
|
55
53
|
|
56
|
-
def organizer
|
57
|
-
@organizer ||= current_organization.users.find_by(id: organizer_id)
|
58
|
-
end
|
59
|
-
|
60
54
|
def questionnaire
|
61
55
|
Decidim::Forms::Questionnaire.new
|
62
56
|
end
|
@@ -3,15 +3,10 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Meetings
|
5
5
|
module Admin
|
6
|
-
# This class holds a Form to create/update meetings from Decidim's admin panel.
|
6
|
+
# This class holds a Form to create/update translatable meetings from Decidim's admin panel.
|
7
7
|
class MeetingForm < Decidim::Form
|
8
8
|
include TranslatableAttributes
|
9
9
|
|
10
|
-
translatable_attribute :title, String
|
11
|
-
translatable_attribute :description, String
|
12
|
-
translatable_attribute :location, String
|
13
|
-
translatable_attribute :location_hints, String
|
14
|
-
|
15
10
|
attribute :address, String
|
16
11
|
attribute :latitude, Float
|
17
12
|
attribute :longitude, Float
|
@@ -22,34 +17,38 @@ module Decidim
|
|
22
17
|
attribute :decidim_category_id, Integer
|
23
18
|
attribute :private_meeting, Boolean
|
24
19
|
attribute :transparent, Boolean
|
25
|
-
|
20
|
+
|
21
|
+
translatable_attribute :title, String
|
22
|
+
translatable_attribute :description, String
|
23
|
+
translatable_attribute :location, String
|
24
|
+
translatable_attribute :location_hints, String
|
26
25
|
|
27
26
|
validates :title, translatable_presence: true
|
28
27
|
validates :description, translatable_presence: true
|
29
28
|
validates :location, translatable_presence: true
|
29
|
+
|
30
30
|
validates :address, presence: true
|
31
|
-
validates :address, geocoding: true, if: -> {
|
31
|
+
validates :address, geocoding: true, if: ->(form) { form.has_address? && !form.geocoded? }
|
32
32
|
validates :start_time, presence: true, date: { before: :end_time }
|
33
33
|
validates :end_time, presence: true, date: { after: :start_time }
|
34
34
|
|
35
35
|
validates :current_component, presence: true
|
36
36
|
validates :category, presence: true, if: ->(form) { form.decidim_category_id.present? }
|
37
37
|
validates :scope, presence: true, if: ->(form) { form.decidim_scope_id.present? }
|
38
|
-
validates :
|
39
|
-
|
40
|
-
validate :scope_belongs_to_participatory_space_scope
|
38
|
+
validates :decidim_scope_id, scope_belongs_to_component: true, if: ->(form) { form.decidim_scope_id.present? }
|
41
39
|
|
42
40
|
delegate :categories, to: :current_component
|
43
41
|
|
44
42
|
def map_model(model)
|
45
43
|
self.services = model.services.map do |service|
|
46
|
-
MeetingServiceForm.
|
44
|
+
MeetingServiceForm.from_model(service)
|
47
45
|
end
|
48
46
|
|
49
47
|
self.decidim_category_id = model.categorization.decidim_category_id if model.categorization
|
50
48
|
presenter = MeetingPresenter.new(model)
|
51
|
-
|
52
|
-
self.
|
49
|
+
|
50
|
+
self.title = presenter.title(all_locales: title.is_a?(Hash))
|
51
|
+
self.description = presenter.description(all_locales: description.is_a?(Hash))
|
53
52
|
end
|
54
53
|
|
55
54
|
def services_to_persist
|
@@ -60,17 +59,13 @@ module Decidim
|
|
60
59
|
services.size
|
61
60
|
end
|
62
61
|
|
63
|
-
def organizer
|
64
|
-
@organizer ||= current_organization.users.find_by(id: organizer_id)
|
65
|
-
end
|
66
|
-
|
67
62
|
alias component current_component
|
68
63
|
|
69
|
-
# Finds the Scope from the given decidim_scope_id, uses
|
64
|
+
# Finds the Scope from the given decidim_scope_id, uses component scope if missing.
|
70
65
|
#
|
71
66
|
# Returns a Decidim::Scope
|
72
67
|
def scope
|
73
|
-
@scope ||= @decidim_scope_id ?
|
68
|
+
@scope ||= @decidim_scope_id ? current_component.scopes.find_by(id: @decidim_scope_id) : current_component.scope
|
74
69
|
end
|
75
70
|
|
76
71
|
# Scope identifier
|
@@ -86,10 +81,16 @@ module Decidim
|
|
86
81
|
@category ||= categories.find_by(id: decidim_category_id)
|
87
82
|
end
|
88
83
|
|
89
|
-
|
84
|
+
def geocoding_enabled?
|
85
|
+
Decidim::Map.available?(:geocoding)
|
86
|
+
end
|
87
|
+
|
88
|
+
def has_address?
|
89
|
+
geocoding_enabled? && address.present?
|
90
|
+
end
|
90
91
|
|
91
|
-
def
|
92
|
-
|
92
|
+
def geocoded?
|
93
|
+
latitude.present? && longitude.present?
|
93
94
|
end
|
94
95
|
end
|
95
96
|
end
|