Skip to content

Commit

Permalink
Merge pull request #843 from EvanBldy/master
Browse files Browse the repository at this point in the history
various improvements
  • Loading branch information
EvanBldy authored Aug 23, 2024
2 parents b64e939 + 28406fd commit f0b0801
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ install_requires =
sqlalchemy_utils==0.41.2
sqlalchemy==2.0.32
ua-parser==0.18.0
werkzeug==3.0.3
werkzeug==3.0.4

[options.package_data]
* = app/file_trees/*.json,migrations/*,migrations/versions/*.py
Expand Down
24 changes: 24 additions & 0 deletions zou/app/blueprints/crud/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
EntityVersion,
EntityLink,
EntityConceptLink,
ENTITY_STATUSES,
)
from zou.app.models.project import Project
from zou.app.models.subscription import Subscription
Expand All @@ -27,6 +28,8 @@
)
from zou.app.utils import date_helpers, events, permissions

from zou.app.services.exception import ArgumentsException

from werkzeug.exceptions import NotFound

from zou.app.blueprints.crud.base import BaseModelResource, BaseModelsResource
Expand Down Expand Up @@ -78,6 +81,16 @@ def update_data(self, data):
data["created_by"] = persons_service.get_current_user()["id"]
return data

def check_creation_integrity(self, data):
"""
Check if entity has a valid status.
"""
if "status" in data:
types = [entity_status for entity_status, _ in ENTITY_STATUSES]
if data["status"] not in types:
raise ArgumentsException("Invalid status")
return True

def all_entries(self, query=None, relations=False):
entities = BaseModelsResource.all_entries(
self, query=query, relations=relations
Expand Down Expand Up @@ -233,3 +246,14 @@ def post_delete(self, entity_dict):
index_service.remove_asset_index(entity_dict["id"])
elif shots_service.is_shot(entity_dict):
index_service.remove_shot_index(entity_dict["id"])

def update_data(self, data, instance_id):
"""
Check if the entity has a valid status.
"""
data = super().update_data(data, instance_id)
if "status" in data:
types = [entity_status for entity_status, _ in ENTITY_STATUSES]
if data["status"] not in types:
raise ArgumentsException("Invalid status")
return data

0 comments on commit f0b0801

Please sign in to comment.