fix(roles): Return conflict if role should be deleted but is still in use
This commit is contained in:
		
							parent
							
								
									bac75ca582
								
							
						
					
					
						commit
						5b3f63cd0a
					
				|  | @ -1,5 +1,5 @@ | ||||||
| from sqlalchemy.exc import IntegrityError | 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.models.user import Role, Permission | ||||||
| from flaschengeist.database import db, case_sensitive | from flaschengeist.database import db, case_sensitive | ||||||
|  | @ -71,4 +71,4 @@ def delete(role): | ||||||
|         db.session.commit() |         db.session.commit() | ||||||
|     except IntegrityError: |     except IntegrityError: | ||||||
|         logger.debug("IntegrityError: Role might still be in use", exc_info=True) |         logger.debug("IntegrityError: Role might still be in use", exc_info=True) | ||||||
|         raise BadRequest("Role still in use") |         raise Conflict("Role still in use") | ||||||
|  |  | ||||||
|  | @ -134,7 +134,7 @@ def delete_role(role_id, current_session): | ||||||
|         current_session: Session sent with Authorization Header |         current_session: Session sent with Authorization Header | ||||||
| 
 | 
 | ||||||
|     Returns: |     Returns: | ||||||
|         HTTP-204 or HTTP error |         HTTP-204 or HTTP error (HTTP-409 Conflict if role still in use) | ||||||
|     """ |     """ | ||||||
|     role = roleController.get(role_id) |     role = roleController.get(role_id) | ||||||
|     roleController.delete(role) |     roleController.delete(role) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue