From 17b4be529db1f6efbdf429bdd605048868caa9c9 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 18 Apr 2018 09:23:44 +0200 Subject: [PATCH] UNFINISHED --- database.py | 7 ------- strings.py | 11 +++++------ worker.py | 6 ++---- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/database.py b/database.py index 8e33689..2f79305 100644 --- a/database.py +++ b/database.py @@ -85,8 +85,6 @@ class Product(TableDeclarativeBase): image = Column(LargeBinary) # Product has been deleted deleted = Column(Boolean, nullable=False) - # Stock quantity, if null product has infinite stock - stock = Column(Integer) # Extra table parameters __tablename__ = "products" @@ -101,17 +99,12 @@ class Product(TableDeclarativeBase): if style == "short": return f"{cart_qty}x {utils.telegram_html_escape(self.name)} - {str(utils.Price(self.price) * cart_qty)}" elif style == "full": - if self.stock is not None: - stock = strings.in_stock_format_string.format(quantity=self.stock) - else: - stock = '' if cart_qty is not None: cart = strings.in_cart_format_string.format(quantity=cart_qty) else: cart = '' return strings.product_format_string.format(name=utils.telegram_html_escape(self.name), description=utils.telegram_html_escape(self.description), - stock=stock, price=str(utils.Price(self.price)), cart=cart) else: diff --git a/strings.py b/strings.py index 9e3af08..aa426ee 100644 --- a/strings.py +++ b/strings.py @@ -16,7 +16,6 @@ in_cart_format_string = "{quantity} nel carrello" # Product information product_format_string = "{name}\n" \ "{description}\n" \ - "{stock}\n" \ "{price}\n" \ "{cart}" @@ -67,9 +66,6 @@ conversation_admin_select_product_to_delete = "❌ Che prodotto vuoi eliminare?" # Conversation: select a user to edit conversation_admin_select_user = "Seleziona l'utente a cui vuoi aggiungere o togliere credito." -# Conversation: add extra notes to the order -conversation_extra_notes = "Che messaggio vuoi lasciare insieme al tuo ordine?" - # Conversation: click below to pay for the purchase conversation_cart_actions = "Aggiungi prodotti al carrello scorrendo in su e premendo il pulsante Aggiungi sotto" \ " i prodotti che desideri acquistare. Quando avrai terminato, torna a questo messaggio e" \ @@ -227,7 +223,9 @@ downloading_image = "Sto scaricando la tua foto!\n" \ # Edit product: current value edit_current_value = "Il valore attuale è:\n" \ - "
{value}
" + "
{value}
\n" \ + "\n" \ + "Premi il tasto Salta sotto questo messaggio per mantenere lo stesso valore." # Payment: cash payment info payment_cash = "Puoi pagare in contanti alla sede fisica del negozio.\n" \ @@ -308,7 +306,8 @@ success_order_completed = "✅ Hai segnato l'ordine #{order_id} come completato. success_order_refunded = "✴️ L'ordine #{order_id} è stato rimborsato con successo." # Success: transaction was created successfully -success_transaction_created = "✅ La transazione è stata creata con successo!" +success_transaction_created = "✅ La transazione è stata creata con successo!\n" \ + "{transaction}" # Error: message received not in a private chat error_nonprivate_chat = "⚠️ Questo bot funziona solo in chat private." diff --git a/worker.py b/worker.py index 3dfd187..37d88ea 100644 --- a/worker.py +++ b/worker.py @@ -584,7 +584,7 @@ class ChatWorker(threading.Thread): description=strings.payment_invoice_description.format(amount=str(value)), payload=self.invoice_payload, provider_token=configloader.config["Credit Card"]["credit_card_token"], - start_parameter="tempdeeplink", # TODO: no idea on how deeplinks should work + start_parameter="tempdeeplink", currency=configloader.config["Payments"]["currency"], prices=prices, need_name=configloader.config["Credit Card"]["name_required"] == "yes", @@ -852,7 +852,6 @@ class ChatWorker(threading.Thread): self.admin.live_mode = False break # Find the order - # TODO: debug the regex? order_id = re.search(strings.order_number.replace("{id}", "([0-9]+)"), update.message.text).group(1) order = self.session.query(db.Order).filter(db.Order.order_id == order_id).one() # Check if the order hasn't been already cleared @@ -912,7 +911,6 @@ class ChatWorker(threading.Thread): # Add to the list all the users for user in users: keyboard_buttons.append([user.identifiable_str()]) - # TODO: handle more than 99 users # Create the keyboard keyboard = telegram.ReplyKeyboardMarkup(keyboard_buttons, one_time_keyboard=True) # Send the keyboard @@ -961,7 +959,7 @@ class ChatWorker(threading.Thread): strings.notification_transaction_created.format(transaction=str(transaction)), parse_mode="HTML") # Notify the admin of the success - self.bot.send_message(self.chat.id, strings.success_transaction_created) + self.bot.send_message(self.chat.id, strings.success_transaction_created.format(transaction=str(transaction))) def __help_menu(self): """Help menu. Allows the user to ask for assistance, get a guide or see some info about the bot."""