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

AddUser: Specific error message for unit users #1039

Merged
merged 2 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ Please add a _short_ line describing the PR you make, if the PR implements a spe
- Introduced an additional validator `dds_web.utils.contains_disallowed_characters` to fix issue [#1007](https://github.com/scilifelabdatacentre/dds_web/issues/1007) ([#1021](https://github.com/ScilifelabDataCentre/dds_web/pull/1021)).
- Fix regex for listing and deleting files [#1029](https://github.com/scilifelabdatacentre/dds_web/issues/1029)
- Hides the "Size" and "total_size" variables according to the role and project status ([#1032](https://github.com/ScilifelabDataCentre/dds_web/pull/1032)).

## Sprint (2022-03-09 - 2022-03-23)

- Introduce a separate error message if someone tried to add an unit user to projects individually. ([#1039](https://github.com/ScilifelabDataCentre/dds_web/pull/1039))
10 changes: 9 additions & 1 deletion dds_web/api/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def add_to_project(whom, project, role, send_email=True):

allowed_roles = ["Project Owner", "Researcher"]

if role not in allowed_roles or whom.role not in allowed_roles:
if role not in allowed_roles:
return {
"status": ddserr.AccessDeniedError.code.value,
"message": (
Expand All @@ -276,6 +276,14 @@ def add_to_project(whom, project, role, send_email=True):
),
}

if whom.role not in allowed_roles:
return {
"status": ddserr.AccessDeniedError.code.value,
"message": (
"Users affiliated with units can not be added to projects individually."
),
}

is_owner = role == "Project Owner"
ownership_change = False

Expand Down