fix(roles): Return conflict if role should be deleted but is still in use

This commit is contained in:
Ferdinand Thiessen 2021-12-05 20:50:57 +01:00
parent bac75ca582
commit 5b3f63cd0a
2 changed files with 3 additions and 3 deletions

View File

@ -1,5 +1,5 @@
from sqlalchemy.exc import IntegrityError
from werkzeug.exceptions import BadRequest, NotFound
from werkzeug.exceptions import BadRequest, Conflict, NotFound
from flaschengeist.models.user import Role, Permission
from flaschengeist.database import db, case_sensitive
@ -71,4 +71,4 @@ def delete(role):
db.session.commit()
except IntegrityError:
logger.debug("IntegrityError: Role might still be in use", exc_info=True)
raise BadRequest("Role still in use")
raise Conflict("Role still in use")

View File

@ -134,7 +134,7 @@ def delete_role(role_id, current_session):
current_session: Session sent with Authorization Header
Returns:
HTTP-204 or HTTP error
HTTP-204 or HTTP error (HTTP-409 Conflict if role still in use)
"""
role = roleController.get(role_id)
roleController.delete(role)