admin page list users
This commit is contained in:
parent
3ba5d6820d
commit
d7af4c92a4
14 changed files with 65 additions and 115 deletions
|
@ -31,6 +31,12 @@ def after_request(response):
|
|||
@admin.route("/", methods=['GET'])
|
||||
@login_required
|
||||
@admin_required
|
||||
def index():
|
||||
return redirect(url_for('admin.list_users'))
|
||||
|
||||
@admin.route("/listitems", methods=['GET'])
|
||||
@login_required
|
||||
@admin_required
|
||||
def list_items():
|
||||
alldeployments = Deployment.query.order_by(Deployment.user_id.desc()).all()
|
||||
alldomains = Domain.query.order_by(Domain.user_id.desc()).all()
|
||||
|
@ -135,10 +141,19 @@ def list_transactions():
|
|||
def transaction(user_pid=0):
|
||||
cuser = User.query.filter_by(pid=user_pid).first()
|
||||
transactions = cuser.inv_transactions.order_by(Transaction.date_created.desc()).all()
|
||||
translist = []
|
||||
|
||||
labelslist = ['today']
|
||||
translist = [cuser.wallet]
|
||||
prevvalue = cuser.wallet
|
||||
for tr in transactions:
|
||||
translist.insert(0, tr.value)
|
||||
labelslist.insert(0, str(tr.date_created.strftime('%d.%m')))
|
||||
translist.insert(0, prevvalue - tr.value)
|
||||
prevvalue -= tr.value
|
||||
|
||||
current_app.logger.info('[{}] transactions: {}'.format(cuser.email, translist))
|
||||
return render_template('uinvoice/transactions.html', transactions=transactions, translist=translist)
|
||||
if len(labelslist) <= 1:
|
||||
labelslist.insert(0, 'before')
|
||||
translist.insert(0, 0)
|
||||
|
||||
#current_app.logger.info('[{}] transactions: {} {} '.format(cuser.email, translist, labelslist))
|
||||
return render_template('uinvoice/transactions.html', transactions=transactions, translist=translist, labelslist=labelslist)
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ class User(db.Model, UserMixin):
|
|||
group = db.Column(db.String(24), default='User')
|
||||
language = db.Column(db.String(2), default='BG')
|
||||
wallet = db.Column(db.Float)
|
||||
overdraft = db.Column(db.Float)
|
||||
currency = db.Column(db.String(3), default='BGN')
|
||||
|
||||
inv_deployments = db.relationship('Deployment', backref='owner', lazy='dynamic')
|
||||
|
|
|
@ -51,7 +51,7 @@ def profile():
|
|||
form.twofactor.data = current_user.twofactor
|
||||
|
||||
wallet = "%.2f" % round(current_user.wallet, 3)
|
||||
current_app.logger.info('[{}] wallet: {}'.format(current_user.email, wallet))
|
||||
#current_app.logger.info('[{}] wallet: {}'.format(current_user.email, wallet))
|
||||
|
||||
return render_template('settings/profile.html', page=page, form=form, wallet=wallet)
|
||||
|
||||
|
|
BIN
app/static/images/createvm.gif
Normal file
BIN
app/static/images/createvm.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 251 KiB |
|
@ -2,8 +2,8 @@
|
|||
<div class="panel panel-warning" id="prxadmin">
|
||||
<div class="panel-heading">Admin Pages</div>
|
||||
<div class="panel-body">
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('admin.list_items') }}','_self')"><span class="glyphicon glyphicon-list" aria-hidden="true"></span> Items List</button>
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('admin.list_users') }}','_self')"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Users List</button>
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('admin.list_items') }}','_self')"><span class="glyphicon glyphicon-list" aria-hidden="true"></span> Items List</button>
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('admin.list_transactions') }}','_self')"><span class="glyphicon glyphicon-usd" aria-hidden="true"></span> Transaction List</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -26,9 +26,11 @@
|
|||
<td>{{ usr.email }}</td>
|
||||
<td>{{ moment(usr.last_seen).format('lll') }}</td>
|
||||
<td>{{ usr.last_ip }}</td>
|
||||
<td><a href="{{ url_for('admin.charge', user_pid=usr.pid) }}">{{ usr.wallet }}</a></td>
|
||||
<td><a href="{{ url_for('admin.dashboard', user_pid=usr.pid) }}">Dashboard</a></td>
|
||||
</td>
|
||||
<td>{{ usr.wallet }}<td>
|
||||
<td><a href="{{ url_for('admin.charge', user_pid=usr.pid) }}" data-toggle="tooltip" title="Add Funds"><span class="glyphicon glyphicon-plus"></span></a>
|
||||
<a href="{{ url_for('admin.transaction', user_pid=usr.pid) }}" data-toggle="tooltip" title="List Transactions"><span class="glyphicon glyphicon-credit-card"></span></a>
|
||||
<a href="{{ url_for('admin.dashboard', user_pid=usr.pid) }}" data-toggle="tooltip" title="Show Dashboard"><span class="glyphicon glyphicon-modal-window"></span></a>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
{% block navbar %}
|
||||
<div class="container-fluid navbar-inverse navbar-fixed-top">
|
||||
<!-- Brand and toggle get grouped for better mobile display -->
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
{% if not current_user.is_authenticated %}
|
||||
<a class="navbar-brand" href="{{ url_for('vmanager.index') }}" rel="home"><span><img style="max-width:100px; margin-top: -7px;" src="../static/images/hex24.png"></span> proxmaster</a>
|
||||
{% else %}
|
||||
<a class="navbar-brand" href="{{ url_for('vmanager.index') }}" rel="home"><span><img style="max-width:100px; margin-top: -7px;" src="../static/images/hex24.png"></span> proxmaster</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
|
||||
{% if current_user.is_authenticated %}
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-togle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Solution Market<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{{ url_for('vmanager.market') }}">Applications</a></li>
|
||||
<li><a href="{{ url_for('vmanager.market') }}">Schemas</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Community<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{{ url_for('vmanager.dashboard') }}">Groups</a></li>
|
||||
<li><a href="{{ url_for('vmanager.dashboard') }}">Blog</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="#">r5</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{% if not current_user.is_authenticated %}
|
||||
<li><a href="{{ url_for('auth.register') }}">Register</a></li>
|
||||
<li><a href="{{ url_for('auth.login') }}">Login</a></li>
|
||||
{% else %}
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><img class="avatar" src="{{ current_user.gravatar(20) }}"> {{ current_user.email }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li><a href="{{ url_for('vmanager.dashboard') }}"><span class="glyphicon glyphicon-eye-open"></span> Dashboard</a></li>
|
||||
<li><a href="{{ url_for('vmanager.profile') }}"><span class="glyphicon glyphicon-flag"></span> Policy</a></li>
|
||||
<li><a href="{{ url_for('vmanager.profile') }}"><span class="glyphicon glyphicon-list"></span> Drafts</a></li>
|
||||
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="{{ url_for('vmanager.profile') }}"><span class="glyphicon glyphicon-user"></span> Profile</a></li>
|
||||
<li><a href="{{ url_for('vmanager.profile') }}"><span class="glyphicon glyphicon-question-sign"></span> Help</a></li>
|
||||
<li><a href="{{ url_for('vmanager.profile') }}"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
|
||||
<li><a href="{{ url_for('auth.logout') }}"><span class="glyphicon glyphicon-off"></span> Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div><!-- /.navbar-collapse -->
|
||||
</div><!-- /.container-fluid -->
|
||||
{% endblock %}
|
||||
|
||||
|
|
@ -40,8 +40,8 @@
|
|||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{% if not current_user.is_authenticated %}
|
||||
<li><a href="{{ url_for('auth.register') }}">Register</a></li>
|
||||
<li><a href="{{ url_for('auth.login') }}">Login</a></li>
|
||||
<li><a href="{{ url_for('auth.register') }}"><span class="glyphicon glyphicon-pencil"></span> Register</a></li>
|
||||
<li><a href="{{ url_for('auth.login') }}"><span class="glyphicon glyphicon-lock"></span> Login</a></li>
|
||||
{% else %}
|
||||
{% if current_user.is_administrator() %}
|
||||
<li><a href="{{ url_for('admin.list_items') }}"><span class="glyphicon glyphicon-wrench"></span> Admin Panel</a></li>
|
||||
|
@ -49,7 +49,7 @@
|
|||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><img class="avatar" src="{{ current_user.gravatar(20) }}"> {{ current_user.email }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{{ url_for('vmanager.dashboard') }}"><span class="glyphicon glyphicon-eye-open"></span> Dashboard</a></li>
|
||||
<li><a href="{{ url_for('vmanager.dashboard') }}"><span class="glyphicon glyphicon-modal-window"></span> Dashboard</a></li>
|
||||
<li><a href="{{ url_for('uinvoice.transactions') }}"><span class="glyphicon glyphicon-list-alt"></span> Transactions</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="{{ url_for('settings.profile') }}"><span class="glyphicon glyphicon-user"></span> Profile</a></li>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="panel-heading">Details</div>
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
<b>Member Since:</b> {{ moment(current_user.member_since).local().fromNow() }}<br />
|
||||
<b>Member Since:</b> {{ moment(current_user.member_since).fromNow() }}<br />
|
||||
<b>Group:</b> {{ current_user.group }}<br />
|
||||
<b>2-Factor:</b> {{ current_user.twofactor }}<br />
|
||||
<a href="/auth/change-password">Change Password</a>
|
||||
|
|
|
@ -25,8 +25,6 @@ $("#{{ form.org_account.id }}").click(function() {
|
|||
{% endblock %}
|
||||
|
||||
{% block page_content %}
|
||||
<div class="container-fluid">
|
||||
<br />
|
||||
<div class="row">
|
||||
{% block sidebar %}
|
||||
<div class="col-md-4">
|
||||
|
|
|
@ -10,9 +10,8 @@ var ctx = document.getElementById("transchart").getContext('2d');
|
|||
var myChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: {{ labelslist }},
|
||||
labels: {{ labelslist | safe }},
|
||||
datasets: [{
|
||||
label: "History",
|
||||
data: {{ translist }},
|
||||
fill: false,
|
||||
borderColor: "rgb(75, 192, 192)",
|
||||
|
@ -23,6 +22,9 @@ var myChart = new Chart(ctx, {
|
|||
// Overrides the global setting
|
||||
mode: 'index'
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
|
|
|
@ -113,6 +113,14 @@ addEventListener("DOMContentLoaded", function() {
|
|||
{% endblock %}
|
||||
|
||||
{% block page_content %}
|
||||
{% if current_user.fresh_user == True %}
|
||||
<div class="row">
|
||||
<center>
|
||||
<img class="img-responsive img-rounded" src="{{ url_for('static', filename='images/createvm.gif') }}" alt="ping">
|
||||
</center><br/>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-12">
|
||||
|
@ -153,7 +161,7 @@ addEventListener("DOMContentLoaded", function() {
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button class="btn btn-default"><span class="glyphicon glyphicon-plus" aria-hiddent="true"></span> Create</button>
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('vmanager.dashboard') }}')"><span class="glyphicon glyphicon-plus" aria-hiddent="true"></span> Create</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -185,7 +193,7 @@ addEventListener("DOMContentLoaded", function() {
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('main.index') }}')"><span class="glyphicon glyphicon-plus" aria-hiddent="true"></span> Order</button>
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('vmanager.dashboard') }}')"><span class="glyphicon glyphicon-plus" aria-hiddent="true"></span> Order</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -213,7 +221,7 @@ addEventListener("DOMContentLoaded", function() {
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('main.index') }}')"><span class="glyphicon glyphicon-plus" aria-hiddent="true"></span> Order</button>
|
||||
<button class="btn btn-default" onclick="window.open('{{ url_for('vmanager.dashboard') }}')"><span class="glyphicon glyphicon-plus" aria-hiddent="true"></span> Order</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -243,7 +251,7 @@ addEventListener("DOMContentLoaded", function() {
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--<button class="btn btn-default" onclick="window.open('{{ url_for('main.index') }}')"><span class="glyphicon glyphicon-plus" aria-hiddent="true"></span> Assign</button> -->
|
||||
<!--<button class="btn btn-default" onclick="window.open('{{ url_for('vmanager.dashboard') }}')"><span class="glyphicon glyphicon-plus" aria-hiddent="true"></span> Assign</button> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,34 +9,27 @@ from ..email import send_email
|
|||
from .. import db
|
||||
from ..models import User, Transaction
|
||||
|
||||
#INVOICES
|
||||
#@uinvoice.route('/charge', methods=['GET', 'POST'])
|
||||
#@login_required
|
||||
#def charge():
|
||||
# """ generate new invoice based on user request """
|
||||
# unpaid_invoices = Order.query.filter_by(user_id=current_user.pid).filter_by(paid=False).all()
|
||||
# if unpaid_invoices != []:
|
||||
# flash('You have unpaid invoices')
|
||||
# return redirect(url_for('uinvoice.documents'))
|
||||
# page = { 'title': 'Charge Funds' }
|
||||
# form = ChargeForm()
|
||||
# if form.validate_on_submit():
|
||||
# newinvoice = Order(amount=form.invoice_amount.data, user_id=current_user.pid)
|
||||
# db.session.add(newinvoice)
|
||||
# db.session.commit()
|
||||
# return redirect(url_for('uinvoice.documents'))
|
||||
# return render_template('uinvoice/charge.html', page=page, form=form)
|
||||
|
||||
@uinvoice.route('/transactions', methods=['GET'])
|
||||
@login_required
|
||||
def transactions():
|
||||
page = { 'title': 'Payment Transaction' }
|
||||
transactions = Transaction.query.filter_by(user_id=current_user.pid).order_by(Transaction.date_created.asc()).all()
|
||||
translist = []
|
||||
for tr in transactions:
|
||||
translist.insert(0, tr.value)
|
||||
return render_template('uinvoice/transactions.html', page=page, transactions=transactions, translist=translist)
|
||||
cuser = current_user
|
||||
transactions = Transaction.query.filter_by(user_id=cuser.pid).order_by(Transaction.date_created.asc()).limit(100)
|
||||
|
||||
labelslist = ['today']
|
||||
translist = [cuser.wallet]
|
||||
prevvalue = cuser.wallet
|
||||
for tr in transactions:
|
||||
labelslist.insert(0, str(tr.date_created.strftime('%d.%m')))
|
||||
translist.insert(0, prevvalue - tr.value)
|
||||
prevvalue -= tr.value
|
||||
|
||||
if len(labelslist) <= 1:
|
||||
labelslist.insert(0, 'before')
|
||||
translist.insert(0, 0)
|
||||
|
||||
#current_app.logger.info('[{}] transactions: {} {} '.format(cuser.email, translist, labelslist))
|
||||
return render_template('uinvoice/transactions.html', transactions=transactions, translist=translist, labelslist=labelslist)
|
||||
|
||||
@uinvoice.route('/order/<int:document_id>', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
|
|
|
@ -174,7 +174,8 @@ def dashboard():
|
|||
send_email(current_app.config['MAIL_USERNAME'], 'Cube {} is unreachable'.format(cubeid),
|
||||
'vmanager/email/adm_unreachable', user=current_user, cubeid=cubeid )
|
||||
|
||||
current_app.logger.info('[{}] deployments: {}, services: {}, domains: {}, addresses: {}'.format(current_user.email, inv_deploynames, inv_services, inv_domains, inv_addresses ))
|
||||
#current_app.logger.info('[{}] deployments: {}, services: {}, domains: {}, addresses: {}'.format(current_user.email, inv_deploynames, inv_services, inv_domains, inv_addresses ))
|
||||
current_app.logger.info('[{}] dashboard loaded.'.format(current_user.email))
|
||||
return render_template('vmanager/dashboard.html', rrd=rrd, status=statuses, inv_deployments=deployments, inv_services=services, inv_domains=domains, inv_addresses=addresses)
|
||||
|
||||
@vmanager.route('/vmvnc/<int:vmid>')
|
||||
|
|
Loading…
Reference in a new issue