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 single meetings into the ical feed
Klaus Zanders10d6af0fc573
diff --git a/modules/meeting/app/controllers/meetings/ical_controller.rb b/modules/meeting/app/controllers/meetings/ical_controller.rbindex 98d8e5510b6..9582b789951 100644--- a/modules/meeting/app/controllers/meetings/ical_controller.rb+++ b/modules/meeting/app/controllers/meetings/ical_controller.rb@@ -37,7 +37,7 @@ module Meetingsuser = token.user- service = Meetings::UnifiedICalService.new(user:)+ service = AllMeetingsICalService.new(user:)respond_to do |format|format.ics dodiff --git a/modules/meeting/app/services/all_meetings_ical_service.rb b/modules/meeting/app/services/all_meetings_ical_service.rbnew file mode 100644index 00000000000..a60f4ba107c--- /dev/null+++ b/modules/meeting/app/services/all_meetings_ical_service.rb@@ -0,0 +1,89 @@+# 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 "icalendar"+require "icalendar/tzinfo"++class AllMeetingsICalService+ include Meetings::ICalHelpers+ attr_reader :user, :url_helpers, :include_historic, :calendar, :timezone++ def initialize(user:, include_historic: false)+ @user = user+ @timezone = user.time_zone+ @url_helpers = OpenProject::StaticRouting::StaticUrlHelpers.new+ @include_historic = include_historic+ @calendar = build_icalendar(Time.current.in_time_zone(user.time_zone))+ end++ def call+ single_meetings.each do |meeting|+ build_single_meeting(meeting)+ end++ ServiceResult.success(result: calendar.to_ical)+ end++ private++ def build_single_meeting(meeting) # rubocop:disable Metrics/AbcSize+ tzinfo = timezone.tzinfo+ tzid = tzinfo.canonical_identifier++ calendar.event do |e|+ e.dtstart = ical_datetime meeting.start_time, tzid+ e.dtend = ical_datetime meeting.end_time, tzid+ e.url = url_helpers.meeting_url(meeting)+ e.summary = "[#{meeting.project.name}] #{meeting.title}"+ e.description = ical_subject(meeting)+ e.uid = "#{meeting.id}@#{meeting.project.identifier}"+ e.organizer = ical_organizer+ e.location = meeting.location.presence++ # set_status(cancelled, e)+ add_attendees(e, meeting)+ end+ end++ def ical_subject(meeting)+ "[#{meeting.project.name}] #{I18n.t(:label_meeting)}: #{meeting.title}"+ end++ def recurring_meetings+ @recurring_meetings ||= RecurringMeeting.visible(user)+ end++ def single_meetings+ @single_meetings ||= if include_historic+ Meeting.not_recurring.visible(user)+ else+ Meeting.not_recurring.from_today.visible(user)+ end+ end+enddiff --git a/modules/meeting/app/services/meetings/unified_ical_service.rb b/modules/meeting/app/services/meetings/unified_ical_service.rbdeleted file mode 100644index 10267a0291f..00000000000--- a/modules/meeting/app/services/meetings/unified_ical_service.rb+++ /dev/null@@ -1,67 +0,0 @@-# 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 "icalendar"-require "icalendar/tzinfo"--module Meetings- class UnifiedICalService- include ICalHelpers- attr_reader :user, :url_helpers, :include_historic-- def initialize(user:, include_historic: false)- @user = user- @url_helpers = OpenProject::StaticRouting::StaticUrlHelpers.new- @include_historic = include_historic- end-- def call- calendar = ::Icalendar::Calendar.new.tap do |calendar|- calendar.prodid = "-//OpenProject GmbH//#{OpenProject::VERSION}//Meeting//EN"- # calendar.add_timezone ical_timezone- end-- ServiceResult.success(result: calendar.to_ical)- end-- private-- def recurring_meetings- @recurring_meetings ||= RecurringMeeting.visible(user)- end-- def single_meetings- @single_meetings ||= if include_historic- Meeting.not_recurring.visible(user)- else- Meeting.not_recurring.from_today.visible(user)- end- end- end-end