Skip to content

Commit

Permalink
fix: Replace parse with parse_with_processor to fix the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AyakorK committed Apr 12, 2024
1 parent 023c00d commit 870ade4
Show file tree
Hide file tree
Showing 9 changed files with 1,247 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class Application < Rails::Application
config.after_initialize do
require "extends/controllers/decidim/devise/sessions_controller_extends"
require "extends/lib/decidim/dependency_resolver_extends"
require "extends/commands/decidim/meetings/admin/update_meeting_extends"
require "extends/commands/decidim/meetings/admin/create_meeting_extends"
require "extends/commands/decidim/meetings/update_meeting_extends"
require "extends/commands/decidim/meetings/create_meeting_extends"

Decidim::GraphiQL::Rails.config.tap do |config|
config.initial_query = "{\n deployment {\n version\n branch\n remote\n upToDate\n currentCommit\n latestCommit\n locallyModified\n }\n}".html_safe
Expand Down
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
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 lib/extends/commands/decidim/meetings/create_meeting_extends.rb
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 lib/extends/commands/decidim/meetings/update_meeting_extends.rb
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
Loading

0 comments on commit 870ade4

Please sign in to comment.