users pagination attempt
This commit is contained in:
parent
4c4623a9a9
commit
19f32a4008
6 changed files with 18 additions and 6898 deletions
|
@ -1,6 +1,7 @@
|
||||||
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
|
||||||
|
@ -75,8 +76,15 @@ def list_archive():
|
||||||
@fresh_login_required
|
@fresh_login_required
|
||||||
@admin_required
|
@admin_required
|
||||||
def list_users():
|
def list_users():
|
||||||
allusers = User.query.filter_by(active=True).order_by(User.last_seen.desc()).all()
|
search = False
|
||||||
return render_template('admin/list_users.html', users=allusers)
|
q = request.args.get('q')
|
||||||
|
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
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
@ -9,6 +9,8 @@
|
||||||
<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>
|
||||||
|
@ -22,7 +24,9 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for usr in users %}
|
{% for usr in users %}
|
||||||
|
{% set rowloop = loop %}
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>{{ loop.index + (page - 1) * per_page }}</td>
|
||||||
<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>
|
||||||
<td data-title="Last IP"><a href="https://apps.db.ripe.net/search/query.html?searchtext={{ usr.last_ip }}" data-toggle="tooltip" title="RIPE Whois Search" target="_blank">{{ usr.last_ip }}</a></td>
|
<td data-title="Last IP"><a href="https://apps.db.ripe.net/search/query.html?searchtext={{ usr.last_ip }}" data-toggle="tooltip" title="RIPE Whois Search" target="_blank">{{ usr.last_ip }}</a></td>
|
||||||
|
@ -35,6 +39,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{{ pagination.links }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -129,7 +129,7 @@ def activate(itemid=0):
|
||||||
if owner.confirmed and form.validate_on_submit():
|
if owner.confirmed and form.validate_on_submit():
|
||||||
total = ppm * form.period.data
|
total = ppm * form.period.data
|
||||||
if owner.wallet < total:
|
if owner.wallet < total:
|
||||||
flash('Activation costs {} {}. Insufficient Funds'.format(total, owner.currency))
|
flash('Activation costs {} {}. Insufficient Funds'.format(total, owner.currency), 'danger')
|
||||||
if current_user.is_administrator():
|
if current_user.is_administrator():
|
||||||
return redirect(url_for('admin.list_users'))
|
return redirect(url_for('admin.list_users'))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
uuid
|
uuid==1.30
|
||||||
alembic==0.9.9
|
alembic==0.9.9
|
||||||
appdirs==1.4.3
|
appdirs==1.4.3
|
||||||
Babel==2.5.3
|
Babel==2.5.3
|
||||||
|
@ -17,6 +17,7 @@ Flask-Login==0.4.1
|
||||||
Flask-Mail==0.9.1
|
Flask-Mail==0.9.1
|
||||||
Flask-Migrate==2.1.1
|
Flask-Migrate==2.1.1
|
||||||
Flask-Moment==0.6.0
|
Flask-Moment==0.6.0
|
||||||
|
Flask-Paginate==0.5.1
|
||||||
Flask-Script==2.0.6
|
Flask-Script==2.0.6
|
||||||
Flask-SQLAlchemy==2.3.2
|
Flask-SQLAlchemy==2.3.2
|
||||||
Flask-WTF==0.14.2
|
Flask-WTF==0.14.2
|
||||||
|
|
Loading…
Reference in a new issue