Beispiel #1
0
def setup():
    db.drop_all()
    db.create_all()

    user = Users(username='******', email=environ.get('EMAIL_ADDRESS'))
    user.password = environ.get('PASSWORD')

    db.session.add(Tags(name='flask'))
    db.session.add(Tags(name='biology'))
    db.session.add(Tags(name='chemistry'))
    db.session.add(user)

    db.session.commit()
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)
Beispiel #5
0
def upload_tag():
	form = UploadTag()

	if form.validate_on_submit():
		names = form.name.data.split(',')
		for name in names:
			tag = Tags.query.filter_by(name=name).first()
			if not tag:
				db.session.add(Tags(name=name))
				db.session.commit()

		flash('tags uploaded')

		return redirect(url_for('admin.upload_tag'))

	return render_template('admin/upload_tag.html', form=form)
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_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'))
Beispiel #9
0
	def get(self):
		tags = Tags(name=None, id=None, postId=None)
		return tags.get()