working pagination only with urls
This commit is contained in:
parent
635e972cd1
commit
8efe280735
3 changed files with 14 additions and 20 deletions
|
@ -1,7 +1,6 @@
|
||||||
from flask import render_template, abort, redirect, url_for, abort, flash, request, current_app, make_response, g
|
from flask import render_template, abort, redirect, url_for, abort, flash, request, current_app, make_response, g
|
||||||
from flask_login import fresh_login_required, login_user, logout_user
|
from flask_login import fresh_login_required, login_user, logout_user
|
||||||
from flask_sqlalchemy import get_debug_queries
|
from flask_sqlalchemy import get_debug_queries
|
||||||
from flask_paginate import Pagination, get_page_parameter
|
|
||||||
|
|
||||||
from . import admin
|
from . import admin
|
||||||
from .forms import ChargeForm, Addr2PoolForm, OrderForm
|
from .forms import ChargeForm, Addr2PoolForm, OrderForm
|
||||||
|
@ -72,19 +71,13 @@ def list_archive():
|
||||||
domains = Domain.query.filter_by(deleted=True).all()
|
domains = Domain.query.filter_by(deleted=True).all()
|
||||||
return render_template('admin/list_archive.html', deployments=deployments, services=services, domains=domains)
|
return render_template('admin/list_archive.html', deployments=deployments, services=services, domains=domains)
|
||||||
|
|
||||||
@admin.route("/listusers", methods=['GET'])
|
@admin.route("/listusers/", defaults={'page': 1})
|
||||||
|
@admin.route("/listusers/<int:page>", methods=['GET'])
|
||||||
@fresh_login_required
|
@fresh_login_required
|
||||||
@admin_required
|
@admin_required
|
||||||
def list_users():
|
def list_users(page):
|
||||||
search = False
|
sqlquery = User.query.filter_by(active=True).order_by(User.last_seen.desc()).paginate(page, current_app.config['ITEMS_PER_PAGE'], error_out=False)
|
||||||
q = request.args.get('q')
|
return render_template('admin/list_users.html', users=sqlquery.items, page=page)
|
||||||
if q:
|
|
||||||
search = True
|
|
||||||
page = request.args.get(get_page_parameter(), type=int, default=1)
|
|
||||||
per_page = 20
|
|
||||||
sqlitems = User.query.filter_by(active=True).order_by(User.last_seen.desc()).all()
|
|
||||||
pagination = Pagination(page=page, per_page=per_page, format_total=True, format_number=True, total=len(sqlitems), search=search, css_framework='foundation', record_name='users')
|
|
||||||
return render_template('admin/list_users.html', users=sqlitems, page=page, per_page=per_page, pagination=pagination)
|
|
||||||
|
|
||||||
@admin.route("/charge/<int:user_pid>", methods=['GET', 'POST'])
|
@admin.route("/charge/<int:user_pid>", methods=['GET', 'POST'])
|
||||||
@fresh_login_required
|
@fresh_login_required
|
||||||
|
@ -146,12 +139,13 @@ def list_servers():
|
||||||
allservers = Server.query.all()
|
allservers = Server.query.all()
|
||||||
return render_template('admin/list_servers.html', servers=allservers)
|
return render_template('admin/list_servers.html', servers=allservers)
|
||||||
|
|
||||||
@admin.route("/listtransactions", methods=['GET'])
|
@admin.route("/listtransactions/", defaults={'page': 1})
|
||||||
|
@admin.route("/listtransactions/<int:page>", methods=['GET'])
|
||||||
@fresh_login_required
|
@fresh_login_required
|
||||||
@admin_required
|
@admin_required
|
||||||
def list_transactions():
|
def list_transactions(page):
|
||||||
alltransactions = Transaction.query.order_by(Transaction.date_created.desc()).all()
|
sqlquery = Transaction.query.order_by(Transaction.date_created.desc()).paginate(page, current_app.config['ITEMS_PER_PAGE'], error_out=False)
|
||||||
return render_template('admin/list_transactions.html', transactions=alltransactions)
|
return render_template('admin/list_transactions.html', transactions=sqlquery.items, page=page)
|
||||||
|
|
||||||
@admin.route("/transaction/<int:user_pid>", methods=['GET'])
|
@admin.route("/transaction/<int:user_pid>", methods=['GET'])
|
||||||
@fresh_login_required
|
@fresh_login_required
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
{% if transactions.has_prev %}<a href="{{ url_for('view', page=transactions.prev_num) }}"><< Previous</a>{% else %}<< Previous{% endif %} |
|
||||||
|
{% if transactions.has_next %}<a href="{{ url_for('view', page=transactions.next_num) }}">Next >></a>{% else %}Next >>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
<div class="panel-heading">List Active Users</div>
|
<div class="panel-heading">List Active Users</div>
|
||||||
<div class="panel-body"><p>
|
<div class="panel-body"><p>
|
||||||
<div class="no-more-tables">
|
<div class="no-more-tables">
|
||||||
{{ pagination.info }}
|
|
||||||
{{ pagination.links }}
|
|
||||||
<table class="table table-hover table-striped table-condensed cf">
|
<table class="table table-hover table-striped table-condensed cf">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -24,7 +22,6 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for usr in users %}
|
{% for usr in users %}
|
||||||
{% set rowloop = loop %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td data-title="Email"><font {% if usr.is_administrator() == True %}color="red"{% endif %}>{{ usr.email }}</td>
|
<td data-title="Email"><font {% if usr.is_administrator() == True %}color="red"{% endif %}>{{ usr.email }}</td>
|
||||||
<td data-title="Last Seen">{{ moment(usr.last_seen).format('lll') }}</td>
|
<td data-title="Last Seen">{{ moment(usr.last_seen).format('lll') }}</td>
|
||||||
|
@ -38,7 +35,8 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{ pagination.links }}
|
{% if users.has_prev %}<a href="{{ url_for('view', page=users.prev_num) }}"><< Previous</a>{% else %}<< Previous{% endif %} |
|
||||||
|
{% if users.has_next %}<a href="{{ url_for('view', page=users.next_num) }}">Next >></a>{% else %}Next >>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue