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): 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) 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) """