Fixed some bugs

This commit is contained in:
Profitroll
2022-12-23 12:54:51 +01:00
parent af862a3454
commit 85112dc653
4 changed files with 41 additions and 12 deletions

View File

@@ -13,7 +13,7 @@ from modules.logging import logWrite
from modules.utils import configGet, locale, should_quote
class DefaultApplicationTemp(dict):
def __init__(self, user: int):
def __init__(self, user: int, reapply: bool = False):
super().__init__({})
self.dict = {
"user": user,
@@ -21,7 +21,7 @@ class DefaultApplicationTemp(dict):
"complete": False,
"sent": False,
"state": "fill",
"reapply": False,
"reapply": reapply,
"stage": 1,
"application": {
"1": None,
@@ -326,14 +326,14 @@ class HoloUser():
"""
return True if col_applications.find_one({"user": self.id}) is not None else False
def application_restart(self) -> None:
def application_restart(self, reapply: bool = False) -> None:
"""Reset application of a user in tmp collection and replace it with an empty one
"""
if col_tmp.find_one({"user": self.id, "type": "application"}) is None:
col_tmp.insert_one(document=DefaultApplicationTemp(self.id).dict)
else:
col_tmp.delete_one({"user": self.id, "type": "application"})
col_tmp.insert_one(document=DefaultApplicationTemp(self.id).dict)
col_tmp.insert_one(document=DefaultApplicationTemp(self.id, reapply=reapply).dict)
async def application_next(self, query: str, msg: Message) -> None:
"""Move on filling application of user
@@ -352,7 +352,7 @@ class HoloUser():
progress = col_tmp.find_one({"user": self.id, "type": "application"})
stage = progress["stage"]
if progress["state"] == "fill":
if progress["state"] == "fill" and progress["sent"] is False:
if stage == 2:
@@ -468,7 +468,7 @@ class HoloUser():
progress = col_tmp.find_one({"user": self.id, "type": "sponsorship"})
stage = progress["stage"]
if progress["state"] == "fill":
if progress["state"] == "fill" and progress["sent"] is False:
if stage == 1: