Commit bd3a8a20 authored by Willard's avatar Willard

Fix dish edits not registering correctly

parent d16d55bb
......@@ -62,6 +62,7 @@ class EditDishView(FormView):
def get_form(self):
form = DishRegisterForm()
form.dish_type.choices = [(dish_type.id, dish_type.name) for dish_type in DishType.query.all()]
form.editing = True
return form
class DeleteDishView(View):
......
......@@ -69,13 +69,14 @@ class DishRegisterForm(FlaskForm):
image = FileField('Image')
price = DecimalField('Price', [DataRequired()], render_kw={"placeholder": "Price"})
dish_type = SelectField('Type', coerce=int)
editing = False
def validate(self, editing=False):
if not FlaskForm.validate(self):
return False
dish = Dish.query.filter_by(name=self.name.data).first()
if not editing:
if not self.editing:
if dish is not None:
flash('Dish name is taken!')
return False
......
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