def s_startsession(i): # Check to see if session exists ? Return session data : create a new one # tag = Tags.select().where(Tags.id == str(hexToDec(i))).first() tag = Tags.select().where(Tags.id == i).first() if tag is not None: if tag.session.first() is None: # No session for this ID exists, create one s = Sessions() s.timeOpened = datetime.datetime.now() s.tag = tag s.save() # Format menu for consumption data = {'menu': []} for x in StoreItems.select().where(StoreItems.store == tag.store): data['menu'].append({ 'name': x.name, 'desc': x.desc, 'id': x.id, 'price': x.price }) return str(dicttoxml.dicttoxml(data, ids=False)) else: flash('Sorry, that tag does not exist') return redirect(url_for('v_index'))
def s_tag(id=None): tag = Tags.select().where(Tags.id == id).first() session['id'] = tag.id storeItems = StoreItems.select().where(StoreItems.store == tag.store) dump = defaultdict(list) for x in storeItems: dump[x.category.name].append({"id": x.id, "name": x.name, "price": x.price, "desc": x.desc}) return json.dumps(dump)
def s_tag(id=None): tag = Tags.select().where(Tags.id == id).first() session['id'] = tag.id storeItems = StoreItems.select().where(StoreItems.store == tag.store) dump = defaultdict(list) for x in storeItems: dump[x.category.name].append({ "id": x.id, "name": x.name, "price": x.price, "desc": x.desc }) return json.dumps(dump)
def s_endsession(i): tag = Tags.select().where(Tags.id == i).first() if tag.session.first() is not None: s = tag.session.first() s.timeClosed = datetime.datetime.now() s.save() # Now migrate it arse = ArchiveSessions() arse.tag = tag arse.timeOpened = s.timeOpened arse.timeClosed = s.timeClosed arse.save() # Now delete the old one # Sessions. return 'Tag %d\'s session was closed!' % tag.id else: return 'Tag %d has no associated session!' % tag.id
def s_startsession(i): # Check to see if session exists ? Return session data : create a new one # tag = Tags.select().where(Tags.id == str(hexToDec(i))).first() tag = Tags.select().where(Tags.id == i).first() if tag is not None: if tag.session.first() is None: # No session for this ID exists, create one s = Sessions() s.timeOpened = datetime.datetime.now() s.tag = tag s.save() # Format menu for consumption data = {'menu': []} for x in StoreItems.select().where(StoreItems.store == tag.store): data['menu'].append({'name': x.name, 'desc': x.desc, 'id': x.id, 'price': x.price}) return str(dicttoxml.dicttoxml(data, ids=False)) else: flash('Sorry, that tag does not exist') return redirect(url_for('v_index'))