Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(4032) - 4156 - Refactor Atlantis countries usage #4163

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
4156 - country_user_summary exclude atlantis roles in published cycles
  • Loading branch information
sorja committed Nov 29, 2024
commit 3c174d3ea0d21d46809c05e6c38d0220f9dad6f9
21 changes: 18 additions & 3 deletions src/server/repository/assessment/assessment/getCreateSchemaDDL.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Areas } from 'meta/area'
import { Assessment, Cycle } from 'meta/assessment'

import { Schemas } from 'server/db'
Expand Down Expand Up @@ -357,9 +358,23 @@ export const getCreateOrReplaceViewCountryUserSummary = (props: { assessment: As
ur.uuid,
to_jsonb(ur.*) as role
from users_role ur
where (ur.cycle_uuid = '${cycle.uuid}' and
ur.assessment_uuid = '${assessment.uuid}')
or ur.role = 'ADMINISTRATOR'
where (
Copy link
Contributor Author

@sorja sorja Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update country user summaries to exclude atlantis roles for published cycles to avoid mismatch in logic
(E.g. FRA2020 -> Admin -> Collaborators: show atlantis country role for user, go to edit user as admin, the role is not visible because we don't allow atlantis countries in published cycles)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't want Atlantis to show up only in public view .
Users with roles should

-- 1. Allow admin roles
ur.role = 'ADMINISTRATOR'
-- 2. Allow regular roles
or (
ur.cycle_uuid = '${cycle.uuid}' and ur.assessment_uuid = '${assessment.uuid}'
and (
-- Allow non-Atlantis roles always
ur.country_iso not like '${Areas.ATLANTIS_PREFIX}%'
or (
-- Allow Atlantis roles only if cycle is not published
ur.country_iso like '${Areas.ATLANTIS_PREFIX}%'
and '${cycle.props?.status}' != 'published'
)
)
)
)
),
filtered_invitations as (
select
Expand Down