fixed wrong HTTP Status Code issues in API
parent
a648594243
commit
9f6fa02de0
|
@ -94,7 +94,7 @@ class ContactCollection:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.CONTACT_NAME_IS_ALREADY_IN_USE')
|
description='API.CONTACT_NAME_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
add_row = (" INSERT INTO tbl_contacts "
|
add_row = (" INSERT INTO tbl_contacts "
|
||||||
|
@ -292,7 +292,7 @@ class ContactItem:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.CONTACT_NAME_IS_ALREADY_IN_USE')
|
description='API.CONTACT_NAME_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
update_row = (" UPDATE tbl_contacts "
|
update_row = (" UPDATE tbl_contacts "
|
||||||
|
|
|
@ -108,7 +108,7 @@ class EquipmentCollection:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.EQUIPMENT_NAME_IS_ALREADY_IN_USE')
|
description='API.EQUIPMENT_NAME_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
if cost_center_id is not None:
|
if cost_center_id is not None:
|
||||||
|
|
|
@ -67,7 +67,7 @@ class GatewayCollection:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.GATEWAY_NAME_IS_ALREADY_IN_USE')
|
description='API.GATEWAY_NAME_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
add_values = (" INSERT INTO tbl_gateways (name, uuid, token) "
|
add_values = (" INSERT INTO tbl_gateways (name, uuid, token) "
|
||||||
|
@ -200,7 +200,7 @@ class GatewayItem:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.GATEWAY_NAME_IS_ALREADY_IN_USE')
|
description='API.GATEWAY_NAME_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
update_row = (" UPDATE tbl_gateways "
|
update_row = (" UPDATE tbl_gateways "
|
||||||
|
|
|
@ -22,7 +22,8 @@ class NotificationCollection:
|
||||||
if status is not None:
|
if status is not None:
|
||||||
status = str.strip(status)
|
status = str.strip(status)
|
||||||
if status not in ['unread', 'read', 'archived']:
|
if status not in ['unread', 'read', 'archived']:
|
||||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_STATUS')
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
|
description='API.INVALID_STATUS')
|
||||||
|
|
||||||
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
|
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
|
||||||
if config.utc_offset[0] == '-':
|
if config.utc_offset[0] == '-':
|
||||||
|
|
|
@ -79,7 +79,7 @@ class StoreTypeCollection:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.STORE_TYPE_NAME_IS_ALREADY_IN_USE')
|
description='API.STORE_TYPE_NAME_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
cursor.execute(" SELECT simplified_code "
|
cursor.execute(" SELECT simplified_code "
|
||||||
|
@ -88,7 +88,7 @@ class StoreTypeCollection:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.STORE_TYPE_SIMPLIFIED_CODE_IS_ALREADY_IN_USE')
|
description='API.STORE_TYPE_SIMPLIFIED_CODE_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
add_value = (" INSERT INTO tbl_store_types "
|
add_value = (" INSERT INTO tbl_store_types "
|
||||||
|
@ -234,7 +234,7 @@ class StoreTypeItem:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.STORE_TYPE_NAME_IS_ALREADY_IN_USE')
|
description='API.STORE_TYPE_NAME_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
cursor.execute(" SELECT simplified_code "
|
cursor.execute(" SELECT simplified_code "
|
||||||
|
|
|
@ -151,7 +151,7 @@ class TariffCollection:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.TARIFF_NAME_IS_ALREADY_IN_USE')
|
description='API.TARIFF_NAME_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
cursor.execute(" SELECT name "
|
cursor.execute(" SELECT name "
|
||||||
|
@ -427,7 +427,7 @@ class TariffItem:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.TARIFF_NAME_IS_ALREADY_IN_USE')
|
description='API.TARIFF_NAME_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
valid_from = datetime.strptime(new_values['data']['valid_from'], '%Y-%m-%dT%H:%M:%S')
|
valid_from = datetime.strptime(new_values['data']['valid_from'], '%Y-%m-%dT%H:%M:%S')
|
||||||
|
|
|
@ -79,7 +79,7 @@ class TenantTypeCollection:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.TENANT_TYPE_NAME_IS_ALREADY_IN_USE')
|
description='API.TENANT_TYPE_NAME_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
cursor.execute(" SELECT simplified_code "
|
cursor.execute(" SELECT simplified_code "
|
||||||
|
@ -88,7 +88,7 @@ class TenantTypeCollection:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.TENANT_TYPE_SIMPLIFIED_CODE_IS_ALREADY_IN_USE')
|
description='API.TENANT_TYPE_SIMPLIFIED_CODE_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
add_value = (" INSERT INTO tbl_tenant_types "
|
add_value = (" INSERT INTO tbl_tenant_types "
|
||||||
|
|
|
@ -769,7 +769,7 @@ class VirtualMeterItem:
|
||||||
if cursor.fetchone() is not None:
|
if cursor.fetchone() is not None:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.VIRTUAL_METER_NAME_IS_ALREADY_IN_USE')
|
description='API.VIRTUAL_METER_NAME_IS_ALREADY_IN_USE')
|
||||||
|
|
||||||
cursor.execute(" SELECT name "
|
cursor.execute(" SELECT name "
|
||||||
|
@ -808,7 +808,7 @@ class VirtualMeterItem:
|
||||||
if row[1] != energy_category_id:
|
if row[1] != energy_category_id:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.ENERGY_ITEM_IS_NOT_BELONG_TO_ENERGY_CATEGORY')
|
description='API.ENERGY_ITEM_IS_NOT_BELONG_TO_ENERGY_CATEGORY')
|
||||||
|
|
||||||
for variable in new_values['data']['expression']['variables']:
|
for variable in new_values['data']['expression']['variables']:
|
||||||
|
|
Loading…
Reference in New Issue