Ejemplo n.º 1
0
def show():
    user = User.get_by_id(current_user.id)
    adress = Adress.get_or_none(Adress.user == user.id)
    invoice = Invoice.get_or_none(Invoice.user == user.id)
    ad = False
    inv = False
    if adress:
        ad = True
    if invoice:
        inv = True

    return render_template('users/show.html',
                           inv=inv,
                           invoice=invoice,
                           user=user,
                           ad=ad,
                           adress=adress)
Ejemplo n.º 2
0
def create_invoice():

    name = request.form.get('name')
    street = request.form.get('street')
    housenumber = request.form.get('housenumber')
    postal = request.form.get('postal')
    city = request.form.get('city')
    country = request.form.get('country')
    phone = request.form.get('phone')

    invoice = Invoice.get_or_none(Invoice.user == current_user.id)
    if invoice:
        invoice = Invoice.update(
            name=name,
            street=street,
            housenumber=housenumber,
            postal=postal,
            city=city,
            country=country,
            phone=phone).where(Invoice.user == current_user.id)
        if invoice.execute():
            flash('wijziging is opgeslagen')
            return redirect(url_for('users.show'))
        else:
            flash('wijziging niet opgeslagen')
            return redirect(url_for('users.show'))
    else:
        invoice = Invoice(name=name,
                          street=street,
                          housenumber=housenumber,
                          postal=postal,
                          city=city,
                          country=country,
                          phone=phone,
                          user=current_user.id)
        if invoice.save():
            flash('wijziging is opgeslagen')
            return redirect(url_for('users.show'))
        else:
            flash('wijziging niet opgeslagen')
            return redirect(url_for('users.show'))