Worked on #13 and #4. There are some caching issues left, though. Introduced abstract class Cacheable. Replaced async_pymongo with pymongo

This commit is contained in:
2025-05-06 02:54:30 +02:00
parent 9d562e2e9d
commit 86c75d06fa
22 changed files with 412 additions and 137 deletions

View File

@@ -23,15 +23,15 @@ async def validate_event_validity(
end_date_internal: datetime = end_date.astimezone(ZoneInfo("UTC")) if to_utc else end_date
if start_date_internal < datetime.now(tz=ZoneInfo("UTC")):
await ctx.respond(_("event_start_past", "messages", locale=ctx.locale))
await ctx.respond(_("event_start_past", "messages", locale=ctx.locale), ephemeral=True)
return False
if end_date_internal < datetime.now(tz=ZoneInfo("UTC")):
await ctx.respond(_("event_end_past", "messages", locale=ctx.locale))
await ctx.respond(_("event_end_past", "messages", locale=ctx.locale), ephemeral=True)
return False
if start_date_internal >= end_date_internal:
await ctx.respond(_("event_end_before_start", "messages", locale=ctx.locale))
await ctx.respond(_("event_end_before_start", "messages", locale=ctx.locale), ephemeral=True)
return False
# TODO Add validation for concurrent events.
@@ -47,7 +47,7 @@ async def validate_event_validity(
query["_id"] = {"$ne": event_id}
if (await col_events.find_one(query)) is not None:
await ctx.respond(_("event_name_duplicate", "messages", locale=ctx.locale))
await ctx.respond(_("event_name_duplicate", "messages", locale=ctx.locale), ephemeral=True)
return False
return True