Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Ensure we send an email when meetings get cancelled

Oliver Günther73200f0fd031
diff --git a/modules/meeting/app/contracts/meetings/base_contract.rb b/modules/meeting/app/contracts/meetings/base_contract.rb
index 229ca51a34a..12df2b732c8 100644
--- a/modules/meeting/app/contracts/meetings/base_contract.rb
+++ b/modules/meeting/app/contracts/meetings/base_contract.rb
@@ -41,5 +41,16 @@ module Meetings
attribute :start_date
attribute :start_time
attribute :start_time_hour
+ attribute :template
+
+ validate :template_requires_series
+
+ private
+
+ def template_requires_series
+ if model.template && model.recurring_meeting_id.nil?
+ errors.add(:template, :invalid)
+ end
+ end
end
end
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index d0aaa38d64b..94eaaf774e8 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -402,9 +402,13 @@ class MeetingsController < ApplicationController
end
def build_meeting
- @meeting = meeting_class.new
- @meeting.project = @project
- @meeting.author = User.current
+ meeting = meeting_class.new
+
+ call = ::Meetings::SetAttributesService
+ .new(user: current_user, model: meeting, contract_class: EmptyContract)
+ .call(project: @project)
+
+ @meeting = call.result
end
def meeting_class
diff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rb
index a58102c9a4c..256ef04e8e9 100644
--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb
@@ -160,11 +160,13 @@ class RecurringMeetingsController < ApplicationController
end
def destroy
- if @recurring_meeting.destroy
- flash[:notice] = I18n.t(:notice_successful_delete)
- else
- flash[:error] = I18n.t(:error_failed_to_delete_entry)
- end
+ # rubocop:disable Rails/ActionControllerFlashBeforeRender
+ RecurringMeetings::DeleteService
+ .new(model: @recurring_meeting, user: User.current)
+ .call
+ .on_success { flash[:notice] = I18n.t(:notice_successful_delete) }
+ .on_failure { flash[:error] = I18n.t(:error_failed_to_delete_entry) }
+ # rubocop:enable Rails/ActionControllerFlashBeforeRender
respond_to do |format|
format.html do
diff --git a/modules/meeting/app/mailers/meeting_mailer.rb b/modules/meeting/app/mailers/meeting_mailer.rb
index 30e452131d2..d7a37826f2b 100644
--- a/modules/meeting/app/mailers/meeting_mailer.rb
+++ b/modules/meeting/app/mailers/meeting_mailer.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -57,6 +59,36 @@ class MeetingMailer < UserMailer
end
end
+ def cancelled(meeting, user, actor)
+ @actor = actor
+ @user = user
+ @meeting = meeting
+
+ open_project_headers "Project" => @meeting.project.identifier,
+ "Meeting-Id" => @meeting.id
+
+ with_attached_ics(meeting, user, cancelled: true) do
+ subject = I18n.t("meeting.email.cancelled.header", title: @meeting.title)
+
+ mail(to: user, subject: "[#{@meeting.project.name}] #{subject}")
+ end
+ end
+
+ def cancelled_series(series, user, actor)
+ @actor = actor
+ @user = user
+ @series = series
+
+ open_project_headers "Project" => @series.project.identifier,
+ "Meeting-Id" => @series.id
+
+ with_attached_ics(@series, user, cancelled: true) do
+ subject = I18n.t("meeting.email.cancelled.header", title: @series.title)
+
+ mail(to: user, subject: "[#{@series.project.name}] #{subject}")
+ end
+ end
+
def icalendar_notification(meeting, user, _actor, **)
@meeting = meeting
@@ -70,9 +102,9 @@ class MeetingMailer < UserMailer
private
- def with_attached_ics(meeting, user)
+ def with_attached_ics(meeting, user, **args)
User.execute_as(user) do
- call = ics_service_call(meeting, user)
+ call = ics_service_call(meeting, user, **args)
call.on_success do
attachments["meeting.ics"] = call.result
@@ -86,15 +118,19 @@ class MeetingMailer < UserMailer
end
end
- def ics_service_call(meeting, user)
- if meeting.recurring?
+ def ics_service_call(meeting, user, **args)
+ if meeting.is_a?(RecurringMeeting)
+ ::RecurringMeetings::ICalService
+ .new(user:, series: meeting)
+ .generate_series(**args)
+ elsif meeting.recurring?
::RecurringMeetings::ICalService
.new(user:, series: meeting.recurring_meeting)
- .generate_occurrence(meeting.scheduled_meeting)
+ .generate_occurrence(meeting, **args)
else
::Meetings::ICalService
.new(user:, meeting:)
- .call
+ .call(**args)
end
end
diff --git a/modules/meeting/app/models/meeting/virtual_start_time.rb b/modules/meeting/app/models/meeting/virtual_start_time.rb
index 68bbdf198e8..b64f388277b 100644
--- a/modules/meeting/app/models/meeting/virtual_start_time.rb
+++ b/modules/meeting/app/models/meeting/virtual_start_time.rb
@@ -92,7 +92,6 @@ module Meeting::VirtualStartTime
# set defaults
# Start date is set to tomorrow at 10 AM (Current users local time)
write_attribute(:start_time, User.current.time_zone.now.at_midnight + 34.hours) if start_time.nil?
- self.duration ||= 1
update_derived_fields
end
diff --git a/modules/meeting/app/services/meetings/delete_service.rb b/modules/meeting/app/services/meetings/delete_service.rb
index 55642242f49..01cfcd8ab39 100644
--- a/modules/meeting/app/services/meetings/delete_service.rb
+++ b/modules/meeting/app/services/meetings/delete_service.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -31,10 +33,25 @@ module Meetings
protected
def after_validate(_, call)
- schedule = model.scheduled_meeting
- schedule.update_column(:cancelled, true) if schedule.present?
+ send_cancellation_mail(model)
+ cancel_scheduled_meeting(model)
call
end
+
+ def send_cancellation_mail(meeting)
+ meeting.participants.where(invited: true).find_each do |participant|
+ MeetingMailer
+ .cancelled(meeting, participant.user, User.current)
+ .deliver_now
+ end
+ end
+
+ def cancel_scheduled_meeting(meeting)
+ schedule = meeting.scheduled_meeting
+ return if schedule.nil?
+
+ schedule.update_column(:cancelled, true)
+ end
end
end
diff --git a/modules/meeting/app/services/meetings/ical_helpers.rb b/modules/meeting/app/services/meetings/ical_helpers.rb
index 9812c612a18..fa6ebdc841d 100644
--- a/modules/meeting/app/services/meetings/ical_helpers.rb
+++ b/modules/meeting/app/services/meetings/ical_helpers.rb
@@ -30,13 +30,27 @@ require "icalendar/tzinfo"
module Meetings
module ICalHelpers
- def ical_event(start_time, &)
+ def ical_event(start_time, cancelled:, &)
calendar = build_icalendar(start_time)
calendar.event(&)
- calendar.publish
+
+ if cancelled
+ calendar.cancel
+ else
+ calendar.publish
+ end
calendar.to_ical
end
+ def set_status(cancelled, event)
+ event.status =
+ if cancelled
+ "CANCELLED"
+ else
+ "CONFIRMED"
+ end
+ end
+
def build_icalendar(start_time)
::Icalendar::Calendar.new.tap do |calendar|
calendar.prodid = "-//OpenProject GmbH//#{OpenProject::VERSION}//Meeting//EN"
diff --git a/modules/meeting/app/services/meetings/ical_service.rb b/modules/meeting/app/services/meetings/ical_service.rb
index dbdaa99958e..9d0519b19a2 100644
--- a/modules/meeting/app/services/meetings/ical_service.rb
+++ b/modules/meeting/app/services/meetings/ical_service.rb
@@ -39,10 +39,10 @@ module Meetings
@url_helpers = OpenProject::StaticRouting::StaticUrlHelpers.new
end
- def call
+ def call(cancelled: false)
User.execute_as(user) do
@timezone = Time.zone || Time.zone_default
- ServiceResult.success(result: generate_ical)
+ ServiceResult.success(result: generate_ical(cancelled:))
end
rescue StandardError => e
Rails.logger.error("Failed to generate ICS for meeting #{@meeting.id}: #{e.message}")
@@ -52,8 +52,8 @@ module Meetings
private
# rubocop:disable Metrics/AbcSize
- def generate_ical
- ical_event(meeting.start_time) do |e|
+ def generate_ical(cancelled:)
+ ical_event(meeting.start_time, cancelled:) do |e|
tzinfo = timezone.tzinfo
tzid = tzinfo.canonical_identifier
@@ -66,6 +66,7 @@ module Meetings
e.organizer = ical_organizer(meeting)
e.location = meeting.location.presence
+ set_status(cancelled, e)
add_attendees(e, meeting)
end
end
diff --git a/modules/meeting/app/services/meetings/set_attributes_service.rb b/modules/meeting/app/services/meetings/set_attributes_service.rb
index abe44c0d3a9..bf32b7e8cd9 100644
--- a/modules/meeting/app/services/meetings/set_attributes_service.rb
+++ b/modules/meeting/app/services/meetings/set_attributes_service.rb
@@ -39,6 +39,7 @@ module Meetings
def set_default_attributes(_params)
model.change_by_system do
model.author = user
+ model.duration ||= 1
end
end
diff --git a/modules/meeting/app/services/recurring_meetings/create_service.rb b/modules/meeting/app/services/recurring_meetings/create_service.rb
index 2a37d196239..d80734ff3ae 100644
--- a/modules/meeting/app/services/recurring_meetings/create_service.rb
+++ b/modules/meeting/app/services/recurring_meetings/create_service.rb
@@ -42,13 +42,16 @@ module RecurringMeetings
end
def create_meeting_template(recurring_meeting)
- template = StructuredMeeting.new(@template_params)
- template.project = recurring_meeting.project
- template.template = true
- template.recurring_meeting = recurring_meeting
- template.author = user
+ params = @template_params.merge(
+ type: "StructuredMeeting",
+ template: true,
+ recurring_meeting:,
+ project: recurring_meeting.project
+ )
- ServiceResult.new(success: template.save, errors: template.errors)
+ Meetings::CreateService
+ .new(user: user)
+ .call(params)
end
end
end
diff --git a/modules/meeting/app/services/recurring_meetings/delete_service.rb b/modules/meeting/app/services/recurring_meetings/delete_service.rb
new file mode 100644
index 00000000000..4287dcffa65
--- /dev/null
+++ b/modules/meeting/app/services/recurring_meetings/delete_service.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module RecurringMeetings
+ class DeleteService < ::BaseServices::Delete
+ protected
+
+ def default_contract_class
+ Meetings::DeleteContract
+ end
+
+ def after_validate(_, call)
+ send_cancellation_mail(model)
+
+ call
+ end
+
+ def send_cancellation_mail(meeting)
+ meeting.template.participants.where(invited: true).find_each do |participant|
+ MeetingMailer
+ .cancelled_series(meeting, participant.user, User.current)
+ .deliver_now
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/services/recurring_meetings/ical_service.rb b/modules/meeting/app/services/recurring_meetings/ical_service.rb
index dd3c6c80173..edde6bf7217 100644
--- a/modules/meeting/app/services/recurring_meetings/ical_service.rb
+++ b/modules/meeting/app/services/recurring_meetings/ical_service.rb
@@ -47,21 +47,23 @@ module RecurringMeetings
@url_helpers = OpenProject::StaticRouting::StaticUrlHelpers.new
end
- def generate_series
+ def generate_series(cancelled: false)
ical_result(series) do
- series_event
+ series_event(cancelled:)
occurrences_events
+ calendar_status(cancelled:)
end
rescue StandardError => e
Rails.logger.error("Failed to generate ICS for meeting series #{series.id}: #{e.message}")
ServiceResult.failure(message: e.message)
end
- def generate_occurrence(meeting)
+ def generate_occurrence(meeting, cancelled: false)
# Get the time the meeting was scheduled to take place
scheduled_meeting = meeting.scheduled_meeting
ical_result(scheduled_meeting) do
- occurrence_event(scheduled_meeting.start_time, meeting)
+ occurrence_event(scheduled_meeting.start_time, meeting, cancelled:)
+ calendar_status(cancelled:)
end
rescue StandardError => e
Rails.logger.error("Failed to generate ICS for meeting #{meeting.id}: #{e.message}")
@@ -70,6 +72,14 @@ module RecurringMeetings
private
+ def calendar_status(cancelled:)
+ if cancelled
+ calendar.cancel
+ else
+ calendar.publish
+ end
+ end
+
def ical_result(meeting)
User.execute_as(user) do
@timezone = Time.zone || Time.zone_default
@@ -77,7 +87,6 @@ module RecurringMeetings
yield
- calendar.publish
ServiceResult.success(result: calendar.to_ical)
end
end
@@ -90,7 +99,7 @@ module RecurringMeetings
tzinfo.canonical_identifier
end
- def series_event # rubocop:disable Metrics/AbcSize
+ def series_event(cancelled:) # rubocop:disable Metrics/AbcSize
calendar.event do |e|
base_series_attributes(e)
@@ -102,16 +111,18 @@ module RecurringMeetings
add_attendees(e, template)
e.exdate = cancelled_schedules
+
+ set_status(cancelled, e)
end
end
def occurrences_events
upcoming_instantiated_schedules.find_each do |schedule|
- occurrence_event(schedule.start_time, schedule.meeting)
+ occurrence_event(schedule.start_time, schedule.meeting, cancelled: false)
end
end
- def occurrence_event(schedule_start_time, meeting) # rubocop:disable Metrics/AbcSize
+ def occurrence_event(schedule_start_time, meeting, cancelled:) # rubocop:disable Metrics/AbcSize
calendar.event do |e|
base_series_attributes(e)
@@ -123,6 +134,7 @@ module RecurringMeetings
e.sequence = meeting.lock_version
add_attendees(e, meeting)
+ set_status(cancelled, e)
end
end
diff --git a/modules/meeting/app/services/recurring_meetings/set_attributes_service.rb b/modules/meeting/app/services/recurring_meetings/set_attributes_service.rb
index 9f232da2b30..e8c71f00475 100644
--- a/modules/meeting/app/services/recurring_meetings/set_attributes_service.rb
+++ b/modules/meeting/app/services/recurring_meetings/set_attributes_service.rb
@@ -43,6 +43,7 @@ module RecurringMeetings
def set_default_attributes(_params)
model.change_by_system do
model.author = user
+ model.duration ||= 1
end
end
end
diff --git a/modules/meeting/app/views/meeting_mailer/cancelled.html.erb b/modules/meeting/app/views/meeting_mailer/cancelled.html.erb
new file mode 100644
index 00000000000..60b556e7820
--- /dev/null
+++ b/modules/meeting/app/views/meeting_mailer/cancelled.html.erb
@@ -0,0 +1,103 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<%
+ summary =
+ if @meeting.recurring?
+ I18n.t("meeting.email.cancelled.summary_occurrence",
+ title: @meeting.title,
+ actor: @actor)
+ else
+ I18n.t("meeting.email.cancelled.summary",
+ title: @meeting.title,
+ actor: @actor)
+ end
+%>
+
+<%= render layout: "mailer/spacer_table" do %>
+ <%= render partial: "mailer/mailer_header",
+ locals: {
+ user: @user,
+ summary:,
+ bottom_spacing: false
+ } %>
+
+ <%= render layout: "mailer/border_table" do %>
+ <tr>
+ <%= placeholder_cell("24px", vertical: true) %>
+ <td>
+ <table>
+ <tr>
+ <td style="<%= placeholder_text_styles(width: "30%") %>">
+ <%= t("meeting.email.cancelled.date_time") %>
+ </td>
+ <td style="<%= placeholder_text_styles %>">
+ <s>
+ <%= format_time_as_date @meeting.start_time %> <%= format_time @meeting.start_time, include_date: false %>
+ -
+ <%= format_time @meeting.end_time, include_date: false %> (<%= formatted_time_zone_offset %>)
+ </s>
+ </td>
+ </tr>
+ <% if @meeting.location.present? %>
+ <tr>
+ <td style="<%= placeholder_text_styles(width: "30%") %>">
+ <%= Meeting.human_attribute_name(:location) %>
+ </td>
+ <td style="<%= placeholder_text_styles %>">
+ <%= auto_link @meeting.location %>
+ </td>
+ </tr>
+ <% end %>
+ <tr>
+ <td style="<%= placeholder_text_styles(width: "30%") %>">
+ <%= Meeting.human_attribute_name(:project) %>
+ </td>
+ <td style="<%= placeholder_text_styles %>">
+ <%= link_to @meeting.project.name, project_url(@meeting.project) %>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <% end %>
+
+ <table>
+ <tr>
+ <%= placeholder_cell("20px", vertical: false) %>
+ </tr>
+ </table>
+
+ <%= action_button do %>
+ <%= link_to I18n.t(:"meeting.email.open_my_meetings_link"),
+ meetings_url,
+ target: "_blank",
+ style: "color: #333333; text-decoration: none; font-size: 14px;white-space: nowrap;", rel: "noopener" %>
+ <% end %>
+<% end %>
diff --git a/modules/meeting/app/views/meeting_mailer/cancelled.text.erb b/modules/meeting/app/views/meeting_mailer/cancelled.text.erb
new file mode 100644
index 00000000000..8e2a05f3f3e
--- /dev/null
+++ b/modules/meeting/app/views/meeting_mailer/cancelled.text.erb
@@ -0,0 +1,47 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<%
+ summary =
+ if @meeting.recurring?
+ I18n.t("meeting.email.cancelled.summary_occurrence",
+ title: @meeting.title,
+ actor: @actor)
+ else
+ I18n.t("meeting.email.cancelled.summary",
+ title: @meeting.title,
+ actor: @actor)
+ end
+%>
+
+<%= summary %>
+
+<%= @meeting.project.name %>: <%= @meeting.title %>
+<%= @meeting.author %>
+<%= t :label_meeting_date_time %>: <%= format_time_as_date @meeting.start_time %> <%= format_time @meeting.start_time, include_date: false %>-<%= format_time @meeting.end_time, include_date: false %> (<%= formatted_time_zone_offset %>)
diff --git a/modules/meeting/app/views/meeting_mailer/cancelled_series.html.erb b/modules/meeting/app/views/meeting_mailer/cancelled_series.html.erb
new file mode 100644
index 00000000000..4144daf8c3f
--- /dev/null
+++ b/modules/meeting/app/views/meeting_mailer/cancelled_series.html.erb
@@ -0,0 +1,78 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<%= render layout: "mailer/spacer_table" do %>
+ <%= render partial: "mailer/mailer_header",
+ locals: {
+ user: @user,
+ summary: I18n.t("meeting.email.cancelled.summary_series", title: @series.title, actor: @actor),
+ bottom_spacing: false
+ } %>
+
+ <%= render layout: "mailer/border_table" do %>
+ <tr>
+ <%= placeholder_cell("24px", vertical: true) %>
+ <td>
+ <table>
+ <tr>
+ <td style="<%= placeholder_text_styles(width: "30%") %>">
+ <%= t(:label_recurring_meeting_schedule) %>
+ </td>
+ <td style="<%= placeholder_text_styles %>">
+ <s>
+ <%= @series.full_schedule_in_words %> (<%= formatted_time_zone_offset %>)
+ </s>
+ </td>
+ </tr>
+ <tr>
+ <td style="<%= placeholder_text_styles(width: "30%") %>">
+ <%= Meeting.human_attribute_name(:project) %>
+ </td>
+ <td style="<%= placeholder_text_styles %>">
+ <%= link_to @series.project.name, project_url(@series.project) %>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <% end %>
+
+ <table>
+ <tr>
+ <%= placeholder_cell("20px", vertical: false) %>
+ </tr>
+ </table>
+
+ <%= action_button do %>
+ <%= link_to I18n.t(:"meeting.email.open_my_meetings_link"),
+ meetings_url,
+ target: "_blank",
+ style: "color: #333333; text-decoration: none; font-size: 14px;white-space: nowrap;", rel: "noopener" %>
+ <% end %>
+<% end %>
diff --git a/modules/meeting/app/views/meeting_mailer/cancelled_series.text.erb b/modules/meeting/app/views/meeting_mailer/cancelled_series.text.erb
new file mode 100644
index 00000000000..4d85d63df08
--- /dev/null
+++ b/modules/meeting/app/views/meeting_mailer/cancelled_series.text.erb
@@ -0,0 +1,36 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<%= I18n.t("meeting.email.cancelled.summary_series",
+ title: @series.title,
+ actor: @actor) %>
+
+<%= @series.project.name %>: <%= @series.title %>
+<%= @series.author %>
+<%= t :label_recurring_meeting_schedule %>: <%= @series.full_schedule_in_words %> (<%= formatted_time_zone_offset %>)
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index 80704b25893..e08617f39f9 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -196,11 +196,20 @@ en:
Send an email invitation immediately to the participants selected above. You can also do this manually at any time later.
send_invitation_emails_structured: "Send an email invitation immediately to all participants. You can also do this manually at any time later."
open_meeting_link: "Open meeting"
+ open_my_meetings_link: "Go to My meetings"
series:
title: "[%{project_name}] Meeting series %{title}"
summary: "%{actor} has set up a new meeting series %{title}"
invited:
summary: "%{actor} has sent you an invitation for the meeting %{title}"
+ cancelled:
+ header: "Cancelled: Meeting '%{title}'"
+ header_occurrence: "Cancelled: Meeting occurrence '%{title}'"
+ header_series: "Cancelled: Meeting series '%{title}'"
+ summary_occurrence: "An occurrence of '%{title}' has been cancelled by %{actor}."
+ summary_series: "Meeting series '%{title}' has been cancelled by %{actor}."
+ summary: "'%{title}' has been cancelled by %{actor}."
+ date_time: "Scheduled date/time"
rescheduled:
header: "Meeting %{title} has been rescheduled"
summary: "Meeting %{title} has been rescheduled by %{actor}"
diff --git a/modules/meeting/spec/factories/meeting_factory.rb b/modules/meeting/spec/factories/meeting_factory.rb
index 3ec2041df7d..7d8821325ae 100644
--- a/modules/meeting/spec/factories/meeting_factory.rb
+++ b/modules/meeting/spec/factories/meeting_factory.rb
@@ -31,6 +31,7 @@ FactoryBot.define do
author factory: :user
project
start_time { Date.tomorrow + 10.hours }
+ recurring_meeting { nil }
duration { 1.0 }
location { "https://some-url.com" }
m.sequence(:title) { |n| "Meeting #{n}" }
diff --git a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb
index f13ab2327f0..672c8f2fc2c 100644
--- a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb
+++ b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb
@@ -88,10 +88,11 @@ RSpec.describe "Recurring meetings CRUD",
show_page.visit!
show_page.delete_meeting_series
- show_page.within_modal "Delete meeting series" do
- check "I understand that this deletion cannot be reversed", allow_label_click: true
-
- click_on "Delete permanently"
+ retry_block do
+ show_page.within_modal "Delete meeting series" do
+ check "I understand that this deletion cannot be reversed", allow_label_click: true
+ click_on "Delete permanently"
+ end
end
expect(page).to have_current_path project_meetings_path(project)
diff --git a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_global_crud_spec.rb b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_global_crud_spec.rb
index 9ab07fdd7aa..62c5970abb3 100644
--- a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_global_crud_spec.rb
+++ b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_global_crud_spec.rb
@@ -89,10 +89,12 @@ RSpec.describe "Recurring meetings global CRUD", :js do
show_page.visit!
show_page.delete_meeting_series
- show_page.within_modal "Delete meeting series" do
- check "I understand that this deletion cannot be reversed", allow_label_click: true
- click_on "Delete permanently"
+ retry_block do
+ show_page.within_modal "Delete meeting series" do
+ check "I understand that this deletion cannot be reversed", allow_label_click: true
+ click_on "Delete permanently"
+ end
end
expect(page).to have_current_path meetings_path
diff --git a/modules/meeting/spec/requests/meetings_delete_spec.rb b/modules/meeting/spec/requests/meetings_delete_spec.rb
new file mode 100644
index 00000000000..a765c21aa26
--- /dev/null
+++ b/modules/meeting/spec/requests/meetings_delete_spec.rb
@@ -0,0 +1,93 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require "spec_helper"
+
+RSpec.describe "DELETE /meetings/:id",
+ :skip_csrf,
+ type: :rails_request do
+ include Redmine::I18n
+
+ shared_let(:project) { create(:project, enabled_module_names: %i[meetings]) }
+ shared_let(:user) do
+ create(:user,
+ firstname: "Bob",
+ lastname: "User",
+ member_with_permissions: { project => %i[view_meetings delete_meetings] })
+ end
+
+ shared_let(:meeting) do
+ create :meeting,
+ project:,
+ title: "My one-off meeting",
+ author: user,
+ start_time: Time.zone.today - 10.days + 10.hours
+ end
+
+ let(:current_user) { user }
+ let(:request) { delete meeting_path(meeting) }
+
+ subject do
+ request
+ response
+ end
+
+ before do
+ login_as(current_user)
+ end
+
+ context "when user has permissions to access" do
+ it "deletes the meeting" do
+ expect(subject).to have_http_status(:see_other)
+
+ expect { meeting.reload }.to raise_error(ActiveRecord::RecordNotFound)
+
+ perform_enqueued_jobs
+ expect(ActionMailer::Base.deliveries.size).to eq(1)
+ mail = ActionMailer::Base.deliveries.first
+ expect(mail.body.parts.first.parts.first.body.to_s)
+ .to include "'My one-off meeting' has been cancelled by #{user.name}"
+ end
+ end
+
+ context "when user has no permissions to access" do
+ let(:current_user) { create(:user) }
+
+ it "does not delete the meeting" do
+ delete meeting_path(meeting)
+ expect(response).to have_http_status(:forbidden)
+ end
+
+ it "does not delete project meeting" do
+ delete project_meeting_path(project, meeting)
+ expect(response).to have_http_status(:forbidden)
+ end
+ end
+end
diff --git a/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_delete_spec.rb b/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_delete_spec.rb
new file mode 100644
index 00000000000..42bccc05331
--- /dev/null
+++ b/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_delete_spec.rb
@@ -0,0 +1,115 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require "spec_helper"
+require_relative "../../support/pages/recurring_meeting/show"
+
+RSpec.describe "DELETE /recurring_meetings/:id",
+ :skip_csrf,
+ type: :rails_request do
+ include Redmine::I18n
+
+ shared_let(:project) { create(:project, enabled_module_names: %i[meetings]) }
+ shared_let(:user) do
+ create(:user,
+ firstname: "Bob",
+ lastname: "User",
+ member_with_permissions: { project => %i[view_meetings delete_meetings] })
+ end
+
+ shared_let(:recurring_meeting) do
+ create :recurring_meeting,
+ project:,
+ author: user,
+ start_time: Time.zone.today - 10.days + 10.hours,
+ frequency: "daily"
+ end
+
+ let(:current_user) { user }
+ let(:show_page) { Pages::RecurringMeeting::Show.new(recurring_meeting).with_capybara_page(page) }
+ let(:request) { delete recurring_meeting_path(recurring_meeting) }
+
+ subject do
+ request
+ response
+ end
+
+ before do
+ login_as(current_user)
+
+ # Assuming the first init job has run
+ RecurringMeetings::InitNextOccurrenceJob.perform_now(recurring_meeting, recurring_meeting.first_occurrence.to_time)
+ end
+
+ context "when user has permissions to access" do
+ it "deletes the series" do
+ title = recurring_meeting.title
+ expect(subject).to have_http_status(:found)
+
+ expect { recurring_meeting.reload }.to raise_error(ActiveRecord::RecordNotFound)
+
+ perform_enqueued_jobs
+ expect(ActionMailer::Base.deliveries.size).to eq(1)
+ mail = ActionMailer::Base.deliveries.first
+ expect(mail.body.parts.first.parts.first.body.to_s)
+ .to include "Meeting series '#{title}' has been cancelled by #{user.name}."
+ end
+
+ context "when deleting an occurrence" do
+ let(:request) { delete meeting_path(recurring_meeting.meetings.not_templated.last) }
+
+ it "deletes the occurrence" do
+ title = recurring_meeting.template.title
+ expect { subject }.to change(recurring_meeting.meetings, :count).by(-1)
+ expect(subject).to have_http_status(:see_other)
+
+ expect(recurring_meeting.reload).to be_present
+ expect(ActionMailer::Base.deliveries.size).to eq(1)
+ mail = ActionMailer::Base.deliveries.first
+ expect(mail.body.parts.first.parts.first.body.to_s)
+ .to include "An occurrence of '#{title}' has been cancelled by #{user.name}."
+ end
+ end
+ end
+
+ context "when user has no permissions to access" do
+ let(:current_user) { create(:user) }
+
+ it "does not show the recurring meetings" do
+ delete recurring_meeting_path(recurring_meeting)
+ expect(response).to have_http_status(:not_found)
+ end
+
+ it "does not show project recurring meetings" do
+ delete project_recurring_meeting_path(project, recurring_meeting)
+ expect(response).to have_http_status(:not_found)
+ end
+ end
+end
diff --git a/spec/mailers/previews/meeting_mailer_preview.rb b/spec/mailers/previews/meeting_mailer_preview.rb
index f97912c6318..3be6f213b68 100644
--- a/spec/mailers/previews/meeting_mailer_preview.rb
+++ b/spec/mailers/previews/meeting_mailer_preview.rb
@@ -45,6 +45,40 @@ class MeetingMailerPreview < ActionMailer::Preview
MeetingMailer.rescheduled(meeting, user, actor, changes:)
end
+ def cancelled
+ language = params["locale"] || I18n.default_locale
+ actor = FactoryBot.build_stubbed(:user, lastname: "Actor")
+ user = FactoryBot.build_stubbed(:user, language:)
+ meeting = FactoryBot.build_stubbed(:meeting, start_time: 1.day.from_now, duration: 1.0)
+
+ MeetingMailer.cancelled(meeting, user, actor)
+ end
+
+ def cancelled_occurrence
+ language = params["locale"] || I18n.default_locale
+ actor = FactoryBot.build_stubbed(:user, lastname: "Actor")
+ user = FactoryBot.build_stubbed(:user, language:)
+
+ recurring_meeting = RecurringMeeting.last
+ raise "Need to have a recurring meeting in your dev db" unless recurring_meeting
+
+ schedule = recurring_meeting.scheduled_meetings.first
+ raise "Need to have a recurring meeting with at least a schedule meeting" unless schedule
+
+ MeetingMailer.cancelled(schedule.meeting, user, actor)
+ end
+
+ def cancelled_series
+ language = params["locale"] || I18n.default_locale
+ actor = FactoryBot.build_stubbed(:user, lastname: "Actor")
+ user = FactoryBot.build_stubbed(:user, language:)
+
+ recurring_meeting = RecurringMeeting.last
+ raise "Need to have a recurring meeting in your dev db" unless recurring_meeting
+
+ MeetingMailer.cancelled_series(recurring_meeting, user, actor)
+ end
+
def invited
language = params["locale"] || I18n.default_locale
actor = FactoryBot.build_stubbed(:user, lastname: "Actor")