Commit 99b081bf authored by Francesca Sargent 's avatar Francesca Sargent
Browse files

Adding edit utility for Cuisine->Methods

parent 81ee32f2
......@@ -84,12 +84,13 @@ def poststuff(type):
if current_user.can(Permission.WRITE_ARTICLES) and \
form.validate_on_submit():
methods = [Method(name=form.methods.data, author=current_user._get_current_object())]
methods = [Method(name=form.methods.data, timestamp='now', author=current_user._get_current_object())]
cuisine = Cuisine(name=form.name.data, description=form.description.data,
methods=methods,
author=current_user._get_current_object())
db.session.add(cuisine)
db.session.flush()
return redirect(url_for('.index'))
if type == 'method':
......@@ -100,7 +101,6 @@ def poststuff(type):
name=form.name.data,
description=form.description.data,
method_text=form.method_text.data,
# cuisines=form.cuisine.data,
author=current_user._get_current_object())
db.session.add(method)
return redirect(url_for('.index'))
......@@ -117,7 +117,6 @@ def autocompletecuisine():
cuisines=[(cuisine.name)
for cuisine in Cuisine.query.order_by(Cuisine.name).all()]
# main.logger.debug(search)
return jsonify(json_list=cuisines)
@main.route('/autocompletemethod',methods=['GET'])
......@@ -126,7 +125,6 @@ def autocompletemethod():
methods=[(method.name)
for method in Method.query.order_by(Method.name).all()]
# main.logger.debug(search)
return jsonify(json_list=methods)
#Recipe Page#
......@@ -328,10 +326,9 @@ def editcuisine(id):
cuisine.name = form.name.data
cuisine.description = form.description.data
if Method.query.filter(Method.name == form.methods.data).first() != None:
methods = [Method.query.filter(Method.name == form.methods.data).first()]
else:
methods = [Method(name=form.methods.data, description='', method_text='', cuisines=[Cuisine.query.filter(Cuisine.name == form.name.data).first()],author=current_user._get_current_object())]
methods = [Method(name=form.methods.data, author=current_user._get_current_object())]
cuisine.methods.extend(methods)
db.session.add(cuisine)
flash('The cuisine has been updated.')
......
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