Merge Beta with Stable releases #1

Merged
profitroll merged 52 commits from dev into master 2022-12-16 16:14:41 +02:00
Showing only changes of commit 2ead4eaa06 - Show all commits

View File

@ -10,6 +10,31 @@ from modules.database import col_tmp, col_users, col_context, col_warnings, col_
from modules.logging import logWrite from modules.logging import logWrite
from modules.utils import configGet, locale, should_quote from modules.utils import configGet, locale, should_quote
class DefaultApplicationTemp(dict):
def __init__(self, user: int):
super().__init__({})
self.dict = {
"user": user,
"type": "application",
"complete": False,
"sent": False,
"state": "fill",
"reapply": False,
"stage": 1,
"application": {
"1": None,
"2": None,
"3": None,
"4": None,
"5": None,
"6": None,
"7": None,
"8": None,
"9": None,
"10": None
}
}
class UserNotFoundError(Exception): class UserNotFoundError(Exception):
"""HoloUser could not find user with such an ID in database""" """HoloUser could not find user with such an ID in database"""
def __init__(self, user, user_id): def __init__(self, user, user_id):
@ -251,32 +276,11 @@ class HoloUser():
def application_restart(self) -> None: def application_restart(self) -> None:
"""Reset application of a user in tmp collection and replace it with an empty one """Reset application of a user in tmp collection and replace it with an empty one
""" """
doc = {
"user": self.id,
"type": "application",
"complete": False,
"sent": False,
"state": "fill",
"reapply": False,
"stage": 1,
"application": {
"1": None,
"2": None,
"3": None,
"4": None,
"5": None,
"6": None,
"7": None,
"8": None,
"9": None,
"10": None
}
}
if col_tmp.find_one({"user": self.id, "type": "application"}) is None: if col_tmp.find_one({"user": self.id, "type": "application"}) is None:
col_tmp.insert_one(document=doc) col_tmp.insert_one(document=DefaultApplicationTemp(self.id).dict)
else: else:
col_tmp.delete_one({"user": self.id, "type": "application"}) col_tmp.delete_one({"user": self.id, "type": "application"})
col_tmp.insert_one(document=doc) col_tmp.insert_one(document=DefaultApplicationTemp(self.id).dict)
async def application_next(self, query: str, msg: Message) -> None: async def application_next(self, query: str, msg: Message) -> None:
"""Move on filling application of user """Move on filling application of user
@ -289,27 +293,7 @@ class HoloUser():
if col_tmp.find_one({"user": self.id, "type": "application"}) is None: if col_tmp.find_one({"user": self.id, "type": "application"}) is None:
col_tmp.insert_one( col_tmp.insert_one(
document={ document=DefaultApplicationTemp(self.id).dict
"user": self.id,
"type": "application",
"complete": False,
"sent": False,
"state": "fill",
"reapply": False,
"stage": 1,
"application": {
"1": None,
"2": None,
"3": None,
"4": None,
"5": None,
"6": None,
"7": None,
"8": None,
"9": None,
"10": None
}
}
) )
progress = col_tmp.find_one({"user": self.id, "type": "application"}) progress = col_tmp.find_one({"user": self.id, "type": "application"})