diff --git a/app/admin.py b/app/admin.py
index b6dceff..b2f8123 100644
--- a/app/admin.py
+++ b/app/admin.py
@@ -4,7 +4,7 @@ from flask.ext import login
from app import app, db
-from models import User, Location, Food, Order, OrderItem
+from models import User, Location, Product, Order, OrderItem
class ModelBaseView(ModelView):
@@ -32,6 +32,6 @@ admin = Admin(app, name='FoodBot', url='/admin', template_mode='bootstrap3')
admin.add_view(UserAdminModel(User, db.session))
admin.add_view(LocationAdminModel(Location, db.session))
-admin.add_view(ModelBaseView(Food, db.session))
+admin.add_view(ModelBaseView(Product, db.session))
admin.add_view(ModelBaseView(Order, db.session))
admin.add_view(ModelBaseView(OrderItem, db.session))
diff --git a/app/create_database.py b/app/create_database.py
index 4be42ca..9b8a6dd 100644
--- a/app/create_database.py
+++ b/app/create_database.py
@@ -20,11 +20,11 @@ blauw_kotje = Location()
blauw_kotje.configure("'t Blauw Kotje", "Top-5-straat Keknet-city", "frietfest.com")
db.session.add(blauw_kotje)
-chili_con_carne = Food()
+chili_con_carne = Product()
chili_con_carne.configure(burrito, "Chili Con Carne", 550)
db.session.add(chili_con_carne)
-medium_pak_frieten = Food()
+medium_pak_frieten = Product()
medium_pak_frieten.configure(blauw_kotje, "Medium Pak Frieten", 220)
db.session.add(medium_pak_frieten)
# To future developers, add yourself here
diff --git a/app/forms.py b/app/forms.py
index 873c9cb..8411c44 100644
--- a/app/forms.py
+++ b/app/forms.py
@@ -28,8 +28,8 @@ class OrderForm(Form):
class OrderItemForm(Form):
- food_id = SelectField('Item', coerce=int)
+ product_id = SelectField('Item', coerce=int)
submit_button = SubmitField('Submit')
def populate(self, location):
- self.food_id.choices = [(i.id, (i.name + ": " + euro(i.price))) for i in location.food]
\ No newline at end of file
+ self.product_id.choices = [(i.id, (i.name + ": " + euro(i.price))) for i in location.products]
\ No newline at end of file
diff --git a/app/models.py b/app/models.py
index f338157..cedbce9 100644
--- a/app/models.py
+++ b/app/models.py
@@ -11,7 +11,7 @@ class User(db.Model):
admin = db.Column(db.Boolean)
bias = db.Column(db.Integer)
runs = db.relationship('Order', backref='courrier', lazy='dynamic')
- orders = db.relationship('OrderItem', backref='user', lazy='dynamic')
+ orderItems = db.relationship('OrderItem', backref='user', lazy='dynamic')
def configure(self, username, admin, bias):
self.username = username
@@ -45,10 +45,9 @@ class Location(db.Model):
name = db.Column(db.String(120))
address = db.Column(db.String(254))
website = db.Column(db.String(120))
- food = db.relationship('Food', backref='location', lazy='dynamic')
+ products = db.relationship('Product', backref='location', lazy='dynamic')
orders = db.relationship('Order', backref='location', lazy='dynamic')
-
def configure(self, name, address, website):
self.name = name
self.address = address
@@ -58,12 +57,12 @@ class Location(db.Model):
return '%s: %s' % (self.name, self.address)
-class Food(db.Model):
+class Product(db.Model):
id = db.Column(db.Integer, primary_key=True)
location_id = db.Column(db.Integer, db.ForeignKey('location.id'))
name = db.Column(db.String(120))
price = db.Column(db.Integer)
- orders = db.relationship('OrderItem', backref='food', lazy='dynamic')
+ orderItems = db.relationship('OrderItem', backref='product', lazy='dynamic')
def configure(self, location, name, price):
@@ -81,7 +80,7 @@ class Order(db.Model):
location_id = db.Column(db.Integer, db.ForeignKey('location.id'))
starttime = db.Column(db.DateTime)
stoptime = db.Column(db.DateTime)
- orders = db.relationship('OrderItem', backref='order', lazy='dynamic')
+ items = db.relationship('OrderItem', backref='order', lazy='dynamic')
def configure(self, courrier, location, starttime, stoptime):
self.courrier = courrier
@@ -94,26 +93,26 @@ class Order(db.Model):
def group_by_user(self):
group = defaultdict(list)
- for item in self.orders:
- group[item.user_id] += [item.food]
+ for item in self.items:
+ group[item.user_id] += [item.product]
return group
def group_by_user_pay(self):
group = defaultdict(int)
- for item in self.orders:
- group[item.user] += item.food.price
+ for item in self.items:
+ group[item.user] += item.product.price
return group
class OrderItem(db.Model):
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
order_id = db.Column(db.Integer, db.ForeignKey('order.id'))
- food_id = db.Column(db.Integer, db.ForeignKey('food.id'))
+ product_id = db.Column(db.Integer, db.ForeignKey('product.id'))
- def configure(self, user, order, food):
+ def configure(self, user, order, product):
self.user = user
self.order = order
- self.food = food
+ self.product = product
def __repr__(self):
return 'OrderItem'
diff --git a/app/templates/order.html b/app/templates/order.html
index 8c8b3fa..5aba8f0 100644
--- a/app/templates/order.html
+++ b/app/templates/order.html
@@ -19,8 +19,8 @@
Stoptime: {{ order.stoptime }}
Total price: {{ total_price|euro }}