from_dict() implemented

This commit is contained in:
Profitroll 2023-09-11 21:16:31 +02:00
parent 13ca097909
commit b0f76f4c49
Signed by: profitroll
GPG Key ID: FA35CAB49DACD3B2
1 changed files with 9 additions and 0 deletions

View File

@ -71,6 +71,15 @@ class PyroUser:
return cls(**db_entry)
@classmethod
async def from_dict(cls, **kwargs):
if "location" in kwargs:
try:
kwargs["location"] = await Location.get(kwargs["location"]) # type: ignore
except ValueError:
kwargs["location"] = None # type: ignore
return cls(**kwargs)
async def update_locale(self, locale: Union[str, None]) -> None:
"""Change user's locale stored in the database.