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

Add a new participated_by scope for meetings and recurring meetings and use it in iCal export

Klaus Zandersad39962b0950
diff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rb
index fd69113179c..84960c3d173 100644
--- a/modules/meeting/app/models/meeting.rb
+++ b/modules/meeting/app/models/meeting.rb
@@ -85,6 +85,10 @@ class Meeting < ApplicationRecord
.merge(Project.allowed_to(args.first || User.current, :view_meetings))
}
+ scope :participated_by, ->(user) {
+ joins(:participants).where(meeting_participants: { user_id: user.id })
+ }
+
acts_as_attachable(
after_remove: :attachments_changed,
order: "#{Attachment.table_name}.file",
diff --git a/modules/meeting/app/models/recurring_meeting.rb b/modules/meeting/app/models/recurring_meeting.rb
index d552f401fed..1fa158e6f84 100644
--- a/modules/meeting/app/models/recurring_meeting.rb
+++ b/modules/meeting/app/models/recurring_meeting.rb
@@ -99,6 +99,10 @@ class RecurringMeeting < ApplicationRecord
.merge(Project.allowed_to(args.first || User.current, :view_meetings))
}
+ scope :participated_by, ->(user) {
+ left_outer_joins(template: :participants).where(participants: { user_id: user.id })
+ }
+
# Virtual attributes that can be passed on to the template on save
virtual_attribute :location do
nil
diff --git a/modules/meeting/app/services/all_meetings/ical_service.rb b/modules/meeting/app/services/all_meetings/ical_service.rb
index 48daae907c6..915bd8b9b33 100644
--- a/modules/meeting/app/services/all_meetings/ical_service.rb
+++ b/modules/meeting/app/services/all_meetings/ical_service.rb
@@ -61,14 +61,14 @@ module AllMeetings
private
def recurring_meetings
- @recurring_meetings ||= RecurringMeeting.visible(user)
+ @recurring_meetings ||= RecurringMeeting.visible(user).participated_by(user)
end
def single_meetings
@single_meetings ||= if include_historic
- Meeting.not_recurring.visible(user)
+ Meeting.not_recurring.visible(user).articipated_by(user)
else
- Meeting.not_recurring.from_today.visible(user)
+ Meeting.not_recurring.from_today.visible(user).participated_by(user)
end
end
end