Commit 9961681f authored by Willard's avatar Willard

Fix errors in dish_view.py

parent 2f7a04c2
...@@ -51,12 +51,15 @@ class EditDishView(FormView): ...@@ -51,12 +51,15 @@ class EditDishView(FormView):
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))
def render_get(self, stall_id, dish_id): def render_get(self, stall_id, dish_id):
form = self.get_form()
form.name.data = self.dish.name form.name.data = self.dish.name
form.description.data = self.dish.description form.description.data = self.dish.description
form.price.data = self.dish.price form.price.data = self.dish.price
return render_template('editdish.html', form=form, stall=self.stall, dish=self.dish) return render_template('editdish.html', form=form, stall=self.stall, dish=self.dish)
def get_form(self): def get_form(self):
return DishRegisterForm() form = DishRegisterForm()
form.dish_type.choices = [(dish_type.id, dish_type.name) for dish_type in DishType.query.all()]
return form
class DeleteDishView(View): class DeleteDishView(View):
decorators = [login_required, dish_validate] decorators = [login_required, dish_validate]
......
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