fixed bug in ports GET
This commit is contained in:
parent
489dfc2ed6
commit
a68a768277
@ -13,8 +13,8 @@ def GetPorts(token):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
pooledConnection = local_db.getPoolConnection()
|
pooledConnection = local_db.getPoolConnection()
|
||||||
commands = pydapper.using(pooledConnection)
|
commands = pydapper.using(pooledConnection)
|
||||||
data = commands.query("SELECT id, name, locode, created, modified, deleted FROM port WHERE deleted = 0 ORDER BY name", model=model.Port)
|
data = commands.query("SELECT id, name, locode, created, modified, deleted FROM port ORDER BY name", model=model.Port)
|
||||||
return json.dumps(data, default=model.obj_dict), 200, {'Content-Type': 'application/json; charset=utf-8'}
|
return json.dumps(data, default=model.obj_dict), 200, {'Content-Type': 'application/json; charset=utf-8'}
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
|||||||
@ -34,10 +34,11 @@ class Berth(Schema):
|
|||||||
modified: datetime
|
modified: datetime
|
||||||
deleted: bool
|
deleted: bool
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class Port(Schema):
|
class Port(Schema):
|
||||||
id: int
|
id: int
|
||||||
name: str
|
name: str
|
||||||
locode: str
|
locode: str
|
||||||
created: datetime
|
created: datetime
|
||||||
modified: datetime
|
modified: datetime
|
||||||
deleted: bool
|
deleted: bool
|
||||||
@ -63,7 +64,7 @@ class EvaluationType(IntEnum):
|
|||||||
def _missing_(cls, value):
|
def _missing_(cls, value):
|
||||||
return cls.undefined
|
return cls.undefined
|
||||||
|
|
||||||
class NotificationType(IntEnum):
|
class NotificationType(IntEnum):
|
||||||
"""
|
"""
|
||||||
Any user has the attributes
|
Any user has the attributes
|
||||||
'notify_email' -> NotificationType.email
|
'notify_email' -> NotificationType.email
|
||||||
@ -76,7 +77,7 @@ class NotificationType(IntEnum):
|
|||||||
push = 2
|
push = 2
|
||||||
# whatsapp = 3
|
# whatsapp = 3
|
||||||
# signal = 4
|
# signal = 4
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _missing_(cls, value):
|
def _missing_(cls, value):
|
||||||
return cls.undefined
|
return cls.undefined
|
||||||
@ -137,7 +138,7 @@ class GetVerifyInlineResp(Schema):
|
|||||||
@dataclass
|
@dataclass
|
||||||
class Notification:
|
class Notification:
|
||||||
"""
|
"""
|
||||||
Base data class for any notification.
|
Base data class for any notification.
|
||||||
|
|
||||||
Description:
|
Description:
|
||||||
'An entry corresponds to an alarm given by a violated rule during times update'
|
'An entry corresponds to an alarm given by a violated rule during times update'
|
||||||
@ -173,7 +174,7 @@ class Participant(Schema):
|
|||||||
postal_code: str
|
postal_code: str
|
||||||
city: str
|
city: str
|
||||||
type: int # fields.Enum(ParticipantType ...)
|
type: int # fields.Enum(ParticipantType ...)
|
||||||
flags: int
|
flags: int
|
||||||
created: datetime
|
created: datetime
|
||||||
modified: datetime
|
modified: datetime
|
||||||
deleted: bool
|
deleted: bool
|
||||||
@ -185,7 +186,7 @@ class Participant(Schema):
|
|||||||
max_int = sum([int(val) for val in list(ParticipantType._value2member_map_.values())])
|
max_int = sum([int(val) for val in list(ParticipantType._value2member_map_.values())])
|
||||||
min_int = 0
|
min_int = 0
|
||||||
|
|
||||||
valid_type = 0 <= value < max_int
|
valid_type = 0 <= value < max_int
|
||||||
if not valid_type:
|
if not valid_type:
|
||||||
raise ValidationError({"type":f"the provided integer is not supported for default behaviour of the ParticipantType IntFlag. Your choice: {value}. Supported values are: 0 <= value {max_int}"})
|
raise ValidationError({"type":f"the provided integer is not supported for default behaviour of the ParticipantType IntFlag. Your choice: {value}. Supported values are: 0 <= value {max_int}"})
|
||||||
|
|
||||||
@ -196,7 +197,7 @@ class Participant(Schema):
|
|||||||
max_int = sum([int(val) for val in list(ParticipantFlag._value2member_map_.values())])
|
max_int = sum([int(val) for val in list(ParticipantFlag._value2member_map_.values())])
|
||||||
min_int = 0
|
min_int = 0
|
||||||
|
|
||||||
valid_type = 0 <= value < max_int
|
valid_type = 0 <= value < max_int
|
||||||
if not valid_type:
|
if not valid_type:
|
||||||
raise ValidationError({"flags":f"the provided integer is not supported for default behaviour of the ParticipantFlag IntFlag. Your choice: {value}. Supported values are: 0 <= value {max_int}"})
|
raise ValidationError({"flags":f"the provided integer is not supported for default behaviour of the ParticipantFlag IntFlag. Your choice: {value}. Supported values are: 0 <= value {max_int}"})
|
||||||
|
|
||||||
@ -253,15 +254,15 @@ class ShipcallSchema(Schema):
|
|||||||
data['type_value'] = int(ShipcallType.undefined)
|
data['type_value'] = int(ShipcallType.undefined)
|
||||||
if 'evaluation' in data:
|
if 'evaluation' in data:
|
||||||
if data['evaluation']:
|
if data['evaluation']:
|
||||||
data['evaluation_value'] = int(data['evaluation'])
|
data['evaluation_value'] = int(data['evaluation'])
|
||||||
else:
|
else:
|
||||||
data['evaluation_value'] = int(EvaluationType.undefined)
|
data['evaluation_value'] = int(EvaluationType.undefined)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@validates("type")
|
@validates("type")
|
||||||
def validate_type(self, value):
|
def validate_type(self, value):
|
||||||
valid_shipcall_type = int(value) in [item.value for item in ShipcallType]
|
valid_shipcall_type = int(value) in [item.value for item in ShipcallType]
|
||||||
|
|
||||||
if not valid_shipcall_type:
|
if not valid_shipcall_type:
|
||||||
raise ValidationError({"type":f"the provided type is not a valid shipcall type."})
|
raise ValidationError({"type":f"the provided type is not a valid shipcall type."})
|
||||||
|
|
||||||
@ -282,10 +283,10 @@ class Participant_Assignment:
|
|||||||
@dataclass
|
@dataclass
|
||||||
class Port_Assignment:
|
class Port_Assignment:
|
||||||
def __init__(self, port_id):
|
def __init__(self, port_id):
|
||||||
self.port_id = port_id
|
self.port_id = port_id
|
||||||
pass
|
pass
|
||||||
|
|
||||||
port_id: int
|
port_id: int
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
return self.__dict__
|
return self.__dict__
|
||||||
@ -458,7 +459,7 @@ class TimesSchema(Schema):
|
|||||||
# when 'value' is 'None', a ValidationError is not issued.
|
# when 'value' is 'None', a ValidationError is not issued.
|
||||||
valid_time = validate_time_is_in_not_too_distant_future(raise_validation_error=True, value=value, months=12)
|
valid_time = validate_time_is_in_not_too_distant_future(raise_validation_error=True, value=value, months=12)
|
||||||
return
|
return
|
||||||
|
|
||||||
@validates("eta_interval_end")
|
@validates("eta_interval_end")
|
||||||
def validate_eta_interval_end(self, value):
|
def validate_eta_interval_end(self, value):
|
||||||
# violation when time is not in the future, but also does not exceed a threshold for the 'reasonable' future
|
# violation when time is not in the future, but also does not exceed a threshold for the 'reasonable' future
|
||||||
@ -494,12 +495,12 @@ class UserSchema(Schema):
|
|||||||
valid_characters = list(map(str,range(0,10)))+["+", " "]
|
valid_characters = list(map(str,range(0,10)))+["+", " "]
|
||||||
if not all([v in valid_characters for v in value]):
|
if not all([v in valid_characters for v in value]):
|
||||||
raise ValidationError({"user_phone":f"one of the phone number values is not valid."})
|
raise ValidationError({"user_phone":f"one of the phone number values is not valid."})
|
||||||
|
|
||||||
@validates("user_email")
|
@validates("user_email")
|
||||||
def validate_user_email(self, value):
|
def validate_user_email(self, value):
|
||||||
if not "@" in value:
|
if not "@" in value:
|
||||||
raise ValidationError({"user_email":f"invalid email address"})
|
raise ValidationError({"user_email":f"invalid email address"})
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Times:
|
class Times:
|
||||||
@ -590,7 +591,7 @@ class ShipSchema(Schema):
|
|||||||
raise ValidationError({"name":f"'name' argument should have at least one character"})
|
raise ValidationError({"name":f"'name' argument should have at least one character"})
|
||||||
elif character_length>=64:
|
elif character_length>=64:
|
||||||
raise ValidationError({"name":f"'name' argument should have at max. 63 characters"})
|
raise ValidationError({"name":f"'name' argument should have at max. 63 characters"})
|
||||||
|
|
||||||
if check_if_string_has_special_characters(value):
|
if check_if_string_has_special_characters(value):
|
||||||
raise ValidationError({"name":f"'name' argument should not have special characters."})
|
raise ValidationError({"name":f"'name' argument should not have special characters."})
|
||||||
return
|
return
|
||||||
@ -609,7 +610,7 @@ class ShipSchema(Schema):
|
|||||||
callsign_length = len(str(value))
|
callsign_length = len(str(value))
|
||||||
if callsign_length>8:
|
if callsign_length>8:
|
||||||
raise ValidationError({"callsign":f"'callsign' argument should not have more than 8 characters"})
|
raise ValidationError({"callsign":f"'callsign' argument should not have more than 8 characters"})
|
||||||
|
|
||||||
if check_if_string_has_special_characters(value):
|
if check_if_string_has_special_characters(value):
|
||||||
raise ValidationError({"callsign":f"'callsign' argument should not have special characters."})
|
raise ValidationError({"callsign":f"'callsign' argument should not have special characters."})
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user