Beispiel #1
0
def seed():
    # Delete the table data.
    Item.delete().execute()
    ItemList.delete().execute()

    # Create the initial item list
    item_list = ItemList(name='Main List')
    item_list.save()

    ItemList(name='Secondary List').save()

    # Create items under the item list
    Item(name='Clean the room', item_list=item_list.id).save()
    Item(name='Take out the trash', item_list=item_list.id).save()
    Item(name='Sweep the floors', item_list=item_list.id).save()
Beispiel #2
0
 def getItemList(self, request):
     print "creating Customer"
     c = []
     query1 = Item.query()
     print query1
     entity1 = query1.get()
     print entity1
     for q in query1:
         c.append(self._copyItemsToForm(q))
     return ItemList(itemList=c)
Beispiel #3
0
def add_item(restaurant_id, menu_code):
    form = ItemAddForm()

    if form.validate_on_submit():
        new_menu = ItemList(
            name=form.name.data,
            description=form.description.data,
            price=form.price.data,
            menu_code=menu_code,
        )

        # Commit to the database
        db.session.add(new_menu)
        db.session.commit()

        # Now that it successfully saved to the db, we can save to disk
        save_food_image(form.image.data.read(), restaurant_id, new_menu.item_code)
        return redirect(
            url_for("list_food_items", restaurant_id=restaurant_id, menu_code=menu_code)
        )

    return render_template("item_add.html", form=form)