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:
@@ -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
|
||||
|
Reference in New Issue
Block a user