(20250220) Bug fix in reminders for work.
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
"""
|
||||
|
||||
AUTHOR:
|
||||
|
||||
Khushal P Soonderji
|
||||
|
||||
DATE:
|
||||
|
||||
Thursday, 20th Feb., 2025.
|
||||
|
||||
OBJECTIVE:
|
||||
|
||||
To give a general response structure to anything happening inside a function.
|
||||
|
||||
REFERENCES:
|
||||
|
||||
N/A
|
||||
|
||||
DOWNLOADS:
|
||||
|
||||
N/A
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** IMPORT ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# To make sibling directories accessible for imports:
|
||||
import sys
|
||||
sys.path.append(".")
|
||||
sys.path.append("..")
|
||||
|
||||
# For making data behaviour_models:
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Any
|
||||
|
||||
# To work with MongoDB:
|
||||
from bson.objectid import ObjectId
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** MACROS / ONE-TIME INIT ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# --- Nothing Yet
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** VARIABLES ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# --- Nothing Yet
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** FUNCTIONS ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
class FunctionCallResponse(BaseModel):
|
||||
|
||||
success: bool = Field(
|
||||
description = "Whether, or not, the objective of the function was achieved.",
|
||||
frozen = False,
|
||||
default = False
|
||||
)
|
||||
|
||||
message: str = Field(
|
||||
description = "A brief message to indicate what happened in the process of executing the function.",
|
||||
frozen = False,
|
||||
default = "ERR: Message NOT captured."
|
||||
)
|
||||
|
||||
exception: Exception = Field(
|
||||
description = "Any exception that occurred in the process of execution.",
|
||||
frozen = False,
|
||||
default = None
|
||||
)
|
||||
|
||||
data: Any = Field(
|
||||
description = "Any data to be returned from the function that would be useful outside.",
|
||||
frozen = False,
|
||||
default = None
|
||||
)
|
||||
|
||||
key: ObjectId = Field(
|
||||
description = "the expendable reference to this auth; expose this to the ui",
|
||||
frozen = True,
|
||||
default_factory = lambda: ObjectId()
|
||||
)
|
||||
|
||||
# ┏┓ ┏•
|
||||
# ┃ ┏┓┏┓╋┓┏┓
|
||||
# ┗┛┗┛┛┗┛┗┗┫
|
||||
# ┛
|
||||
|
||||
class Config:
|
||||
extra = "forbid"
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
def model_dump(self, *args, **kwargs):
|
||||
return super().model_dump(*args, by_alias = True, **kwargs)
|
||||
|
||||
# ┓┏ ┓• ┓ •
|
||||
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓
|
||||
# ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗
|
||||
|
||||
pass
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** MAIN PROGRAM ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
pass
|
||||
@@ -0,0 +1,121 @@
|
||||
"""
|
||||
|
||||
AUTHOR:
|
||||
|
||||
Khushal P Soonderji
|
||||
|
||||
DATE:
|
||||
|
||||
Tuesday, 10th Sept., 2024.
|
||||
|
||||
OBJECTIVE:
|
||||
|
||||
To provide a data structure for the JSON received in the API calls to generate and verify timed OTPs.
|
||||
|
||||
REFERENCES:
|
||||
|
||||
N/A
|
||||
|
||||
DOWNLOADS:
|
||||
|
||||
N/A
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** IMPORT ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# To make sibling directories accessible for imports:
|
||||
import sys
|
||||
sys.path.append(".")
|
||||
sys.path.append("..")
|
||||
|
||||
# For making data models:
|
||||
from pydantic import BaseModel, Field, field_validator, Extra
|
||||
from typing import Optional, Any, Dict, List
|
||||
from typing_extensions import Annotated
|
||||
|
||||
# My utils:
|
||||
from utils_v2.string import regex
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** MACROS / ONE-TIME INIT ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# --- Nothing Yet
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** VARIABLES ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# --- Nothing Yet
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** FUNCTIONS ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
class GenerateTimedOTP(BaseModel):
|
||||
|
||||
id: str | Dict | List
|
||||
attempts: Optional[int] = 3
|
||||
seconds: Optional[int | float] = 30.0
|
||||
|
||||
class Config:
|
||||
extra = "forbid"
|
||||
|
||||
def get(self, key: str, default = None):
|
||||
return getattr(self, key, default)
|
||||
|
||||
@field_validator("attempts")
|
||||
def validate_attempts(cls, value):
|
||||
if not 1 <= value <= 10: raise ValueError("Attempts must be at least 1 and at most 10.")
|
||||
return value
|
||||
|
||||
@field_validator("seconds")
|
||||
def validate_expiry(cls, value):
|
||||
if not 30 <= value <= 300: raise ValueError("Expiry must be at least 30s and at most 300s.")
|
||||
return value
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class VerifyTimedOTP(BaseModel):
|
||||
|
||||
id: str | Dict | List
|
||||
otp: str
|
||||
|
||||
class Config:
|
||||
extra = "forbid"
|
||||
|
||||
def get(self, key: str, default = None):
|
||||
return getattr(self, key, default)
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
# *** MAIN PROGRAM ***
|
||||
# ***** ****
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
pass
|
||||
Reference in New Issue
Block a user