A simple web application that allows invitation based registration to a matrix instance
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
from datetime import datetime from typing import Tuple
class RegistrationCode: def __init__(self, code: str, creation_time: datetime = datetime.now(), expiration_time: datetime = None, usages: int = 0, max_usages: int = 1): self.code = code self.creation_time = creation_time self.expiration_time = expiration_time self.usages = usages self.max_usages = max_usages
@staticmethod def from_db(db_registration_code: Tuple) -> 'RegistrationCode': expiration_time = None if db_registration_code[2] is None else datetime.fromisoformat(db_registration_code[2]) return RegistrationCode( db_registration_code[0], datetime.fromisoformat(db_registration_code[1]), expiration_time, db_registration_code[3], db_registration_code[4] )
def is_expired(self): return self.expiration_time is not None and self.expiration_time < datetime.now()
class RegisteredUser: def __init__(self, username: str, registered_time: datetime = datetime.now()): self.username = username self.registered_time = registered_time
@staticmethod def from_db(db_registered_user: Tuple) -> 'RegisteredUser': return RegisteredUser( db_registered_user[0], datetime.fromisoformat(db_registered_user[1]) )
|