Commit 8c43b975 authored by Willard's avatar Willard

Fix more syntax errors

parent 66024726
...@@ -42,6 +42,7 @@ class EditDishView(FormView): ...@@ -42,6 +42,7 @@ class EditDishView(FormView):
self.dish = Dish.query.get(dish_id) self.dish = Dish.query.get(dish_id)
return FormView.dispatch_request(self, stall_id=stall_id, dish_id=dish_id) return FormView.dispatch_request(self, stall_id=stall_id, dish_id=dish_id)
def render_post(self, stall_id, dish_id): def render_post(self, stall_id, dish_id):
form = self.get_form()
self.dish.name = form.name.data self.dish.name = form.name.data
self.dish.description = form.description.data self.dish.description = form.description.data
self.dish.price = form.price.data self.dish.price = form.price.data
...@@ -49,7 +50,7 @@ class EditDishView(FormView): ...@@ -49,7 +50,7 @@ class EditDishView(FormView):
self.dish.image_path = secure_filename(form.image.data.filename) 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)) form.image.data.save(os.path.join(app.config['UPLOAD_FOLDER'], self.dish.image_path))
db.session.commit() db.session.commit()
return redirect(url_for('view_stall', stall_id=stall.id)) return redirect(url_for('view_stall', stall_id=self.stall.id))
def render_get(self, stall_id, dish_id): def render_get(self, stall_id, dish_id):
form = self.get_form() form = self.get_form()
form.name.data = self.dish.name form.name.data = self.dish.name
......
...@@ -16,8 +16,8 @@ class NewStallView(FormView): ...@@ -16,8 +16,8 @@ class NewStallView(FormView):
decorators = [login_required] decorators = [login_required]
def render_post(self): def render_post(self):
form = self.get_form() form = self.get_form()
stall = Stall(form.name.data, form.description.data, current_user.id, form.location.data) self.stall = Stall(form.name.data, form.description.data, current_user.id, form.location.data)
db.session.add(stall) db.session.add(self.stall)
db.session.commit() db.session.commit()
return redirect(url_for('view_stall', stall_id=self.stall.id)) return redirect(url_for('view_stall', stall_id=self.stall.id))
def render_get(self): def render_get(self):
...@@ -64,7 +64,7 @@ class DeleteStallView(View): ...@@ -64,7 +64,7 @@ class DeleteStallView(View):
stall = Stall.query.get(stall_id) stall = Stall.query.get(stall_id)
db.session.delete(stall) db.session.delete(stall)
db.session.commit() db.session.commit()
return redirect(url_for('view_stall'), stall_id=stall_id) return redirect(url_for('view_stall', stall_id=stall_id))
app.add_url_rule('/stalls', view_func=StallListView.as_view('stalls'), methods=['GET']) app.add_url_rule('/stalls', view_func=StallListView.as_view('stalls'), methods=['GET'])
app.add_url_rule('/stalls/new', view_func=NewStallView.as_view('new_stall')) app.add_url_rule('/stalls/new', view_func=NewStallView.as_view('new_stall'))
......
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