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

Merge branch 'dev' into replace-remaining-allowed-calls

Klaus Zandersba7f27c9f56a
diff --cc app/models/users/permission_checks.rb
index 65b1b6afd9c,476104125bc..8be654c8b93
--- a/app/models/users/permission_checks.rb
+++ b/app/models/users/permission_checks.rb
@@@ -95,30 -95,7 +95,29 @@@ module Users::PermissionCheck
.uniq
end
+ # Helper method to be used in places where we just throw anything into the permission check and don't know what
+ # context it should be checked on. Things like menu item checks, controller action checks, generic services, etc.
+ def allowed_based_on_permission_context?(permission, project: nil, entity: nil) # rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize
+ permissions = Authorization.permissions_for(permission, raise_on_unknown: true)
+
+ permissions.any? do |perm|
+ if perm.global?
+ allowed_globally?(perm)
+ elsif perm.work_package? && entity.is_a?(WorkPackage)
+ allowed_in_work_package?(perm, entity)
+ elsif perm.project? && project
+ allowed_in_project?(perm, project)
+ elsif perm.project? && entity && entity.respond_to?(:project)
+ allowed_in_project?(perm, entity.project)
+ elsif perm.project? && entity.nil? && project.nil?
+ allowed_in_any_project?(perm)
+ else
+ false
+ end
+ end
+ end
+
# Old allowed_to? interface. Marked as deprecated, should be removed at some point ... Guessing 14.0?
-
def allowed_to?(action, context, global: false)
# OpenProject::Deprecation.deprecate_method(User, :allowed_to?)
user_allowed_service.call(action, context, global:)
diff --cc config/locales/en.yml
index 5b1f2f4a17d,696a91a61f3..c47901294b1
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@@ -2296,40 -2262,42 +2297,41 @@@ en
mention:
subject: "%{user_name} mentioned you in #%{id} - %{subject}"
notification:
- center: "To notification center"
- see_in_center: "See comment in notification center"
- settings: "Change email settings"
- salutation: "Hello %{user}"
+ center: 'To notification center'
+ see_in_center: 'See comment in notification center'
+ settings: 'Change email settings'
+ salutation: 'Hello %{user}'
+ salutation_full_name: 'Full name'
work_packages:
- created_at: 'Created at %{timestamp} by %{user} '
- login_to_see_all: 'Log in to see all notifications.'
- mentioned: 'You have been <b>mentioned in a comment</b>'
- mentioned_by: '%{user} mentioned you in a comment'
+ created_at: "Created at %{timestamp} by %{user} "
+ login_to_see_all: "Log in to see all notifications."
+ mentioned: "You have been <b>mentioned in a comment</b>"
+ mentioned_by: "%{user} mentioned you in a comment"
more_to_see:
- one: 'There is 1 more work package with notifications.'
- other: 'There are %{count} more work packages with notifications.'
- open_in_browser: 'Open in browser'
+ one: "There is 1 more work package with notifications."
+ other: "There are %{count} more work packages with notifications."
+ open_in_browser: "Open in browser"
reason:
- watched: 'Watched'
- assigned: 'Assigned'
- responsible: 'Accountable'
- mentioned: 'Mentioned'
- shared: 'Shared'
- subscribed: 'all'
- prefix: 'Received because of the notification setting: %{reason}'
- date_alert_start_date: 'Date alert'
- date_alert_due_date: 'Date alert'
- see_all: 'See all'
- updated_at: 'Updated at %{timestamp} by %{user}'
+ watched: "Watched"
+ assigned: "Assigned"
+ responsible: "Accountable"
+ mentioned: "Mentioned"
+ shared: "Shared"
+ subscribed: "all"
+ prefix: "Received because of the notification setting: %{reason}"
+ date_alert_start_date: "Date alert"
+ date_alert_due_date: "Date alert"
+ see_all: "See all"
+ updated_at: "Updated at %{timestamp} by %{user}"
sharing:
work_packages:
- allowed_actions: 'You may %{allowed_actions} this work package. This can change depending on your project role and permissions.'
- create_account: 'To access this work package you will need to create an %{instance} account. '
- open_work_package: 'Open work package'
- subject: 'You have been shared work package #%{id}'
+ allowed_actions: "You may %{allowed_actions} this work package. This can change depending on your project role and permissions."
+ create_account: "To access this work package you will need to create an %{instance} account. "
+ open_work_package: "Open work package"
+ subject: "You have been shared work package #%{id}"
summary:
- user: '%{user} shared a work package with you with %{role_rights} rights'
- group: '%{user} shared a work package with the group %{group} you are a member of'
-
+ user: "%{user} shared a work package with you with %{role_rights} rights"
+ group: "%{user} shared a work package with the group %{group} you are a member of"
mail_body_account_activation_request: "A new user (%{value}) has registered. The account is pending your approval:"
mail_body_account_information: "Your account information"