def render_admin_page(page=1):
    contact = current_user.contact
    countquery = "SELECT COUNT(*) FROM users WHERE contact = '{}' AND usertype = 'admin'".format(
        contact)
    count = db.session.execute(countquery).fetchall()
    total = count[0][0]

    # PER_PAGE = 10
    # page = request.args.get(get_page_parameter(), type=int, default=1)
    # start = (page-1)*PER_PAGE
    # end = page * PER_PAGE
    pagination = Pagination(bs_version=3,
                            page=page,
                            total=total,
                            per_page=10,
                            record_name='admin')

    page_offset = (page - 1) * 10
    if total < page * 10:
        page_display = total % 10
        pagequery = """SELECT * FROM users WHERE contact = '{}' AND usertype = 'admin'
                         LIMIT '{}' OFFSET '{}'""".format(
            contact, page_display, page_offset)
    else:
        pagequery = """SELECT * FROM users WHERE contact = '{}' AND usertype = 'admin'
                         LIMIT 10 OFFSET '{}'""".format(contact, page_offset)

    results = profileTable(db.session.execute(pagequery))
    return render_template('admin.html',
                           results=results,
                           pagination=pagination,
                           username=current_user.username)
def render_caretaker_profile():
    contact = current_user.contact
    query = "SELECT * FROM users WHERE contact = '{}'".format(contact)
    results = db.session.execute(query)
    table = profileTable(results)
    return render_template('profileCaretaker.html',
                           table=table,
                           username=current_user.username)
Example #3
0
def render_admin_profile():
    print(current_user, flush=True)
    contact = current_user.contact
    query = "SELECT * FROM users WHERE contact = '{}'".format(contact)
    results = db.session.execute(query)
    table = profileTable(results)
    return render_template('profileAdmin.html',
                           table=table,
                           username=current_user.username + " admin")
Example #4
0
def render_admin_page():
    print(current_user, flush=True)
    contact = current_user.contact
    query = "SELECT * FROM users WHERE contact = '{}' AND usertype = 'admin'".format(
        contact)
    results = profileTable(db.session.execute(query))
    return render_template('admin.html',
                           results=results,
                           username=current_user.username + " admin")
def render_owner_profile():
    form = ProfileForm()
    contact = current_user.contact
    query = "SELECT * FROM users WHERE contact = '{}';".format(contact)
    profile = db.session.execute(query).fetchall()
    table = profileTable(profile)
    return render_template("profileOwner.html",
                           profile=profile,
                           form=form,
                           table=table,
                           username=current_user.username)