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 # greed configuration file
# boolean parameters should be written in lowercase
# Config file parameters # Config file parameters
[Config] [Config]
; Config file version. DO NOT EDIT THIS! ; Config file version. DO NOT EDIT THIS!
version = 11 version = 12
; Set this to no when you are done editing the file ; Set this to no when you are done editing the file
is_template = yes is_template = yes
@ -49,6 +51,11 @@ email_required = yes
# Require the phone number of the user # Require the phone number of the user
phone_required = yes phone_required = yes
# Bot appearance settings
[Appearance]
# Show the full order info to the customers
full_order_info = no
# Exception reporting settings # Exception reporting settings
[Error Reporting] [Error Reporting]
# Optional sentry token: get the token at https://sentry.io/ # Optional sentry token: get the token at https://sentry.io/

View file

@ -239,25 +239,36 @@ class Order(TableDeclarativeBase):
def __repr__(self): def __repr__(self):
return f"<Order {self.order_id} placed by User {self.user_id}>" 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() joined_self = session.query(Order).filter_by(order_id=self.order_id).join(Transaction).one()
items = "" items = ""
for item in self.items: for item in self.items:
items += str(item) + "\n" items += str(item) + "\n"
if self.delivery_date is not None: if self.delivery_date is not None:
status_emoji = strings.emoji_completed status_emoji = strings.emoji_completed
status_text = strings.text_completed
elif self.refund_date is not None: elif self.refund_date is not None:
status_emoji = strings.emoji_refunded status_emoji = strings.emoji_refunded
status_text = strings.text_refunded
else: else:
status_emoji = strings.emoji_not_processed status_emoji = strings.emoji_not_processed
return status_emoji + " " + \ status_text = strings.text_not_processed
strings.order_number.format(id=self.order_id) + "\n" + \ if user and configloader.config["Appearance"]["full_order_info"] == "yes":
strings.order_format_string.format(user=self.user.mention(), return strings.user_order_format_string.format(status_emoji=status_emoji,
date=self.creation_date.isoformat(), status_text=status_text,
items=items, items=items,
notes=self.notes if self.notes is not None else "", notes=self.notes,
value=str(utils.Price(-joined_self.transaction.value))) + \ value=str(utils.Price(-joined_self.transaction.value))) + \
(strings.refund_reason.format(reason=self.refund_reason) if self.refund_date is not None else "") (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): class OrderItem(TableDeclarativeBase):

View file

@ -21,9 +21,9 @@ product_format_string = "<b>{name}</b>\n" \
"<b>{cart}</b>" "<b>{cart}</b>"
# Order number, displayed in the order info # 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" \ order_format_string = "di {user}\n" \
"Creato {date}\n" \ "Creato {date}\n" \
"\n" \ "\n" \
@ -32,6 +32,13 @@ order_format_string = "di {user}\n" \
"\n" \ "\n" \
"Note del cliente: {notes}" "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 # Transaction page is loading
loading_transactions = "<i>Caricamento delle transazioni in corso...\n" \ loading_transactions = "<i>Caricamento delle transazioni in corso...\n" \
"Attendi qualche secondo, per piacere.</i>" "Attendi qualche secondo, per piacere.</i>"
@ -203,6 +210,15 @@ emoji_completed = "✅"
# Emoji: refunded order # Emoji: refunded order
emoji_refunded = "✴️" 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? # Add product: name?
ask_product_name = "Come si deve chiamare il prodotto?" ask_product_name = "Come si deve chiamare il prodotto?"