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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add notify attribute to meetings
Mir Bhatia6e024b5bbf3d
diff --git a/db/migrate/20250709103506_add_notify_status_to_meetings.rb b/db/migrate/20250709103506_add_notify_status_to_meetings.rbnew file mode 100644index 00000000000..21009b2ba38--- /dev/null+++ b/db/migrate/20250709103506_add_notify_status_to_meetings.rb@@ -0,0 +1,35 @@+# 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.+#++++class AddNotifyStatusToMeetings < ActiveRecord::Migration[8.0]+ def change+ add_column :meetings, :notify, :boolean, default: true, null: false+ end+enddiff --git a/modules/meeting/app/components/meetings/header_component.html.erb b/modules/meeting/app/components/meetings/header_component.html.erbindex 67472658698..607479710a2 100644--- a/modules/meeting/app/components/meetings/header_component.html.erb+++ b/modules/meeting/app/components/meetings/header_component.html.erb@@ -86,7 +86,7 @@item.with_leading_visual_icon(icon: :download)end- if @meeting.open? && User.current.allowed_in_project?(:send_meeting_invites_and_outcomes, @meeting.project)+ if send_emails?menu.with_item(label: t("meeting.label_mail_all_participants"),href: notify_project_meeting_path(@project, @meeting),@@ -97,7 +97,7 @@endmenu.with_item(- label: t("meeting.label_export_pdf"),+ label: t("meeting.label_export_pdf"),tag: :a,href: generate_pdf_dialog_project_meeting_path(@project, @meeting),content_arguments: {diff --git a/modules/meeting/app/components/meetings/header_component.rb b/modules/meeting/app/components/meetings/header_component.rbindex 5d6fa8d81ad..fb3aa044720 100644--- a/modules/meeting/app/components/meetings/header_component.rb+++ b/modules/meeting/app/components/meetings/header_component.rb@@ -73,6 +73,12 @@ module Meetings@series.scheduled_meetings.none?end+ def send_emails?+ [email protected]? &&+ @meeting.notify &&+ User.current.allowed_in_project?(:send_meeting_invites_and_outcomes, @meeting.project)+ end+def breadcrumb_items[({ href: project_overview_path(@project.id), text: @project.name } if @project.present?),diff --git a/modules/meeting/app/components/meetings/index/form_component.html.erb b/modules/meeting/app/components/meetings/index/form_component.html.erbindex 81cada069af..c6c3176b4e7 100644--- a/modules/meeting/app/components/meetings/index/form_component.html.erb+++ b/modules/meeting/app/components/meetings/index/form_component.html.erb@@ -116,6 +116,10 @@endend+ modal_body.with_row(mt: 3) do+ render(Meeting::SendEmailUpdates.new(f, meeting: @meeting))+ end+if @copy_frommodal_body.with_row dorender(Meeting::CopiedFrom.new(f, id: @copy_from.id))diff --git a/modules/meeting/app/contracts/meetings/base_contract.rb b/modules/meeting/app/contracts/meetings/base_contract.rbindex ef8e659a910..ec3b5970fdb 100644--- a/modules/meeting/app/contracts/meetings/base_contract.rb+++ b/modules/meeting/app/contracts/meetings/base_contract.rb@@ -43,6 +43,7 @@ module Meetingsattribute :start_timeattribute :start_time_hourattribute :template+ attribute :notifyvalidate :template_requires_seriesdiff --git a/modules/meeting/app/contracts/recurring_meetings/base_contract.rb b/modules/meeting/app/contracts/recurring_meetings/base_contract.rbindex dbe2b5a3680..c1571746ebd 100644--- a/modules/meeting/app/contracts/recurring_meetings/base_contract.rb+++ b/modules/meeting/app/contracts/recurring_meetings/base_contract.rb@@ -45,6 +45,7 @@ module RecurringMeetingsattribute :iterationsattribute :intervalattribute :time_zone+ attribute :notify# Virtual attributes for the formattribute :durationdiff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rbindex 13b2da65081..b19aa11bd7e 100644--- a/modules/meeting/app/controllers/meetings_controller.rb+++ b/modules/meeting/app/controllers/meetings_controller.rb@@ -475,7 +475,7 @@ class MeetingsController < ApplicationControllerparams.require(:meeting).permit(:title, :location, :start_time, :project_id,- :duration, :start_date, :start_time_hour,+ :duration, :start_date, :start_time_hour, :notify,participants_attributes: %i[email name invited attended user user_id meeting id])endenddiff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rbindex 0f82d4af99d..314a62187c0 100644--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb@@ -246,6 +246,8 @@ class RecurringMeetingsController < ApplicationControllerenddef deliver_invitation_mails+ return unless @recurring_meeting.template.notify?+@recurring_meeting.template.participants@@ -328,7 +330,7 @@ class RecurringMeetingsController < ApplicationControllerparams.require(:meeting).permit(:project_id, :title, :location, :start_time_hour, :duration, :start_date,- :interval, :frequency, :end_after, :end_date, :iterations)+ :interval, :frequency, :end_after, :end_date, :iterations, :notify)enddef find_copy_from_meetingdiff --git a/modules/meeting/app/forms/meeting/send_email_updates.rb b/modules/meeting/app/forms/meeting/send_email_updates.rbnew file mode 100644index 00000000000..3b06d575efe--- /dev/null+++ b/modules/meeting/app/forms/meeting/send_email_updates.rb@@ -0,0 +1,45 @@+# 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.+#++++class Meeting::SendEmailUpdates < ApplicationForm+ form do |meeting_form|+ meeting_form.check_box(+ name: "notify",+ label: I18n.t("label_meeting_send_updates"),+ checked: @meeting.notify? != false+ )+ end++ def initialize(meeting:)+ super()++ @meeting = meeting+ end+enddiff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rbindex 8afabfef1c6..a81d88f141d 100644--- a/modules/meeting/app/models/meeting.rb+++ b/modules/meeting/app/models/meeting.rb@@ -185,6 +185,10 @@ class Meeting < ApplicationRecord!closed? && user.allowed_in_project?(:edit_meetings, project)end+ def notify?+ notify+ end+def invited_or_attended_participantsparticipants.where(invited: true).or(participants.where(attended: true))end@@ -304,7 +308,7 @@ class Meeting < ApplicationRecordenddef send_participant_added_mail(participant)- return if templated? || new_record?+ return if templated? || new_record? || !notify?if Journal::NotificationConfiguration.active?MeetingMailer.invited(self, participant.user, User.current).deliver_later@@ -312,7 +316,7 @@ class Meeting < ApplicationRecordenddef send_rescheduling_mail- return if templated? || new_record?+ return if templated? || new_record? || !notify?MeetingNotificationService.new(self)diff --git a/modules/meeting/app/models/recurring_meeting.rb b/modules/meeting/app/models/recurring_meeting.rbindex 1538b0eaa59..d552f401fed 100644--- a/modules/meeting/app/models/recurring_meeting.rb+++ b/modules/meeting/app/models/recurring_meeting.rb@@ -99,14 +99,16 @@ class RecurringMeeting < ApplicationRecord.merge(Project.allowed_to(args.first || User.current, :view_meetings))}- # Keep location and duration as a virtual attribute- # so it can be passed to the template on save+ # Virtual attributes that can be passed on to the template on savevirtual_attribute :location donilendvirtual_attribute :duration donilend+ virtual_attribute :notify do+ nil+ enddef will_end?last_occurrence.present?@@ -116,6 +118,10 @@ class RecurringMeeting < ApplicationRecordwill_end? && last_occurrence < Time.zone.nowend+ def notify?+ template&.notify?+ end+def human_frequencycase frequencywhen "working_days"diff --git a/modules/meeting/app/services/meeting_notification_service.rb b/modules/meeting/app/services/meeting_notification_service.rbindex 5f62adc51e5..25567799d8b 100644--- a/modules/meeting/app/services/meeting_notification_service.rb+++ b/modules/meeting/app/services/meeting_notification_service.rb@@ -7,8 +7,12 @@ class MeetingNotificationServiceenddef call(action, **)- recipients_with_errors = send_notifications!(action, **)- ServiceResult.new(success: recipients_with_errors.empty?, errors: recipients_with_errors)+ if meeting.notify?+ recipients_with_errors = send_notifications!(action, **)+ ServiceResult.new(success: recipients_with_errors.empty?, errors: recipients_with_errors)+ else+ ServiceResult.failure(errors: meeting.participants.includes(:user))+ endendprivatediff --git a/modules/meeting/app/services/meetings/create_service.rb b/modules/meeting/app/services/meetings/create_service.rbindex 3031b4d5d53..de778195777 100644--- a/modules/meeting/app/services/meetings/create_service.rb+++ b/modules/meeting/app/services/meetings/create_service.rb@@ -33,8 +33,9 @@ module Meetingsprotecteddef after_perform(call)- if call.success? && Journal::NotificationConfiguration.active?- meeting = call.result+ meeting = call.result++ if call.success? && Journal::NotificationConfiguration.active? && meeting.notify?meeting.participants.where(invited: true).each do |participant|MeetingMailerdiff --git a/modules/meeting/app/services/meetings/delete_service.rb b/modules/meeting/app/services/meetings/delete_service.rbindex d9a4884afc3..14ac391db18 100644--- a/modules/meeting/app/services/meetings/delete_service.rb+++ b/modules/meeting/app/services/meetings/delete_service.rb@@ -33,7 +33,7 @@ module Meetingsprotecteddef after_validate(call)- send_cancellation_mail(model)+ send_cancellation_mail(model) if model.notify?cancel_scheduled_meeting(model)calldiff --git a/modules/meeting/app/services/recurring_meetings/delete_service.rb b/modules/meeting/app/services/recurring_meetings/delete_service.rbindex 774a2889fe7..6430a052951 100644--- a/modules/meeting/app/services/recurring_meetings/delete_service.rb+++ b/modules/meeting/app/services/recurring_meetings/delete_service.rb@@ -37,7 +37,7 @@ module RecurringMeetingsenddef after_validate(call)- send_cancellation_mail(model)+ send_cancellation_mail(model) if model.notify?callenddiff --git a/modules/meeting/app/services/recurring_meetings/update_service.rb b/modules/meeting/app/services/recurring_meetings/update_service.rbindex 70587732a5e..21c2344ed91 100644--- a/modules/meeting/app/services/recurring_meetings/update_service.rb+++ b/modules/meeting/app/services/recurring_meetings/update_service.rb@@ -151,6 +151,8 @@ module RecurringMeetingsenddef send_rescheduled_mail(recurring_meeting)+ return unless recurring_meeting.notify?+recurring_meeting.template.participantsdiff --git a/modules/meeting/app/services/recurring_meetings/with_template.rb b/modules/meeting/app/services/recurring_meetings/with_template.rbindex 4aeb1e55b24..76db0ca8f9b 100644--- a/modules/meeting/app/services/recurring_meetings/with_template.rb+++ b/modules/meeting/app/services/recurring_meetings/with_template.rb@@ -41,7 +41,7 @@ module RecurringMeetingsenddef extract_template_params(params)- params.slice(:start_date, :start_time_hour, :title, :location, :duration)+ params.slice(:start_date, :start_time_hour, :title, :location, :duration, :notify)endendenddiff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.ymlindex d716f9552d4..fbb0a06a1e7 100644--- a/modules/meeting/config/locales/en.yml+++ b/modules/meeting/config/locales/en.yml@@ -135,6 +135,7 @@ en:label_meeting_date_time: "Date/Time"label_meeting_date_and_time: "Date and time"label_meeting_diff: "Diff"+ label_meeting_send_updates: "Send email calendar updates"label_recurring_meeting: "Recurring meeting"label_recurring_meeting_part_of: "Part of a meeting series"label_recurring_meeting_new: "New recurring meeting"