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

Change message when project is busy #1450

Merged
merged 15 commits into from
Aug 21, 2023
1 change: 1 addition & 0 deletions SPRINTLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,4 @@ _Nothing merged in CLI during this sprint_
- 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))
7 changes: 5 additions & 2 deletions dds_web/api/project.py
i-oden marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -95,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 @@ -145,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
5 changes: 4 additions & 1 deletion tests/api/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ def test_projectstatus_when_busy(module_client):
json={"something": "something"},
)
assert response.status_code == http.HTTPStatus.BAD_REQUEST
assert f"The project '{project.public_id}' is currently busy" in response.json.get("message")
assert (
f"The status for the project '{project.public_id}' is already in the process of being changed."
in response.json.get("message")
)


def test_projectstatus_when_not_busy_but_invalid(module_client):
Expand Down