Skip to content

Commit

Permalink
Merge pull request #854 from frankrousseau/master
Browse files Browse the repository at this point in the history
Various fixes
  • Loading branch information
EvanBldy authored Sep 6, 2024
2 parents 8e55db1 + 45bc80d commit 4799727
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
15 changes: 15 additions & 0 deletions zou/app/blueprints/crud/entity_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
5 changes: 5 additions & 0 deletions zou/app/services/deletion_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 5 additions & 13 deletions zou/app/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,13 @@
<p>Before you can use any of the endpoints outline below,
you will have to get a JWT token to authorize your requests.
</p>
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 <server_address>/auth/login -d "email=<youremail>&password=<yourpassword>```.
<p>
You will find the information to retrieve it in the
<a href="#tag/Authentication">Zou documentation</a>.
</p>
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 <server_address>/api/auth/login -d "email=<youremail>&password=<yourpassword>"'
{{"login": true", "access_token": "eyJ0e...", ...}}
$ jwt=eyJ0e... # Store the access token for easier use
$ curl -H "Authorization: Bearer $jwt" <server_address>/api/data/projects
[{{...}},
{{...}}]
```
[OpenAPI definition](/openapi.json)
"""

Expand Down

0 comments on commit 4799727

Please sign in to comment.