Skip to content

Commit

Permalink
Merge pull request #1457 from ScilifelabDataCentre/dev
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
i-oden authored Aug 28, 2023
2 parents 774b7a5 + abb196e commit d686af2
Show file tree
Hide file tree
Showing 31 changed files with 1,292 additions and 290 deletions.
19 changes: 17 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
Changelog
==========

.. _2.3.1:
.. _2.5.0:

2.3.1 - 2023-07-05
version 2.5.0 - 2023-08-30
~~~~~~~~~~~~~~~~~~~~~~~~

- Dependencies:
- `cryptography` from `39.0.1` to `41.0.3`
- `certifi` from `2022.12.07` to `2023.07.22`
- _New_ project buckets will be created at a new storage location if Unit information has been updated with storage keys and information.
- Bug fixed: Listing projects via web interface works again
- Endpoint `ProjectBusy` is no longer usable; `dds-cli` versions prior to `2.2.0` will no longer work
- New endpoint `UnitUserEmails`: Super Admins can get primary emails for Unit Admins- and Personnel. This is for emailing purposes.
- Message about project being busy has been changed to a more accurate and understandable statement
- Documentation: Typo fixed in Technical Overview

.. _2.4.0:

2.4.0 - 2023-07-05
~~~~~~~~~~~~~~~~~~~

