1
Fork 0
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:
Steffo 2018-04-26 08:47:53 +02:00
parent a41728ba12
commit fe63028e5f
3 changed files with 46 additions and 12 deletions

View file

@ -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/

View file

@ -239,25 +239,36 @@ 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
return status_emoji + " " + \
strings.order_number.format(id=self.order_id) + "\n" + \
strings.order_format_string.format(user=self.user.mention(),
date=self.creation_date.isoformat(),
items=items,
notes=self.notes if self.notes is not None else "",
value=str(utils.Price(-joined_self.transaction.value))) + \
(strings.refund_reason.format(reason=self.refund_reason) if self.refund_date is not None else "")
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(),
date=self.creation_date.isoformat(),
items=items,
notes=self.notes if self.notes is not None else "",
value=str(utils.Price(-joined_self.transaction.value))) + \
(strings.refund_reason.format(reason=self.refund_reason) if self.refund_date is not None else "")
class OrderItem(TableDeclarativeBase):

View file

@ -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?"