From 4ba81fd24250b38c9a59f090c2b7aca903b5ea31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 13 Mar 2024 12:30:14 +0100 Subject: [PATCH] Allow previewing on meeting contents --- lib/api/v3/render/render_api.rb | 2 +- modules/meeting/app/models/meeting_content.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/api/v3/render/render_api.rb b/lib/api/v3/render/render_api.rb index 1e7f8a7835ef..e295fb3ed1ca 100644 --- a/lib/api/v3/render/render_api.rb +++ b/lib/api/v3/render/render_api.rb @@ -35,7 +35,7 @@ class RenderAPI < ::API::OpenProjectAPI resources :render do helpers do - SUPPORTED_CONTEXT_NAMESPACES ||= %w(work_packages projects news posts wiki_pages).freeze + SUPPORTED_CONTEXT_NAMESPACES ||= %w(work_packages projects news posts wiki_pages meeting_contents).freeze SUPPORTED_MEDIA_TYPE ||= 'text/plain'.freeze def allowed_content_types diff --git a/modules/meeting/app/models/meeting_content.rb b/modules/meeting/app/models/meeting_content.rb index 441535ee7b51..17438e44cc5d 100644 --- a/modules/meeting/app/models/meeting_content.rb +++ b/modules/meeting/app/models/meeting_content.rb @@ -50,6 +50,12 @@ class MeetingContent < ApplicationRecord title: Proc.new { |o| "#{o.class.model_name.human}: #{o.meeting.title}" }, url: Proc.new { |o| { controller: '/meetings', action: 'show', id: o.meeting } } + scope :visible, ->(*args) { + includes(meeting: :project) + .references(:projects) + .merge(Project.allowed_to(args.first || User.current, :view_meetings)) + } + def editable? true end