-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Replace parse with parse_with_processor to fix the issue
- Loading branch information
Showing
9 changed files
with
1,247 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
lib/extends/commands/decidim/meetings/admin/create_meeting_extends.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Meetings | ||
module Admin | ||
module CreateMeetingExtends | ||
def call | ||
return broadcast(:invalid) if @form.invalid? | ||
|
||
transaction do | ||
create_meeting! | ||
create_services! | ||
end | ||
|
||
create_follow_form_resource(form.current_user) | ||
broadcast(:ok, meeting) | ||
end | ||
|
||
private | ||
|
||
def create_meeting! | ||
parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite | ||
parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite | ||
|
||
params = { | ||
scope: form.scope, | ||
category: form.category, | ||
title: parsed_title, | ||
description: parsed_description, | ||
end_time: form.end_time, | ||
start_time: form.start_time, | ||
online_meeting_url: form.online_meeting_url, | ||
registration_type: form.registration_type, | ||
registration_url: form.registration_url, | ||
type_of_meeting: form.clean_type_of_meeting, | ||
address: form.address, | ||
latitude: form.latitude, | ||
longitude: form.longitude, | ||
location: form.location, | ||
location_hints: form.location_hints, | ||
private_meeting: form.private_meeting, | ||
transparent: form.transparent, | ||
author: form.current_organization, | ||
registration_terms: form.current_component.settings.default_registration_terms, | ||
registrations_enabled: form.registrations_enabled, | ||
component: form.current_component, | ||
questionnaire: Decidim::Forms::Questionnaire.new, | ||
iframe_embed_type: form.iframe_embed_type, | ||
comments_enabled: form.comments_enabled, | ||
comments_start_time: form.comments_start_time, | ||
comments_end_time: form.comments_end_time, | ||
iframe_access_level: form.iframe_access_level | ||
} | ||
|
||
@meeting = Decidim.traceability.create!( | ||
Decidim::Meetings::Meeting, | ||
form.current_user, | ||
params, | ||
visibility: "all" | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
Decidim::Meetings::Admin::CreateMeeting.class_eval do | ||
prepend Decidim::Meetings::Admin::CreateMeetingExtends | ||
end |
61 changes: 61 additions & 0 deletions
61
lib/extends/commands/decidim/meetings/admin/update_meeting_extends.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Meetings | ||
module Admin | ||
module UpdateMeetingExtends | ||
def call | ||
return broadcast(:invalid) if form.invalid? | ||
|
||
transaction do | ||
update_meeting! | ||
send_notification if should_notify_followers? | ||
schedule_upcoming_meeting_notification if meeting.published? && start_time_changed? | ||
update_services! | ||
end | ||
|
||
broadcast(:ok, meeting) | ||
end | ||
|
||
private | ||
|
||
def update_meeting! | ||
parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite | ||
parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite | ||
|
||
Decidim.traceability.update!( | ||
meeting, | ||
form.current_user, | ||
scope: form.scope, | ||
category: form.category, | ||
title: parsed_title, | ||
description: parsed_description, | ||
end_time: form.end_time, | ||
start_time: form.start_time, | ||
online_meeting_url: form.online_meeting_url, | ||
registration_type: form.registration_type, | ||
registration_url: form.registration_url, | ||
registrations_enabled: form.registrations_enabled, | ||
type_of_meeting: form.clean_type_of_meeting, | ||
address: form.address, | ||
latitude: form.latitude, | ||
longitude: form.longitude, | ||
location: form.location, | ||
location_hints: form.location_hints, | ||
private_meeting: form.private_meeting, | ||
transparent: form.transparent, | ||
iframe_embed_type: form.iframe_embed_type, | ||
comments_enabled: form.comments_enabled, | ||
comments_start_time: form.comments_start_time, | ||
comments_end_time: form.comments_end_time, | ||
iframe_access_level: form.iframe_access_level | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
Decidim::Meetings::Admin::UpdateMeeting.class_eval do | ||
prepend Decidim::Meetings::Admin::UpdateMeetingExtends | ||
end |
68 changes: 68 additions & 0 deletions
68
lib/extends/commands/decidim/meetings/create_meeting_extends.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Meetings | ||
module CreateMeetingExtends | ||
def call | ||
return broadcast(:invalid) if form.invalid? | ||
|
||
transaction do | ||
create_meeting! | ||
schedule_upcoming_meeting_notification | ||
send_notification | ||
end | ||
|
||
create_follow_form_resource(form.current_user) | ||
broadcast(:ok, meeting) | ||
end | ||
|
||
private | ||
|
||
def create_meeting! | ||
parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite | ||
parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite | ||
|
||
params = { | ||
scope: form.scope, | ||
category: form.category, | ||
title: { I18n.locale => parsed_title }, | ||
description: { I18n.locale => parsed_description }, | ||
end_time: form.end_time, | ||
start_time: form.start_time, | ||
address: form.address, | ||
latitude: form.latitude, | ||
longitude: form.longitude, | ||
location: { I18n.locale => form.location }, | ||
location_hints: { I18n.locale => form.location_hints }, | ||
author: form.current_user, | ||
decidim_user_group_id: form.user_group_id, | ||
online_meeting_url: form.online_meeting_url, | ||
registration_type: form.registration_type, | ||
registration_url: form.registration_url, | ||
available_slots: form.available_slots, | ||
registration_terms: { I18n.locale => form.registration_terms }, | ||
registrations_enabled: form.registrations_enabled, | ||
type_of_meeting: form.clean_type_of_meeting, | ||
component: form.current_component, | ||
published_at: Time.current, | ||
iframe_embed_type: form.iframe_embed_type, | ||
iframe_access_level: form.iframe_access_level | ||
} | ||
|
||
@meeting = Decidim.traceability.create!( | ||
Meeting, | ||
form.current_user, | ||
params, | ||
visibility: "public-only" | ||
) | ||
Decidim.traceability.perform_action!(:publish, meeting, form.current_user, visibility: "all") do | ||
meeting.publish! | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
Decidim::Meetings::CreateMeeting.class_eval do | ||
prepend Decidim::Meetings::CreateMeetingExtends | ||
end |
60 changes: 60 additions & 0 deletions
60
lib/extends/commands/decidim/meetings/update_meeting_extends.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Meetings | ||
module UpdateMeetingExtends | ||
def call | ||
return broadcast(:invalid) if form.invalid? | ||
|
||
transaction do | ||
update_meeting! | ||
send_notification if should_notify_followers? | ||
schedule_upcoming_meeting_notification if start_time_changed? | ||
end | ||
|
||
broadcast(:ok, meeting) | ||
end | ||
|
||
private | ||
|
||
def update_meeting! | ||
parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite | ||
parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite | ||
|
||
Decidim.traceability.update!( | ||
meeting, | ||
form.current_user, | ||
{ | ||
scope: form.scope, | ||
category: form.category, | ||
title: { I18n.locale => parsed_title }, | ||
description: { I18n.locale => parsed_description }, | ||
end_time: form.end_time, | ||
start_time: form.start_time, | ||
address: form.address, | ||
latitude: form.latitude, | ||
longitude: form.longitude, | ||
location: { I18n.locale => form.location }, | ||
location_hints: { I18n.locale => form.location_hints }, | ||
author: form.current_user, | ||
decidim_user_group_id: form.user_group_id, | ||
registration_type: form.registration_type, | ||
registration_url: form.registration_url, | ||
available_slots: form.available_slots, | ||
registration_terms: { I18n.locale => form.registration_terms }, | ||
registrations_enabled: form.registrations_enabled, | ||
type_of_meeting: form.clean_type_of_meeting, | ||
online_meeting_url: form.online_meeting_url, | ||
iframe_embed_type: form.iframe_embed_type, | ||
iframe_access_level: form.iframe_access_level | ||
}, | ||
visibility: "public-only" | ||
) | ||
end | ||
end | ||
end | ||
end | ||
|
||
Decidim::Meetings::UpdateMeeting.class_eval do | ||
prepend Decidim::Meetings::UpdateMeetingExtends | ||
end |
Oops, something went wrong.