def edit(loc_id): location = db.Location.get_or_404(loc_id) form = Location_Form(request.form , obj=location) if form.validate_on_submit(): form.populate_obj(location) location.save() return redirect( url_for('locations.show', loc_id = location._id)) return render_template('locations/edit.html', form = form)
def edit(loc_id): location = db.Location.get_or_404(loc_id) form = Location_Form(request.form, obj=location) if form.validate_on_submit(): form.populate_obj(location) location.save() return redirect(url_for('locations.show', loc_id=location._id)) return render_template('locations/edit.html', form=form)
def add(): form = Location_Form() if form.validate_on_submit(): location = Location(name=form.name.data, contact=form.contact.data, desc=form.desc.data, address=form.desc.data, loc=(form.long.data, form.lat.data)) location.save() loc_id = location.mongo_id return redirect(url_for('locations.show', loc_id=location.mongo_id)) return render_template('locations/add.html', form=form)
def add(): form = Location_Form() if form.validate_on_submit(): location = Location(name = form.name.data, contact = form.contact.data, desc = form.desc.data, address = form.desc.data, loc = (form.long.data, form.lat.data) ) location.save() loc_id = location.mongo_id return redirect( url_for('locations.show', loc_id = location.mongo_id)) return render_template('locations/add.html', form = form)