This commit is contained in:
Trygve Magnus Ræder 2011-03-06 20:15:38 +00:00
parent 490c3c3ef7
commit 0fd8de7ad3
2 changed files with 17 additions and 2 deletions

BIN
data

Binary file not shown.

View File

@ -6,6 +6,7 @@ from sqlalchemy.sql import func
from sqlalchemy import desc from sqlalchemy import desc
import re, sys, os, traceback, signal, readline import re, sys, os, traceback, signal, readline
from helpers import * from helpers import *
import datetime
exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q'] exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q']
help_commands = ['help', '?'] help_commands = ['help', '?']
@ -16,6 +17,11 @@ restart_commands = ['restart']
low_credit_warning_limit = -100 low_credit_warning_limit = -100
def time():
now=datetime.datetime.now()
out=str(now.day)+'-'+str(now.month)+'-'+str(now.year)
return(out)
class ExitMenu(Exception): class ExitMenu(Exception):
pass pass
@ -135,6 +141,7 @@ class Menu():
continue continue
if result in context_commands: if result in context_commands:
self.show_context() self.show_context()
print 'hei hello'
continue continue
if result in faq_commands: if result in faq_commands:
FAQMenu().execute() FAQMenu().execute()
@ -851,10 +858,15 @@ When finished, write an empty line to confirm the purchase.
self.print_purchase() self.print_purchase()
for t in self.purchase.transactions: for t in self.purchase.transactions:
print 'User %s\'s credit is now %d kr' % (t.user.name, t.user.credit) print 'User %s\'s credit is now %d kr' % (t.user.name, t.user.credit)
if (t.user.credit < low_credit_warning_limit and thing.card != '42'): if (t.user.credit < low_credit_warning_limit and t.user.card != '11122233'):
print ('USER %s HAS LOWER CREDIT THAN %d, AND SHOULD CONSIDER PUTTING SOME MONEY IN THE BOX.' print ('USER %s HAS LOWER CREDIT THAN %d, AND SHOULD CONSIDER PUTTING SOME MONEY IN THE BOX.'
% (t.user.name, low_credit_warning_limit)) % (t.user.name, low_credit_warning_limit))
self.pause() self.pause()
#skriver til log
#print Product.price
#with open("dibbler-out.txt", "a") as f:
# f.write("purchase|"+ time() +"|"+self.purchase.entries[0].product.name+"|"+t.user.name+"|+str(Product.price)+|"+'-1'+"|\n")
return True return True
def complete_input(self): def complete_input(self):
@ -1062,6 +1074,9 @@ def restart():
if not conf.stop_allowed: if not conf.stop_allowed:
signal.signal(signal.SIGTSTP, signal.SIG_IGN) signal.signal(signal.SIGTSTP, signal.SIG_IGN)
main = Menu('Dibbler main menu', main = Menu('Dibbler main menu',
items=[BuyMenu(), items=[BuyMenu(),
ProductListMenu(), ProductListMenu(),