Esempio n. 1
0
def manageproducts():
    page = getIntQueryParam(request, 1)
    per_page = app.config['PER_PAGE']
    q = Product.query.order_by(Product.active.desc())
    s = request.args.get('search')
    if s:
        q = q.filter(Product.description.like(f'%{s}%'))
    products = q.paginate(page,per_page,error_out=False)
    return render_template('admin/manage_products.html', products=products, searchterm=s)
Esempio n. 2
0
def manageusers():
    page = getIntQueryParam(request, 1)
    per_page = app.config['PER_PAGE']
    q = User.query.order_by(User.active.desc(), User.id.desc())
    s = request.args.get('search')
    if s:
        q = q.filter(or_(User.username.like(f'%{s}%'), User.email.like(f'%{s}%')))
    users = q.paginate(page,per_page,error_out=False)
    return render_template('admin/manage_users.html', users=users)
Esempio n. 3
0
def invoice():
    page = getIntQueryParam(request, 1)
    per_page = app.config['PER_PAGE']
    invoices = db.session.query(Invoice).join(
        User, User.id == Invoice.user_id).filter(
            User.id == current_user.id).order_by(Invoice.paid,
                                                 Invoice.date.desc()).paginate(
                                                     page,
                                                     per_page,
                                                     error_out=False)
    return render_template('invoices.html', invoices=invoices)
Esempio n. 4
0
def offers():
    if not current_user.paypal:
        flash(_('Bitte hinterlege deine PayPal.me Kennung'))
        return redirect(url_for('auth.editself'))
    page = getIntQueryParam(request, 1)
    per_page = app.config['PER_PAGE']
    q = Offer.query
    if not current_user.has_role('admin') or not request.args.get('all'):
        q = q.filter(Offer.user == current_user)
    offers = q.order_by(Offer.created.desc()).paginate(page,
                                                       per_page,
                                                       error_out=False)
    return render_template('offers.html', offers=offers)
Esempio n. 5
0
def overview():
    page = getIntQueryParam(request, 1)
    per_page = app.config['PER_PAGE']
    cons = Consumption.query.filter(
        and_(Consumption.user_id == current_user.id,
             Consumption.billed == False)).order_by(desc(
                 Consumption.time)).paginate(page, per_page, error_out=False)

    sum = db.engine.execute(text(
        'select sum(amount * price) from consumption where user_id = :uid and billed = 0'
    ),
                            uid=current_user.id).fetchone()
    return render_template('overview.html',
                           summed=format_curr(sum[0] or 0),
                           consumptions=cons)