1
0
Fork 0
mirror of https://github.com/dancojocaru2000/foxbank.git synced 2025-02-23 08:09:35 +02:00
foxbank/server/models.py
2021-12-06 01:34:00 +02:00

25 lines
No EOL
566 B
Python

from dataclasses import dataclass
@dataclass
class User:
id: int
username: str
email: str
otp: str
fullname: str
def to_json(self, include_otp=False, include_id=False):
result = {
'username': self.username,
'email': self.email,
'fullname': self.fullname,
}
if include_id:
result['id'] = self.id
if include_otp:
result['otp'] = self.otp
return result
@classmethod
def from_query(cls, query_result):
return cls(*query_result)