Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 'Fix meeting form for admin to update registrations_enabled field' to v0.26 #10533

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -53,6 +53,7 @@ def create_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,
customize_registration_email: form.customize_registration_email,
Expand Down
Expand Up @@ -52,6 +52,7 @@ def update_meeting!
registration_type: form.registration_type,
registration_url: form.registration_url,
available_slots: form.available_slots,
registrations_enabled: form.registrations_enabled,
type_of_meeting: form.clean_type_of_meeting,
address: form.address,
latitude: form.latitude,
Expand Down
Expand Up @@ -13,6 +13,7 @@ class MeetingForm < ::Decidim::Meetings::BaseMeetingForm
attribute :private_meeting, Boolean
attribute :transparent, Boolean
attribute :registration_type, String
attribute :registrations_enabled, Boolean, default: false
attribute :registration_url, String
attribute :available_slots, Integer, default: 0
attribute :customize_registration_email, Boolean
Expand Down Expand Up @@ -135,6 +136,10 @@ def registration_type_select
end
end

def registrations_enabled
on_this_platform?
end

def embeddable_meeting_url
if online_meeting_url.present? && %w(embed_in_meeting_page open_in_live_event_page).include?(iframe_embed_type)
embedder_service = Decidim::Meetings::MeetingIframeEmbedder.new(online_meeting_url)
Expand Down
7 changes: 7 additions & 0 deletions decidim-meetings/spec/commands/admin/create_meeting_spec.rb
Expand Up @@ -25,6 +25,7 @@ module Decidim::Meetings
let(:registration_url) { "http://decidim.org" }
let(:registration_type) { "on_this_platform" }
let(:available_slots) { 0 }
let(:registrations_enabled) { true }
let(:iframe_embed_type) { "embed_in_meeting_page" }
let(:iframe_access_level) { "all" }
let(:services) do
Expand Down Expand Up @@ -68,6 +69,7 @@ module Decidim::Meetings
registration_type: registration_type,
available_slots: available_slots,
registration_url: registration_url,
registrations_enabled: registrations_enabled,
clean_type_of_meeting: type_of_meeting,
online_meeting_url: online_meeting_url,
customize_registration_email: customize_registration_email,
Expand Down Expand Up @@ -110,6 +112,11 @@ module Decidim::Meetings
expect(meeting.author).to eq organization
end

it "sets the registration enabled flag" do
subject.call
expect(meeting.registrations_enabled).to eq registrations_enabled
end

it "sets the component" do
subject.call
expect(meeting.component).to eq current_component
Expand Down
8 changes: 8 additions & 0 deletions decidim-meetings/spec/commands/admin/update_meeting_spec.rb
Expand Up @@ -31,6 +31,7 @@ module Decidim::Meetings
let(:available_slots) { 0 }
let(:customize_registration_email) { true }
let(:registration_email_custom_content) { { "en" => "The registration email custom content." } }
let(:registrations_enabled) { true }
let(:iframe_embed_type) { "none" }
let(:iframe_access_level) { nil }

Expand All @@ -56,6 +57,7 @@ module Decidim::Meetings
registration_type: registration_type,
available_slots: available_slots,
registration_url: registration_url,
registrations_enabled: registrations_enabled,
clean_type_of_meeting: type_of_meeting,
online_meeting_url: online_meeting_url,
customize_registration_email: customize_registration_email,
Expand Down Expand Up @@ -103,6 +105,11 @@ module Decidim::Meetings
expect(meeting.author).to eq organization
end

it "sets the registration enabled flag" do
subject.call
expect(meeting.registrations_enabled).to eq registrations_enabled
end

it "sets the services" do
subject.call
meeting.services.each_with_index do |service, index|
Expand Down Expand Up @@ -163,6 +170,7 @@ module Decidim::Meetings
registration_type: registration_type,
available_slots: available_slots,
registration_url: registration_url,
registrations_enabled: registrations_enabled,
clean_type_of_meeting: type_of_meeting,
online_meeting_url: online_meeting_url,
customize_registration_email: customize_registration_email,
Expand Down
4 changes: 3 additions & 1 deletion decidim-meetings/spec/forms/admin/meeting_form_spec.rb
Expand Up @@ -53,6 +53,7 @@ module Decidim::Meetings
let(:online_meeting_url) { "http://decidim.org" }
let(:registration_url) { "http://decidim.org" }
let(:registration_type) { "on_this_platform" }
let(:registrations_enabled) { true }
let(:available_slots) { 0 }
let(:iframe_embed_type) { "none" }
let(:attributes) do
Expand All @@ -75,7 +76,8 @@ module Decidim::Meetings
registration_url: registration_url,
type_of_meeting: type_of_meeting,
online_meeting_url: online_meeting_url,
iframe_embed_type: iframe_embed_type
iframe_embed_type: iframe_embed_type,
registrations_enabled: registrations_enabled
}
end

Expand Down
30 changes: 30 additions & 0 deletions decidim-meetings/spec/system/admin/admin_manages_meetings_spec.rb
Expand Up @@ -162,6 +162,36 @@
end
end

it "sets registration enabled to true when registration type is on this platform" do
within find("tr", text: Decidim::Meetings::MeetingPresenter.new(meeting).title) do
click_link "Edit"
end

within ".edit_meeting" do
select "On this platform", from: :meeting_registration_type

find("*[type=submit]").click
end

expect(page).to have_admin_callout("successfully")
expect(meeting.reload.registrations_enabled).to be true
end

it "sets registration enabled to false when registration type is not on this platform" do
within find("tr", text: Decidim::Meetings::MeetingPresenter.new(meeting).title) do
click_link "Edit"
end

within ".edit_meeting" do
select "Registration disabled", from: :meeting_registration_type

find("*[type=submit]").click
end

expect(page).to have_admin_callout("successfully")
expect(meeting.reload.registrations_enabled).to be false
end

it "adds a few services to the meeting", :serves_geocoding_autocomplete do
within find("tr", text: Decidim::Meetings::MeetingPresenter.new(meeting).title) do
click_link "Edit"
Expand Down