diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-09 21:07:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-09 21:07:58 +0300 |
commit | b3986e06460cc2bff35c1c1e7902579b46c1d4c6 (patch) | |
tree | 3646975b83dd94a772a5a943ca1c5e7872646813 /app/models | |
parent | fa0535cda4c99da0ca078882c610fd3b3564f991 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/issue.rb | 39 | ||||
-rw-r--r-- | app/models/pages_deployment.rb | 7 | ||||
-rw-r--r-- | app/models/project.rb | 5 | ||||
-rw-r--r-- | app/models/project_pages_metadatum.rb | 1 |
4 files changed, 29 insertions, 23 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 89188870f0e..b207785021d 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -695,20 +695,14 @@ class Issue < ApplicationRecord # for performance reasons, check commit: 002ad215818450d2cbbc5fa065850a953dc7ada8 # Make sure to sync this method with issue_policy.rb def readable_by?(user) - if !project.issues_enabled? - false - elsif user.can_read_all_resources? - true - elsif project.personal? && project.team.owner?(user) + if user.can_read_all_resources? true - elsif confidential? && !assignee_or_author?(user) - project.member?(user, Gitlab::Access::REPORTER) elsif hidden? false - elsif project.public? || (project.internal? && !user.external?) - project.feature_available?(:issues, user) + elsif project + project_level_readable_by?(user) else - project.member?(user) + group_level_readable_by?(user) end end @@ -761,6 +755,31 @@ class Issue < ApplicationRecord private + def project_level_readable_by?(user) + if !project.issues_enabled? + false + elsif project.personal? && project.team.owner?(user) + true + elsif confidential? && !assignee_or_author?(user) + project.member?(user, Gitlab::Access::REPORTER) + elsif project.public? || (project.internal? && !user.external?) + project.feature_available?(:issues, user) + else + project.member?(user) + end + end + + def group_level_readable_by?(user) + # This should never happen as we don't support personal namespace level issues. Just additional safety. + return false unless namespace.is_a?(::Group) + + if confidential? && !assignee_or_author?(user) + namespace.member?(user, Gitlab::Access::REPORTER) + else + namespace.member?(user) + end + end + def due_date_after_start_date return unless start_date.present? && due_date.present? diff --git a/app/models/pages_deployment.rb b/app/models/pages_deployment.rb index ad7660b17f1..f05ed2aac6e 100644 --- a/app/models/pages_deployment.rb +++ b/app/models/pages_deployment.rb @@ -6,8 +6,6 @@ class PagesDeployment < ApplicationRecord include FileStoreMounter include Gitlab::Utils::StrongMemoize - MIGRATED_FILE_NAME = "_migrated.zip" - attribute :file_store, :integer, default: -> { ::Pages::DeploymentUploader.default_store } belongs_to :project, optional: false @@ -16,7 +14,6 @@ class PagesDeployment < ApplicationRecord belongs_to :ci_build, class_name: 'Ci::Build', optional: true scope :older_than, ->(id) { where('id < ?', id) } - scope :migrated_from_legacy_storage, -> { where(file: MIGRATED_FILE_NAME) } scope :with_files_stored_locally, -> { where(file_store: ::ObjectStorage::Store::LOCAL) } scope :with_files_stored_remotely, -> { where(file_store: ::ObjectStorage::Store::REMOTE) } scope :project_id_in, ->(ids) { where(project_id: ids) } @@ -44,10 +41,6 @@ class PagesDeployment < ApplicationRecord .update_all(updated_at: now, deleted_at: time || now) end - def migrated? - file.filename == MIGRATED_FILE_NAME - end - private def set_size diff --git a/app/models/project.rb b/app/models/project.rb index 55cdad1dd94..eb3a4f5f0b8 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2239,11 +2239,6 @@ class Project < ApplicationRecord pages_metadatum&.deployed? end - def pages_path - # TODO: when we migrate Pages to work with new storage types, change here to use disk_path - File.join(Settings.pages.path, full_path) - end - def pages_show_onboarding? !(pages_metadatum&.onboarding_complete || pages_metadatum&.deployed) end diff --git a/app/models/project_pages_metadatum.rb b/app/models/project_pages_metadatum.rb index 7a3ece4bc92..eca2e5a740e 100644 --- a/app/models/project_pages_metadatum.rb +++ b/app/models/project_pages_metadatum.rb @@ -12,6 +12,5 @@ class ProjectPagesMetadatum < ApplicationRecord belongs_to :pages_deployment scope :deployed, -> { where(deployed: true) } - scope :only_on_legacy_storage, -> { deployed.where(pages_deployment: nil) } scope :with_project_route_and_deployment, -> { preload(:pages_deployment, project: [:namespace, :route]) } end |