Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translated menu to english #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def setup():
for lcd in bar_lcd, customer_lcd:
lcd.tick_off()
lcd.clean()
lcd.write("Laster systemet!")
lcd.write("Loading system!")

# Get the config
config = configparser.ConfigParser()
Expand All @@ -51,7 +51,7 @@ def setup():


def get_card_id():
write((bar_lcd, customer_lcd), "Venter pa kort")
write((bar_lcd, customer_lcd), "Waiting for card")

return main.getid()

Expand All @@ -61,26 +61,26 @@ def register_customer(card_uid):
user_id = ""
is_intern = False

choice = ChoiceMenu((bar_lcd,), "Er personen intern?", ("Ja", "Nei")).menu()
if choice is "Ja":
choice = ChoiceMenu((bar_lcd,), "Is the person an intern?", ("Yes", "No")).menu()
if choice is "Yes":
is_intern = True
while not user_id:
username = KeyboardMenu((bar_lcd, customer_lcd), "Brukernavn").menu()
username = KeyboardMenu((bar_lcd, customer_lcd), "Username").menu()
if not username:
return (None, None) # Empty username means cancel

user = api.get_user(username)
if "detail" in user: # If there is a detail, it means that we didn't get a match.
write((bar_lcd, customer_lcd), "Brukeren finnes ikke")
write((bar_lcd, customer_lcd), "User not found")
time.sleep(2) # Give user some time to read
else:
user_id = user["id"]
elif choice is None:
return (None, None)

write((bar_lcd, customer_lcd), "Registerer kort")
write((bar_lcd, customer_lcd), "Registrating card")
if api.register_card(card_uid, user_id, is_intern):
write((bar_lcd, customer_lcd), "Kort registrert!")
write((bar_lcd, customer_lcd), "Card registerd!")
time.sleep(2) # Give the user some time to read

return (username, is_intern)
Expand All @@ -91,9 +91,9 @@ def get_customer(card_uid):

# The card is not in the database
if username is None:
write((customer_lcd,), "Ikke gjenkjent")
choice = ChoiceMenu((bar_lcd,), "Kort ikke gjenkjent", ("Register", "Avbryt")).menu()
if choice is "Avbryt" or choice is None:
write((customer_lcd,), "Not accepted")
choice = ChoiceMenu((bar_lcd,), "Unknown card", ("Register", "Cancle")).menu()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cancel

if choice is "Cancle" or choice is None:
return None

username, is_intern = register_customer(card_uid)
Expand All @@ -114,8 +114,8 @@ def display_info(customer):

if customer.intern:
output += "Name: %s\n" % customer.username
output += "Bonger: %2d\n" % customer.vouchers
output += "Kaffe: %2d" % customer.coffee_vouchers
output += "Vouchers: %2d\n" % customer.vouchers
output += "Coffee: %2d" % customer.coffee_vouchers

write((bar_lcd,), output)
# We don't want to display the username on the customer screen
Expand All @@ -125,21 +125,21 @@ def display_info(customer):


def register_use(identifier, amount, api_method):
write((bar_lcd, customer_lcd), "Trekker %d bonger" % amount)
write((bar_lcd, customer_lcd), "Witdrawing %d vouchers" % amount)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Withdrawing


if api_method(identifier, amount):
write((bar_lcd, customer_lcd), "%d bonger trukket" % amount)
write((bar_lcd, customer_lcd), "%d vouchers withdrawn" % amount)
else:
write((bar_lcd, customer_lcd), "Ikke nok bonger")
write((bar_lcd, customer_lcd), "Not enough vouchers")


def register_vouchers(card_uid, amount):
write((bar_lcd, customer_lcd), "Legger til %d bonger" % amount)
write((bar_lcd, customer_lcd), "Adding %d vouchers" % amount)

if api.register_coffee_vouchers(card_uid, amount):
write((bar_lcd, customer_lcd), "%d bonger lagt til" % amount)
write((bar_lcd, customer_lcd), "%d vouchers added" % amount)
else:
write((bar_lcd, customer_lcd), "Feil D:")
write((bar_lcd, customer_lcd), "Wrong D:")


def buy_action():
Expand All @@ -153,15 +153,15 @@ def buy_action():
display_info(customer)

# Get amount of bongs to remove
amount = AmountMenu((bar_lcd,), "Antall a fjerne", clean=False, position=3).menu()
amount = AmountMenu((bar_lcd,), "Amount to withdraw", clean=False, position=3).menu()
if not amount:
return

# Remove x amount of bongs from customer
voucher_type = None
if customer.intern:
voucher_type = ChoiceMenu((bar_lcd,), "Hva slags bong?", ("Internbong", "Kaffebong")).menu()
if voucher_type is "Internbong":
voucher_type = ChoiceMenu((bar_lcd,), "What type?", ("Internvoucher", "Coffeevoucher")).menu()
if voucher_type is "Internvoucher":
register_use(customer.username, amount, api.use_vouchers)
else:
register_use(card_uid, amount, api.use_coffee_vouchers)
Expand All @@ -188,11 +188,11 @@ def register_action():
while True:
choice = ChoiceMenu(
(bar_lcd,),
"Hva vil du gjore?",
("Uttak", "Kjop kaffebonger")
"What do you want to do?",
("Withdraw", "Buy coffee vouchers")
).menu()

if choice is "Uttak":
if choice is "Withdraw":
buy_action()
elif choice is "Kjop kaffebonger":
elif choice is "Buy coffee vouchers":
register_action()