fixed bug in ports GET
This commit is contained in:
parent
489dfc2ed6
commit
a68a768277
@ -13,8 +13,8 @@ def GetPorts(token):
|
||||
|
||||
try:
|
||||
pooledConnection = local_db.getPoolConnection()
|
||||
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)
|
||||
commands = pydapper.using(pooledConnection)
|
||||
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'}
|
||||
|
||||
except Exception as ex:
|
||||
|
||||
@ -34,10 +34,11 @@ class Berth(Schema):
|
||||
modified: datetime
|
||||
deleted: bool
|
||||
|
||||
@dataclass
|
||||
class Port(Schema):
|
||||
id: int
|
||||
name: str
|
||||
locode: str
|
||||
locode: str
|
||||
created: datetime
|
||||
modified: datetime
|
||||
deleted: bool
|
||||
@ -63,7 +64,7 @@ class EvaluationType(IntEnum):
|
||||
def _missing_(cls, value):
|
||||
return cls.undefined
|
||||
|
||||
class NotificationType(IntEnum):
|
||||
class NotificationType(IntEnum):
|
||||
"""
|
||||
Any user has the attributes
|
||||
'notify_email' -> NotificationType.email
|
||||
@ -76,7 +77,7 @@ class NotificationType(IntEnum):
|
||||
push = 2
|
||||
# whatsapp = 3
|
||||
# signal = 4
|
||||
|
||||
|
||||
@classmethod
|
||||
def _missing_(cls, value):
|
||||
return cls.undefined
|
||||
@ -137,7 +138,7 @@ class GetVerifyInlineResp(Schema):
|
||||
@dataclass
|
||||
class Notification:
|
||||
"""
|
||||
Base data class for any notification.
|
||||
Base data class for any notification.
|
||||
|
||||
Description:
|
||||
'An entry corresponds to an alarm given by a violated rule during times update'
|
||||
@ -173,7 +174,7 @@ class Participant(Schema):
|
||||
postal_code: str
|
||||
city: str
|
||||
type: int # fields.Enum(ParticipantType ...)
|
||||
flags: int
|
||||
flags: int
|
||||
created: datetime
|
||||
modified: datetime
|
||||
deleted: bool
|
||||
@ -185,7 +186,7 @@ class Participant(Schema):
|
||||
max_int = sum([int(val) for val in list(ParticipantType._value2member_map_.values())])
|
||||
min_int = 0
|
||||
|
||||
valid_type = 0 <= value < max_int
|
||||
valid_type = 0 <= value < max_int
|
||||
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}"})
|
||||
|
||||
@ -196,7 +197,7 @@ class Participant(Schema):
|
||||
max_int = sum([int(val) for val in list(ParticipantFlag._value2member_map_.values())])
|
||||
min_int = 0
|
||||
|
||||
valid_type = 0 <= value < max_int
|
||||
valid_type = 0 <= value < max_int
|
||||
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}"})
|
||||
|
||||
@ -253,15 +254,15 @@ class ShipcallSchema(Schema):
|
||||
data['type_value'] = int(ShipcallType.undefined)
|
||||
if 'evaluation' in data:
|
||||
if data['evaluation']:
|
||||
data['evaluation_value'] = int(data['evaluation'])
|
||||
data['evaluation_value'] = int(data['evaluation'])
|
||||
else:
|
||||
data['evaluation_value'] = int(EvaluationType.undefined)
|
||||
return data
|
||||
|
||||
|
||||
@validates("type")
|
||||
def validate_type(self, value):
|
||||
valid_shipcall_type = int(value) in [item.value for item in ShipcallType]
|
||||
|
||||
|
||||
if not valid_shipcall_type:
|
||||
raise ValidationError({"type":f"the provided type is not a valid shipcall type."})
|
||||
|
||||
@ -282,10 +283,10 @@ class Participant_Assignment:
|
||||
@dataclass
|
||||
class Port_Assignment:
|
||||
def __init__(self, port_id):
|
||||
self.port_id = port_id
|
||||
self.port_id = port_id
|
||||
pass
|
||||
|
||||
port_id: int
|
||||
port_id: int
|
||||
|
||||
def to_json(self):
|
||||
return self.__dict__
|
||||
@ -458,7 +459,7 @@ class TimesSchema(Schema):
|
||||
# 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)
|
||||
return
|
||||
|
||||
|
||||
@validates("eta_interval_end")
|
||||
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
|
||||
@ -494,12 +495,12 @@ class UserSchema(Schema):
|
||||
valid_characters = list(map(str,range(0,10)))+["+", " "]
|
||||
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."})
|
||||
|
||||
|
||||
@validates("user_email")
|
||||
def validate_user_email(self, value):
|
||||
if not "@" in value:
|
||||
raise ValidationError({"user_email":f"invalid email address"})
|
||||
|
||||
|
||||
|
||||
@dataclass
|
||||
class Times:
|
||||
@ -590,7 +591,7 @@ class ShipSchema(Schema):
|
||||
raise ValidationError({"name":f"'name' argument should have at least one character"})
|
||||
elif character_length>=64:
|
||||
raise ValidationError({"name":f"'name' argument should have at max. 63 characters"})
|
||||
|
||||
|
||||
if check_if_string_has_special_characters(value):
|
||||
raise ValidationError({"name":f"'name' argument should not have special characters."})
|
||||
return
|
||||
@ -609,7 +610,7 @@ class ShipSchema(Schema):
|
||||
callsign_length = len(str(value))
|
||||
if callsign_length>8:
|
||||
raise ValidationError({"callsign":f"'callsign' argument should not have more than 8 characters"})
|
||||
|
||||
|
||||
if check_if_string_has_special_characters(value):
|
||||
raise ValidationError({"callsign":f"'callsign' argument should not have special characters."})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user