Exemplo n.º 1
0
def package():
    form = ShippingForm()
    if form.validate_on_submit():
        package = Package()
        form.populate_obj(package)
        package.location = package.origin
        package.save()
        Package.advance_all_locations()
        return redirect(url_for('.index'))
    return render_template('shipping_request.html', form=form)
Exemplo n.º 2
0
def new_package():
    form = ShippingForm()
    if form.validate_on_submit():
        data = form.data
        new_package = Package(name=data["name_sender"],
                              recipient=data["name_recipient"],
                              origin=data["origin"],
                              destination=data["destination"],
                              location=data["origin"])
        db.session.add(new_package)
        db.session.commit()
        Package.advance_all_locations()
        return redirect("/")
    return render_template('shipping_request.html', form=form)
def new_package():
    form = Shipping_Form()
    if (form.validate_on_submit()):
        data = form.data
        new_package = Package(sender=data["sender"],
                              recipient=data['recipient'],
                              origin=data['origin'],
                              destination=data['destination'],
                              location=data['origin'])
        db.session.add(new_package)
        db.session.commit()
        Package.advance_all_locations()
        return redirect('/')
    return render_template('shipping_request.html', form=form)
def shipping_request():
    form = ShippingForm()
    if form.validate_on_submit():
        data = form.data
        new_package = Package(sender=data["sender_name"],
                              recipient=data["recipient_name"],
                              origin=data["origin"],
                              destination=data["destination"],
                              location=data["origin"])
        db.session.add(new_package)
        db.session.commit()
        Package.advance_all_locations()
        return redirect(url_for('.index'))
    return render_template("shipping_request.html", form=form)
Exemplo n.º 5
0
def form():
    form = ShippingForm()
    if form.validate_on_submit():
        data = form.data
        new_package = Package(sender=data["sender_name"],
                              recipient=data["recipient_name"],
                              origin=data["origin"],
                              destination=data["destination"],
                              location=data["origin"])
        db.session.add(new_package)
        db.session.commit()

        # DEBUG: Advance Time
        Package.advance_all_locations()
        return redirect('/')
    return render_template('shipping_request.html', form=form)
Exemplo n.º 6
0
def new_package():
    form = ShippingForm()
    form.origin.choices = [(city, city) for city in map.keys()]
    form.destination.choices = [(city, city) for city in map.keys()]

    if form.validate_on_submit():
        Package.advance_all_locations()
        print(form.data)
        data = form.data
        new_package = Package(
            sender=data["sender_name"],
            recipient=data["recipient_name"],
            origin=data["origin"],
            destination=data["destination"],
            location=data["origin"]
        )
        db.session.add(new_package)
        db.session.commit()
        return redirect(url_for(".index"))

    return render_template('shipping_request.html', form=form)
def root_endpoint():
    packages = Package.query.all()
    Package.advance_all_locations()
    return render_template('package_status.html', packages=packages)