예제 #1
0
def door2door_redirect():
    user = h.get_current_user()
    if not user or not user.place:
        return redirect(url_for("dashboard"))

    place = user.place if user.place.type >= PlaceType.get("AC") else user.place.get_parent("AC")
    endpoint = ".door2door" if request.path == "/door2door" else ".make_entry"
    return redirect(url_for(endpoint, place=place))
예제 #2
0
def door2door_redirect():
    user = h.get_current_user()
    if not user or not user.place:
        return redirect(url_for("dashboard"))

    place = user.place if user.place.type >= PlaceType.get(
        "AC") else user.place.get_parent("AC")
    endpoint = ".door2door" if request.path == "/door2door" else ".make_entry"
    return redirect(url_for(endpoint, place=place))
예제 #3
0
파일: views.py 프로젝트: er-anup/cleansweep
def make_entry(place):
    # If place is greater than AC set form to None
    form = forms.Door2DoorForm(place, request.form) if place.type <= PlaceType.get("AC") else None
    if request.method == "POST" and form.validate():
        place.add_door2door_entry(
            name=form.name.data, voters_in_family=form.voters_in_family.data, phone=form.phone.data, town=form.town.data
        )
        db.session.commit()
        return redirect(url_for(".door2door", place=place))
    return render_template("entry_door2door.html", place=place, form=form)
예제 #4
0
def make_entry(place):
    # If place is greater than AC set form to None
    form = forms.Door2DoorForm(
        place, request.form) if place.type <= PlaceType.get("AC") else None
    if request.method == "POST" and form.validate():
        entry = place.add_door2door_entry(
            name=form.name.data,
            voters_in_family=form.voters_in_family.data,
            phone=form.phone.data,
            town=form.town.data,
        )
        db.session.commit()
        signals.door2door_import.send([entry])
        return redirect(url_for(".door2door", place=place))
    return render_template("entry_door2door.html", place=place, form=form)