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
addjust sql to get actions from anonymous user
Dmitrii52ff9eeeb890
diff --git a/app/models/capabilities/scopes/default.rb b/app/models/capabilities/scopes/default.rbindex ad3a7c4f970..76689cb2c20 100644--- a/app/models/capabilities/scopes/default.rb+++ b/app/models/capabilities/scopes/default.rb@@ -40,10 +40,13 @@ module Capabilities::ScopesUNION#{default_sql_by_non_member}UNION+ #{default_sql_by_non_member_with_anonymous}+ UNION#{default_sql_by_admin}) capabilitiesSQL+ # binding.pryselect('capabilities.*').from(capabilities_sql)end@@ -117,6 +120,32 @@ module Capabilities::ScopesWHERE enabled_modules.project_id IS NOT NULL OR "actions".module IS NULLSQLend++ def default_sql_by_non_member_with_anonymous+ <<~SQL.squish+ SELECT DISTINCT+ actions.id "action",+ users.id principal_id,+ projects.id context_id+ FROM (#{Action.default.to_sql}) actions+ JOIN "role_permissions" ON "role_permissions"."permission" = "actions"."permission"+ JOIN "roles" ON "roles".id = "role_permissions".role_id AND roles.builtin = #{Role::BUILTIN_ANONYMOUS}+ JOIN (#{Principal.visible.not_builtin_without_anonymous.not_locked_without_anonymous.to_sql}) users+ ON 1 = 1+ JOIN "projects"+ ON "projects".active = true+ AND ("projects".public = true OR EXISTS (SELECT 1+ FROM members+ WHERE members.project_id = projects.id+ AND members.user_id = users.id+ LIMIT 1))+ LEFT OUTER JOIN enabled_modules+ ON enabled_modules.project_id = projects.id+ AND actions.module = enabled_modules.name++ WHERE enabled_modules.project_id IS NOT NULL OR "actions".module IS NULL+ SQL+ endendendenddiff --git a/app/models/principals/scopes/not_builtin.rb b/app/models/principals/scopes/not_builtin.rbindex aeafd8f22c5..bed6a86e387 100644--- a/app/models/principals/scopes/not_builtin.rb+++ b/app/models/principals/scopes/not_builtin.rb@@ -42,6 +42,11 @@ module Principals::ScopesAnonymousUser.name,DeletedUser.name])end++ def not_builtin_without_anonymous+ where.not(type: [SystemUser.name,+ DeletedUser.name])+ endendendenddiff --git a/app/models/principals/scopes/status.rb b/app/models/principals/scopes/status.rbindex f04f9e083d5..bcf2545174c 100644--- a/app/models/principals/scopes/status.rb+++ b/app/models/principals/scopes/status.rb@@ -45,6 +45,10 @@ module Principals::Scopesnot_builtin.where.not(status: val)endend++ def self.not_locked_without_anonymous+ not_builtin_without_anonymous.where.not(status: :locked)+ endendendenddiff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.tsindex 6900966d9cf..9bf5f045fcd 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts@@ -33,7 +33,6 @@ import {} from '@angular/core';import {combineLatest,- merge,Observable,} from 'rxjs';import {@@ -89,12 +88,7 @@ export class WorkPackageFilesTabComponent implements OnInit {return;}- // ToDo: Needs to be fixed after capabilities are available for anonymous user.- // https://community.openproject.org/projects/openproject/work_packages/44850/activity- const canViewFileLinks = merge(- this.currentUserService.isLoggedIn$.pipe(map((isLoggedIn) => !isLoggedIn)),- this.currentUserService.hasCapabilities$('file_links/view', project.id),- );+ const canViewFileLinks = this.currentUserService.hasCapabilities$('file_links/view', project.id);this.storages$ = this.storagesResourceServicediff --git a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.tsindex 5db8439e8f1..a9c39ec2396 100644--- a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts+++ b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts@@ -186,8 +186,6 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit}private instantiateStorageInformation(fileLinks:IFileLink[]):StorageInformationBox[] {- // ToDo: Replace with anonymous user capabilities check.- // https://community.openproject.org/projects/openproject/work_packages/44850/activityif (!this.isLoggedIn) {return [];}