Skip to content

Commit

Permalink
Merge branch 'dev' into add_link
Browse files Browse the repository at this point in the history
  • Loading branch information
i-oden authored Feb 28, 2022
2 parents a28a7e0 + d0efbf9 commit af4767e
Show file tree
Hide file tree
Showing 8 changed files with 274 additions and 6 deletions.
242 changes: 242 additions & 0 deletions ADR.md

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Please add a _short_ line describing the PR you make, if the PR implements a spe
* Rearrangement and clean up of the token ([910](https://github.com/ScilifelabDataCentre/dds_web/pull/910))

## Sprint (2022-02-23 - 2022-03-09)
* Add landing page after password reset ([931](https://github.com/ScilifelabDataCentre/dds_web/pull/931))
* Add endpoint for health check (intended for readinessProbe) ([933](https://github.com/ScilifelabDataCentre/dds_web/pull/933))
* Introduced a `--no-mail` flag in the CLI respectively a `send_email: True/False` json parameter to fix [issue 924](https://github.com/scilifelabdatacentre/dds_web/issues/924) ([#926](https://github.com/ScilifelabDataCentre/dds_web/pull/926))
* Add landing page after password reset ([#931](https://github.com/ScilifelabDataCentre/dds_web/pull/931))
* Add endpoint for health check (intended for readinessProbe) ([#933](https://github.com/ScilifelabDataCentre/dds_web/pull/933))
* Introduced a `--no-mail` flag in the CLI respectively a `send_email: True/False` json parameter to fix [#924](https://github.com/scilifelabdatacentre/dds_web/issues/924) ([#926](https://github.com/ScilifelabDataCentre/dds_web/pull/926))
* Invite Unit Admin (temporary way) ([#938](https://github.com/ScilifelabDataCentre/dds_web/pull/938))
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ and/or projects resulting in the production of large amounts of data, e.g. seque

The backend interface is built using [Flask](https://flask.palletsprojects.com/en/2.0.x/).

See the [ADR] for information on the design decisions.

---
## Development
<br>
Expand Down
2 changes: 1 addition & 1 deletion dds_web/api/schemas/project_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def return_items(self, data, **kwargs):
# Check if project has contents
project_row = verify_project_exists(spec_proj=data.get("project"))
if not project_row.files:
raise ddserr.EmptyProjectException
raise ddserr.EmptyProjectException(project=project_row.public_id)

# Check if specific files have been requested or if requested all contents
files, folder_contents, not_found = (None, None, None)
Expand Down
20 changes: 18 additions & 2 deletions dds_web/api/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def post(self):
if not dds_web.utils.valid_user_role(specified_role=role):
raise ddserr.DDSArgumentError(message="Invalid user role.")

# Unit only changable for Super Admin invites
unit = json_info.get("unit") if auth.current_user().role == "Super Admin" else None

# A project may or may not be specified
project = args.get("project") if args else None
if project:
Expand Down Expand Up @@ -99,13 +102,15 @@ def post(self):

else:
# Send invite if the user doesn't exist
invite_user_result = self.invite_user(email=email, new_user_role=role, project=project)
invite_user_result = self.invite_user(
email=email, new_user_role=role, project=project, unit=unit
)

return invite_user_result, invite_user_result["status"]

@staticmethod
@logging_bind_request
def invite_user(email, new_user_role, project=None):
def invite_user(email, new_user_role, project=None, unit=None):
"""Invite a new user"""

current_user_role = get_user_roles_common(user=auth.current_user())
Expand Down Expand Up @@ -193,6 +198,17 @@ def invite_user(email, new_user_role, project=None):

# Append invite to unit if applicable
if new_invite.role in ["Unit Admin", "Unit Personnel"]:
# TODO Change / move this later. This is just so that we can add an initial unit admin.
if auth.current_user().role == "Super Admin":
if unit:
unit_row = models.Unit.query.filter_by(public_id=unit).one_or_none()
if not unit_row:
raise ddserr.DDSArgumentError(message="Invalid unit publid id.")

unit_row.invites.append(new_invite)
else:
raise ddserr.DDSArgumentError(message="Cannot invite this user.")

if "Unit" in auth.current_user().role:
# Give new unit user access to all projects of the unit
auth.current_user().unit.invites.append(new_invite)
Expand Down
6 changes: 6 additions & 0 deletions dds_web/development/db_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def fill_db():

password = "password"

# Super Admin
superadmin = models.SuperAdmin(username="superadmin", password=password, name="Super Admin")
superadmin_email = models.Email(email="[email protected]", primary=True)
superadmin_email.user = superadmin
db.session.add(superadmin_email)

# Create first unit user
unituser_1 = models.UnitUser(
username="unituser_1",
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ services:
# - type: bind
# source: ./Dockerfiles/mariadb/mariadb.conf
# target: /etc/mysql/conf.d/encrypt.cnf

# # Keys
# - type: bind
# source: ./Dockerfiles/mariadb/db-encrypt
Expand Down
Binary file added img/zstandard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit af4767e

Please sign in to comment.