From 390ae5774797604ffe72a799c7551fd460656682 Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Tue, 2 May 2023 09:43:33 +0200 Subject: [PATCH] Delete functionality not implemented correctly --- bot/commands/journal.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bot/commands/journal.py b/bot/commands/journal.py index 8c5b628..008f0d9 100644 --- a/bot/commands/journal.py +++ b/bot/commands/journal.py @@ -96,7 +96,7 @@ class JournalHandler(BaseHandler): await update.message.reply_text("Please enter the date in the format DDMMYYYY") return DATE_ENTRY - if context.chat_data.get("delete", True): + if context.chat_data.get("delete", False): # if not set, delete was not chosen with self.models.db: self.current_model = self.models.JournalEntry.get_or_none( date = date @@ -105,6 +105,7 @@ class JournalHandler(BaseHandler): return DELETE_ENTRY else: await update.message.reply_text("No entry found for this date") + context.chat_data["delete"] = False return ConversationHandler.END else: with self.models.db: @@ -154,5 +155,6 @@ class JournalHandler(BaseHandler): async def delete_entry(self, update, context): with self.models.db: self.current_model.delete_instance() + context.chat_data["delete"] = False await update.callback_query.edit_message_text(text="Entry deleted ✅") return ConversationHandler.END