def tc_today(n=1): """ generate n table codes for today """ for i in range(0,n): tcode = str(uuid.uuid3(uuid.uuid1(), 'digital menu'))[:4] if tcode == 'dba5': tcode = str(uuid.uuid3(uuid.uuid1(), 'digital menu'))[:4] # insert this table code to use tc = TableCode(code=tcode, date=date.today()) tc.save()
def tc_days(n=30,per_day=10): # generate table codes per day for i in range(0,n): valid_day = date.today()+timedelta(i) tc = TableCode(code='dba5', date=valid_day) tc.save() for j in range(0,per_day): # 10 table codes per day tcode = str(uuid.uuid3(uuid.uuid1(), 'digital menu'))[:4] if tcode == 'dba5': # regenerate since it collides with default tcode = str(uuid.uuid3(uuid.uuid1(), 'digital menu'))[:4] # insert this table code to use tc = TableCode(code=tcode, date=valid_day) tc.save()
from legals.models import Order, MenuItem, MenuItemReview, TableCode, Experiment from django.contrib.auth.models import User import datetime e = Experiment.objects.get(id=1) t = TableCode(code='abcd', experiment = e, date=datetime.date.today()) t.save() t = TableCode.objects.filter(code='abcd')[0] michael = User.objects.get(id=2) o = Order(user=michael, table=t) o.save() # these items have a price that is not fixed for i in [59,52]: m = MenuItem.objects.get(id=i) r = MenuItemReview(item=m, rating=5, comment="This was soo delicious") r.save() o.items.add(r) o.save() o = Order(user=michael, table=t) o.save() for i in [25,15,45]: m = MenuItem.objects.get(id=i) r = MenuItemReview(item=m, rating=5, comment="This was soo delicious") r.save() o.items.add(r) o.save()