From 09a139279dc63ac4e9f1ad4724e88b5270c3784a Mon Sep 17 00:00:00 2001 From: Frank Rousseau Date: Wed, 4 Sep 2024 17:41:57 +0200 Subject: [PATCH 1/3] [projects] Fix deletion with descriptor linked to departments --- zou/app/services/deletion_service.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zou/app/services/deletion_service.py b/zou/app/services/deletion_service.py index 9560f7b235..bafeb06b27 100644 --- a/zou/app/services/deletion_service.py +++ b/zou/app/services/deletion_service.py @@ -362,6 +362,11 @@ def remove_project(project_id): ApiEvent.delete_all_by(project_id=project_id) Entity.delete_all_by(project_id=project_id) + + descriptors = MetadataDescriptor.query.filter_by(project_id=project_id) + for descriptor in descriptors: + descriptor.departments = [] + descriptor.save() MetadataDescriptor.delete_all_by(project_id=project_id) Milestone.delete_all_by(project_id=project_id) ScheduleItem.delete_all_by(project_id=project_id) From 0385b5ca6acd726f3610b152d9fe8a3e992d8f91 Mon Sep 17 00:00:00 2001 From: Frank Rousseau Date: Thu, 5 Sep 2024 10:54:06 +0200 Subject: [PATCH 2/3] [assets] Do not allow asset type duplicates --- zou/app/blueprints/crud/entity_type.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zou/app/blueprints/crud/entity_type.py b/zou/app/blueprints/crud/entity_type.py index 20e7afad29..235db77eba 100644 --- a/zou/app/blueprints/crud/entity_type.py +++ b/zou/app/blueprints/crud/entity_type.py @@ -4,6 +4,9 @@ from zou.app.utils import events from zou.app.services import entities_service, assets_service +from zou.app.services.exception import WrongParameterException + + class EntityTypesResource(BaseModelsResource): def __init__(self): @@ -28,6 +31,18 @@ def post_creation(self, instance): assets_service.clear_asset_type_cache() return instance.serialize(relations=True) + def check_creation_integrity(self, data): + entity_type = ( + EntityType.query + .filter(EntityType.name.ilike(data.get("name", ""))) + .first() + ) + if entity_type is not None: + raise WrongParameterException( + "Entity type with this name already exists" + ) + return data + class EntityTypeResource(BaseModelResource): def __init__(self): From 45bc80d5f0ee71ee835cc28e8bff22c85d5c82e9 Mon Sep 17 00:00:00 2001 From: Frank Rousseau Date: Thu, 5 Sep 2024 23:29:13 +0200 Subject: [PATCH 3/3] [qa] Remove curl exemple to comply to bump.sh restrictions --- zou/app/swagger.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/zou/app/swagger.py b/zou/app/swagger.py index 9fd0430fcc..4374d8254a 100644 --- a/zou/app/swagger.py +++ b/zou/app/swagger.py @@ -30,21 +30,13 @@

Before you can use any of the endpoints outline below, you will have to get a JWT token to authorize your requests. +

-You can get a authorization token using a (form-encoded) POST request to ```/auth/login```. -With curl this would look something like ```curl -X POST /auth/login -d "email=&password=```. +

+You will find the information to retrieve it in the +Zou documentation. +

-The response is a JSON object, specifically you'll need to provide the ```access_token``` for your future requests. - -Here is a complete authentication process as an example (again using curl): -``` -$ curl -X POST /api/auth/login -d "email=&password="' -{{"login": true", "access_token": "eyJ0e...", ...}} -$ jwt=eyJ0e... # Store the access token for easier use -$ curl -H "Authorization: Bearer $jwt" /api/data/projects -[{{...}}, -{{...}}] -``` [OpenAPI definition](/openapi.json) """