fixed error, but enum values are still serialized as int
This commit is contained in:
parent
01dda53425
commit
dd4ae7def8
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
@ -15,9 +15,9 @@
|
||||
"SECRET_KEY" : "zdiTz8P3jXOc7jztIQAoelK4zztyuCpJ" // https://randomkeygen.com/
|
||||
},
|
||||
"args": [
|
||||
"run" //,
|
||||
// "--no-debugger",
|
||||
//"--no-reload"
|
||||
"run",
|
||||
// "--no-debugger",
|
||||
"--no-reload"
|
||||
],
|
||||
"jinja": true,
|
||||
"justMyCode": true
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import json
|
||||
import logging
|
||||
import pydapper
|
||||
import pdb
|
||||
|
||||
from ..schemas import model
|
||||
from ..schemas.model import History
|
||||
@ -17,8 +18,6 @@ def GetHistory(options):
|
||||
try:
|
||||
pooledConnection = local_db.getPoolConnection()
|
||||
commands = pydapper.using(pooledConnection)
|
||||
h = History(1, 1, 1, "2020-01-01", "2020-01-01", model.ObjectType.shipcall, model.Operation.insert)
|
||||
|
||||
|
||||
if "shipcall_id" in options and options["shipcall_id"]:
|
||||
data = commands.query("SELECT id, participant_id, shipcall_id, timestamp, eta, type, operation FROM history WHERE shipcall_id = ?shipcallid?",
|
||||
@ -29,6 +28,7 @@ def GetHistory(options):
|
||||
pooledConnection.close()
|
||||
|
||||
except Exception as ex:
|
||||
pdb.pm()
|
||||
logging.error(ex)
|
||||
print(ex)
|
||||
result = {}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
from dataclasses import field, dataclass
|
||||
from marshmallow import Schema, fields, INCLUDE, ValidationError
|
||||
from marshmallow_enum import EnumField
|
||||
from enum import Enum
|
||||
from enum import IntEnum
|
||||
|
||||
from marshmallow_dataclass import dataclass
|
||||
from typing import List
|
||||
@ -25,14 +25,16 @@ class Berth(Schema):
|
||||
modified: datetime
|
||||
deleted: bool
|
||||
|
||||
class Operation(Enum):
|
||||
insert = 1,
|
||||
update = 2,
|
||||
delete = 3
|
||||
class Operation(IntEnum):
|
||||
UNDEFINED = 0
|
||||
INSERT = 1
|
||||
UPDATE = 2
|
||||
DELETE = 3
|
||||
|
||||
class ObjectType(Enum):
|
||||
shipcall = 1,
|
||||
times = 2
|
||||
class ObjectType(IntEnum):
|
||||
UNDEFINED = 0
|
||||
SHIPCALL = 1
|
||||
TIMES = 2
|
||||
|
||||
@dataclass
|
||||
class History:
|
||||
@ -45,7 +47,7 @@ class History:
|
||||
self.type = type
|
||||
self.operation = operation
|
||||
pass
|
||||
|
||||
|
||||
id: int
|
||||
participant_id: int
|
||||
shipcall_id: int
|
||||
@ -54,8 +56,8 @@ class History:
|
||||
type: EnumField(ObjectType)
|
||||
operation: EnumField(Operation)
|
||||
@classmethod
|
||||
def from_query_row(self, id, participant_id, ship_id, timestamp, eta, type, operation):
|
||||
return self(id, participant_id, ship_id, timestamp, eta, ObjectType(type), Operation(operation))
|
||||
def from_query_row(self, id, participant_id, shipcall_id, timestamp, eta, type, operation):
|
||||
return self(id, participant_id, shipcall_id, timestamp, eta, ObjectType(type), Operation(operation))
|
||||
|
||||
class Error(Schema):
|
||||
message = fields.String(required=True)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user