mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-21 21:44:19 +00:00
#15: Hide order id from users
This commit is contained in:
parent
a41728ba12
commit
fe63028e5f
3 changed files with 46 additions and 12 deletions
|
@ -1,9 +1,11 @@
|
|||
# greed configuration file
|
||||
|
||||
# boolean parameters should be written in lowercase
|
||||
|
||||
# Config file parameters
|
||||
[Config]
|
||||
; Config file version. DO NOT EDIT THIS!
|
||||
version = 11
|
||||
version = 12
|
||||
; Set this to no when you are done editing the file
|
||||
is_template = yes
|
||||
|
||||
|
@ -49,6 +51,11 @@ email_required = yes
|
|||
# Require the phone number of the user
|
||||
phone_required = yes
|
||||
|
||||
# Bot appearance settings
|
||||
[Appearance]
|
||||
# Show the full order info to the customers
|
||||
full_order_info = no
|
||||
|
||||
# Exception reporting settings
|
||||
[Error Reporting]
|
||||
# Optional sentry token: get the token at https://sentry.io/
|
||||
|
|
13
database.py
13
database.py
|
@ -239,17 +239,28 @@ class Order(TableDeclarativeBase):
|
|||
def __repr__(self):
|
||||
return f"<Order {self.order_id} placed by User {self.user_id}>"
|
||||
|
||||
def get_text(self, session):
|
||||
def get_text(self, session, user=False):
|
||||
joined_self = session.query(Order).filter_by(order_id=self.order_id).join(Transaction).one()
|
||||
items = ""
|
||||
for item in self.items:
|
||||
items += str(item) + "\n"
|
||||
if self.delivery_date is not None:
|
||||
status_emoji = strings.emoji_completed
|
||||
status_text = strings.text_completed
|
||||
elif self.refund_date is not None:
|
||||
status_emoji = strings.emoji_refunded
|
||||
status_text = strings.text_refunded
|
||||
else:
|
||||
status_emoji = strings.emoji_not_processed
|
||||
status_text = strings.text_not_processed
|
||||
if user and configloader.config["Appearance"]["full_order_info"] == "yes":
|
||||
return strings.user_order_format_string.format(status_emoji=status_emoji,
|
||||
status_text=status_text,
|
||||
items=items,
|
||||
notes=self.notes,
|
||||
value=str(utils.Price(-joined_self.transaction.value))) + \
|
||||
(strings.refund_reason.format(reason=self.refund_reason) if self.refund_date is not None else "")
|
||||
else:
|
||||
return status_emoji + " " + \
|
||||
strings.order_number.format(id=self.order_id) + "\n" + \
|
||||
strings.order_format_string.format(user=self.user.mention(),
|
||||
|
|
20
strings.py
20
strings.py
|
@ -21,9 +21,9 @@ product_format_string = "<b>{name}</b>\n" \
|
|||
"<b>{cart}</b>"
|
||||
|
||||
# Order number, displayed in the order info
|
||||
order_number = "Ordine #{id}"
|
||||
order_number = "<b>Ordine #{id}</b>"
|
||||
|
||||
# Order info displayed string
|
||||
# Order info string, shown to the admins
|
||||
order_format_string = "di {user}\n" \
|
||||
"Creato {date}\n" \
|
||||
"\n" \
|
||||
|
@ -32,6 +32,13 @@ order_format_string = "di {user}\n" \
|
|||
"\n" \
|
||||
"Note del cliente: {notes}"
|
||||
|
||||
# Order info string, shown to the user
|
||||
user_order_format_string = "{status_emoji} <b>Ordine {status_text}</b>\n" \
|
||||
"{items}\n" \
|
||||
"TOTALE: {value}\n" \
|
||||
"\n" \
|
||||
"Note: {notes}"
|
||||
|
||||
# Transaction page is loading
|
||||
loading_transactions = "<i>Caricamento delle transazioni in corso...\n" \
|
||||
"Attendi qualche secondo, per piacere.</i>"
|
||||
|
@ -203,6 +210,15 @@ emoji_completed = "✅"
|
|||
# Emoji: refunded order
|
||||
emoji_refunded = "✴️"
|
||||
|
||||
# Text: unprocessed order
|
||||
text_not_processed = "in sospeso"
|
||||
|
||||
# Text: completed order
|
||||
text_completed = "completato"
|
||||
|
||||
# Text: refunded order
|
||||
text_refunded = "rimborsato"
|
||||
|
||||
# Add product: name?
|
||||
ask_product_name = "Come si deve chiamare il prodotto?"
|
||||
|
||||
|
|
Loading…
Reference in a new issue