Commit dd91f897 authored by Willard's avatar Willard

Add type and cuisine id to constructor

parent 99bca4d0
......@@ -18,7 +18,7 @@ class NewDishView(FormView):
def render_post(self, stall_id):
form = self.get_form()
filename = secure_filename(form.image.data.filename)
dish = Dish(form.name.data, form.description.data, form.price.data, self.stall.id, filename)
dish = Dish(form.name.data, form.description.data, form.price.data, self.stall.id, form.dish_type.data, form.dish_cuisine.data, filename)
form.image.data.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
db.session.add(dish)
db.session.commit()
......@@ -47,6 +47,8 @@ class EditDishView(FormView):
self.dish.name = form.name.data
self.dish.description = form.description.data
self.dish.price = form.price.data
self.dish.type_id = form.dish_type.data
self.dish.cuisine_id = form.dish_cuisine.data
if form.image.data.filename is not u'':
self.dish.image_path = secure_filename(form.image.data.filename)
form.image.data.save(os.path.join(app.config['UPLOAD_FOLDER'], self.dish.image_path))
......
......@@ -47,11 +47,13 @@ class Dish(db.Model):
favorites = db.relationship('User', secondary=dish_favorites, backref=db.backref('dish', lazy='dynamic'))
reviews = db.relationship('DishReview', backref='dish', lazy='dynamic')
def __init__(self, name, description, price, stall_id, image_path):
def __init__(self, name, description, price, stall_id, type_id, cuisine_id, image_path):
self.name = name
self.description = description
self.price = price
self.stall_id = stall_id
self.type_id = type_id
self.cuisine_id = cuisine_id
self.image_path = image_path
def average_rating(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment