Exemple #1
0
def add_location():
    form = AddLocationForm(request.form)
    if request.method == "POST" and form.validate():
        new_location = Location(name=form.name.data)
        db.session.add(new_location)
        db.session.commit()
        flash("New location was successfully added")
        return redirect(url_for("list_locations"))
    return render_template("add_location.html", form=form)
def add_location():
	## Validate and collect the form data
	add_form = AddLocationForm()
	if add_form.validate_on_submit():
		name = add_form.name.data
		description = add_form.description.data
		category = add_form.category.data
		visit.add(name, description, category)

	## Redirect to locations route function
	return redirect(url_for("locations", category="recommended", _external=True, _scheme='https'))
Exemple #3
0
def add_location():
    ## Validate and collect the form data
    add_form = AddLocationForm()
    if add_form.validate_on_submit():
        name = add_form.name.data
        description = add_form.description.data
        category = add_form.category.data
        visit.add(name, description, category)

    ## Redirect to locations route function
    return redirect(url_for("locations", category=category))
def addLocation():
    locationForm = AddLocationForm()
    if locationForm.validate_on_submit():

        location = Location(int(locationForm.location_id.data))
        request = location.addLocation(locationForm.name.data, locationForm.minimum_required.data,
                                       locationForm.maximum_required.data)
        if request is True:
            return redirect(url_for('viewLocations'))

    return render_template("location.html", form=locationForm)
def locations(category):
	locations = visit.get_list_by_category(category)
	## Check the request for form data and process

	if request.method == "POST":
		[(name, action)] = request.form.items()

		if action == UP_ACTION:
			visit.moveup(name)
		elif action == DEL_ACTION:
			visit.delete(name)
	## Return the main template with variables
	return render_template("locations.html", category=category, categories=categories, locations=locations,
						   add_location=AddLocationForm())
def add_location():
    ## Validate and collect the form data
    add_form = AddLocationForm()
    category = add_form.category.data
    #if add_form.validate_on_submit():
    if True:
        name = add_form.name.data
        description = add_form.description.data
        category = add_form.category.data
        visit.add(name, description, category)

    #visit.add("testing if statement", "test", "recommended")
    ## Redirect to locations route function
    return redirect(
        url_for('locations',
                category=category,
                _external=True,
                _scheme='https'))