Skip to content

Commit 9ab53e4

Browse files
committed
Fixed import constraint
1 parent 5cbdaf1 commit 9ab53e4

File tree

6 files changed

+15
-31
lines changed

6 files changed

+15
-31
lines changed

source/app/blueprints/rest/manage/manage_customers_routes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from app.business.customers import customers_get
2929
from app.business.customers_contacts import customers_contacts_get
3030
from app.models.errors import ObjectNotFoundError
31+
from app.models.errors import ElementInUseError
3132
from app.datamgmt.client.client_db import create_customer
3233
from app.datamgmt.client.client_db import create_contact
3334
from app.datamgmt.client.client_db import delete_client
@@ -40,7 +41,6 @@
4041
from app.datamgmt.client.client_db import get_client_contact
4142
from app.datamgmt.client.client_db import update_client
4243
from app.datamgmt.client.client_db import update_contact
43-
from app.datamgmt.exceptions.ElementExceptions import ElementInUseException
4444
from app.datamgmt.manage.manage_users_db import add_user_to_customer
4545
from app.iris_engine.utils.tracker import track_activity
4646
from app.models.authorization import Permissions
@@ -290,7 +290,7 @@ def delete_customers(client_id):
290290
except ObjectNotFoundError:
291291
return response_error('Invalid Customer ID')
292292

293-
except ElementInUseException:
293+
except ElementInUseError:
294294
return response_error('Cannot delete a referenced customer')
295295

296296
except Exception:
@@ -313,7 +313,7 @@ def delete_contact_route(client_id, contact_id):
313313
except ObjectNotFoundError:
314314
return response_error('Invalid contact ID')
315315

316-
except ElementInUseException:
316+
except ElementInUseError:
317317
return response_error('Cannot delete a referenced contact')
318318

319319
except Exception:

source/app/blueprints/rest/v2/manage_routes/customers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
from app.blueprints.rest.endpoints import response_api_not_found
2727
from app.blueprints.rest.endpoints import response_api_deleted
2828
from app.blueprints.access_controls import ac_api_requires
29-
from app.datamgmt.exceptions.ElementExceptions import ElementInUseException
3029
from app.models.authorization import Permissions
3130
from app.schema.marshables import CustomerSchema
3231
from app.models.errors import ObjectNotFoundError
32+
from app.models.errors import ElementInUseError
3333
from app.business.customers import customers_create_with_user
3434
from app.business.customers import customers_get
3535
from app.business.customers import customers_update
@@ -82,8 +82,8 @@ def delete(self, identifier):
8282

8383
except ObjectNotFoundError:
8484
return response_api_not_found()
85-
except ElementInUseException:
86-
return response_api_error('Cannot delete a referenced customer')
85+
except ElementInUseError as e:
86+
return response_api_error(e.get_message())
8787

8888

8989
customers_blueprint = Blueprint('customers_rest_v2', __name__, url_prefix='/customers')

source/app/datamgmt/client/client_db.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from typing import Optional
2424

2525
from app import db
26-
from app.datamgmt.exceptions.ElementExceptions import ElementInUseException
26+
from app.models.errors import ElementInUseError
2727
from app.models.cases import Cases
2828
from app.models.models import Client
2929
from app.models.models import Contact
@@ -143,7 +143,7 @@ def delete_contact(contact: Contact):
143143
db.session.commit()
144144

145145
except Exception:
146-
raise ElementInUseException('A currently referenced contact cannot be deleted')
146+
raise ElementInUseError('A currently referenced contact cannot be deleted')
147147

148148

149149
def update_client(schema, customer: Client, data):
@@ -168,7 +168,7 @@ def delete_client(customer: Client) -> None:
168168
db.session.delete(customer)
169169
db.session.commit()
170170
except Exception:
171-
raise ElementInUseException('A currently referenced customer cannot be deleted')
171+
raise ElementInUseError('Cannot delete a referenced customer')
172172

173173

174174
def get_case_client(case_id: int) -> Client:

source/app/datamgmt/exceptions/ElementExceptions.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

source/app/datamgmt/exceptions/__init__.py

Whitespace-only changes.

source/app/models/errors.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ def __init__(self):
4141
class UnhandledBusinessError(BusinessProcessingError):
4242

4343
def __init__(self, message, data=None):
44-
self._message = message
45-
self._data = data
44+
super().__init__(message, data)
4645
logger.exception(message)
4746
logger.exception(data)
47+
48+
49+
class ElementInUseError(BusinessProcessingError):
50+
51+
pass

0 commit comments

Comments
 (0)