Пример #1
0
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'))
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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'))