- Dependencies:
Expand Down
21 changes: 20 additions & 1 deletion SPRINTLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,26 @@ _Nothing merged in CLI during this sprint_
- Change from personal name to unit name if / where it's displayed in emails ([#1439](https://github.com/ScilifelabDataCentre/dds_web/pull/1439))
- Refactoring: `lost_files_s3_db` flask command changed to group with subcommands ([#1438](https://github.com/ScilifelabDataCentre/dds_web/pull/1438))

# 2023-06-26 - 2023-07-14
# 2023-06-26 - 2023-08-04 (Summer)

- Change display project info depending on the user role ([#1440](https://github.com/ScilifelabDataCentre/dds_web/pull/1440))
- New version: 2.4.0 ([#1443](https://github.com/ScilifelabDataCentre/dds_web/pull/1443))
- Bug fix: Web UI project listing fix ([#1445](https://github.com/ScilifelabDataCentre/dds_web/pull/1445))
- Documentation: Technical Overview, section Creating a Unit in the DDS ([#1449](https://github.com/ScilifelabDataCentre/dds_web/pull/1449))

# 2023-08-07 - 2023-08-18

- Empty endpoint: `ProjectBusy` ([#1446](https://github.com/ScilifelabDataCentre/dds_web/pull/1446))

# 2023-08-04 - 2023-08-18

- Rename storage-related columns in `Unit` table ([#1447](https://github.com/ScilifelabDataCentre/dds_web/pull/1447))
- Dependency: Bump `cryptography` to 41.0.3 due to security vulnerability alerts(s) ([#1451](https://github.com/ScilifelabDataCentre/dds_web/pull/1451))
- Allow for change of storage location ([#1448](https://github.com/ScilifelabDataCentre/dds_web/pull/1448))
- Endpoint: `UnitUserEmails`; Return primary emails for Unit Personnel- and Admins ([#1454](https://github.com/ScilifelabDataCentre/dds_web/pull/1454))
- Change message about project being busy with upload etc ([#1450](https://github.com/ScilifelabDataCentre/dds_web/pull/1450))

# 2023-08-21 - 2023-09-01

- Dependency: Bump `certifi` to 2023.07.22 due to security vulnerability alert(s) ([#1452](https://github.com/ScilifelabDataCentre/dds_web/pull/1452))
- New version: 2.5.0 ([#1458](https://github.com/ScilifelabDataCentre/dds_web/pull/1458))
2 changes: 2 additions & 0 deletions dds_web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,13 @@ def load_user(user_id):
quarterly_usage,
collect_stats,
monitor_usage,
update_unit,
)

# Add flask commands - general
app.cli.add_command(fill_db_wrapper)
app.cli.add_command(create_new_unit)
app.cli.add_command(update_unit)
app.cli.add_command(update_uploaded_file_with_log)
app.cli.add_command(lost_files_s3_db)

Expand Down
1 change: 1 addition & 0 deletions dds_web/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def output_json(data, code, headers=None):
)
api.add_resource(superadmin_only.AnyProjectsBusy, "/proj/busy/any", endpoint="projects_busy_any")
api.add_resource(superadmin_only.Statistics, "/stats", endpoint="stats")
api.add_resource(superadmin_only.UnitUserEmails, "/user/emails", endpoint="user_emails")

# Invoicing ############################################################################ Invoicing #
api.add_resource(user.ShowUsage, "/usage", endpoint="usage")
16 changes: 11 additions & 5 deletions dds_web/api/api_s3_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
)

from dds_web.database import models
import dds_web.utils


####################################################################################################
Expand Down Expand Up @@ -51,14 +52,19 @@ def __exit__(self, exc_type, exc_value, tb):
return True

def get_s3_info(self):
"""Get information required to connect to cloud."""
"""Get information required to connect to cloud storage."""
# Check if to use sto4
use_sto4 = dds_web.utils.use_sto4(
unit_object=self.project.responsible_unit, project_object=self.project
)

endpoint, name, accesskey, secretkey = (
models.Unit.query.filter_by(id=self.project.responsible_unit.id)
.with_entities(
models.Unit.safespring_endpoint,
models.Unit.safespring_name,
models.Unit.safespring_access,
models.Unit.safespring_secret,
models.Unit.sto4_endpoint if use_sto4 else models.Unit.sto2_endpoint,
models.Unit.sto4_name if use_sto4 else models.Unit.sto2_name,
models.Unit.sto4_access if use_sto4 else models.Unit.sto2_access,
models.Unit.sto4_secret if use_sto4 else models.Unit.sto2_secret,
)
.one_or_none()
)
Expand Down
57 changes: 18 additions & 39 deletions dds_web/api/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
ProjectBusyError,
S3ConnectionError,
NoSuchUserError,
VersionMismatchError,
)
from dds_web.api.user import AddUser
from dds_web.api.schemas import project_schemas, user_schemas
Expand Down Expand Up @@ -94,7 +95,7 @@ def post(self):
if project.busy:
raise ProjectBusyError(
message=(
f"The project '{project_id}' is currently busy with upload/download/deletion. "
f"The status for the project '{project_id}' is already in the process of being changed. "
"Please try again later. \n\nIf you know the project is not busy, contact support."
)
)
Expand Down Expand Up @@ -144,8 +145,11 @@ def post(self):

try:
project.project_statuses.append(new_status_row)
project.busy = False
project.busy = False # TODO: Use set_busy instead?
db.session.commit()
flask.current_app.logger.info(
f"Busy status set. Project: '{project.public_id}', Busy: False"
)
except (sqlalchemy.exc.OperationalError, sqlalchemy.exc.SQLAlchemyError) as err:
flask.current_app.logger.exception(err)
db.session.rollback()
Expand Down Expand Up @@ -489,7 +493,7 @@ def format_project_dict(self, current_user):
user_projects = models.Project.query.filter(sqlalchemy.and_(*all_filters)).all()

researcher = False
if auth.current_user().role not in ["Super Admin", "Unit Admin", "Unit Personnel"]:
if current_user.role not in ["Super Admin", "Unit Admin", "Unit Personnel"]:
researcher = True

# Get info for all projects
Expand Down Expand Up @@ -922,45 +926,20 @@ def give_project_access(project_list, current_user, user):


class ProjectBusy(flask_restful.Resource):
@auth.login_required(role=["Unit Admin", "Unit Personnel", "Project Owner", "Researcher"])
@auth.login_required
@logging_bind_request
@dbsession
@json_required
def put(self):
"""Set project to busy / not busy."""
# Get project ID, project and verify access
project_id = dds_web.utils.get_required_item(obj=flask.request.args, req="project")
project = dds_web.utils.collect_project(project_id=project_id)
dds_web.utils.verify_project_access(project=project)
"""OLD ENDPOINT.
Previously set project status to busy.
# Get busy or not busy
request_json = flask.request.get_json(silent=True)
set_to_busy = request_json.get("busy") # Already checked by json_required
if set_to_busy is None:
raise DDSArgumentError(message="Missing information about setting busy or not busy.")

if set_to_busy:
# Check if project is busy
if project.busy:
return {"ok": False, "message": "The project is already busy, cannot proceed."}

# Set project as busy
project.busy = True
else:
# Check if project is not busy
if not project.busy:
return {
"ok": False,
"message": "The project is already not busy, cannot proceed.",
}

# Set project to not busy
project.busy = False

return {
"ok": True,
"message": f"Project {project_id} was set to {'busy' if set_to_busy else 'not busy'}.",
}
TODO: Can remove from 2024. Will otherwise cause breaking changes for old CLI versions.
"""
raise VersionMismatchError(
message=(
"Your CLI version is trying to use functionality which is no longer in use. "
"Upgrade your version to the latest one and run your command again."
)
)


class ProjectInfo(flask_restful.Resource):
Expand Down
22 changes: 21 additions & 1 deletion dds_web/api/superadmin_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get(self):
"Public ID": u.public_id,
"External Display Name": u.external_display_name,
"Contact Email": u.contact_email,
"Safespring Endpoint": u.safespring_endpoint,
"Safespring Endpoint": u.sto2_endpoint,
"Days In Available": u.days_in_available,
"Days In Expired": u.days_in_expired,
"Size": u.size,
Expand Down Expand Up @@ -345,3 +345,23 @@ def get(self):
if stat_rows
]
}


class UnitUserEmails(flask_restful.Resource):
"""Get emails for Unit Admins and Unit Personnel."""

@auth.login_required(role=["Super Admin"])
@logging_bind_request
@handle_db_error
def get(self):
"""Collect the user emails and return a list."""
# Get all emails connected to a Unit Admin or Personnel account
user_emails = [user.primary_email for user in models.UnitUser.query.all()]

# Return empty if no emails
if not user_emails:
flask.current_app.logger.info("There are no primary emails to return.")
return {"empty": True}

# Return emails
return {"emails": user_emails}
Loading

0 comments on commit d686af2

Please sign in to comment.