add admin order confirm page

This commit is contained in:
deflax 2018-02-26 02:34:00 +02:00
parent 233fe39b32
commit 2c5d46d4b3
8 changed files with 70 additions and 6 deletions

View file

@ -7,7 +7,7 @@ from .forms import ChargeForm, Addr2PoolForm, OrderForm
from .. import db
from ..email import send_email
from ..models import User, Transaction, Server, Deployment, Service, Region, Address, Domain, contact_proxmaster
from ..models import User, Transaction, Order, Server, Deployment, Service, Region, Address, Domain, contact_proxmaster
from ..decorators import admin_required, permission_required
import base64
@ -34,6 +34,12 @@ def after_request(response):
def index():
return redirect(url_for('admin.list_users'))
@admin.route("/listorders", methods=['GET', 'POST'])
@fresh_login_required
@admin_required
def list_orders():
AllOrders = Order.query.all()
return render_template('admin/list_orders.html', orders=AllOrders)
@admin.route("/listdeployments", methods=['GET'])
@fresh_login_required

View file

@ -87,6 +87,7 @@ class User(db.Model, UserMixin):
wallet = db.Column(db.Float)
currency = db.Column(db.String, default='BGN')
inv_transactions = db.relationship('Transaction', backref='owner', lazy='dynamic')
inv_orders = db.relationship('Order', backref='owner', lazy='dynamic')
inv_servers = db.relationship('Server', backref='owner', lazy='dynamic')
inv_deployments = db.relationship('Deployment', backref='owner', lazy='dynamic')

View file

@ -2,7 +2,6 @@
{% block styles %}
{{ super() }}
</style>
{% endblock %}
{% block page_content %}

View file

@ -0,0 +1,58 @@
{% extends "base.html" %}
{% block styles %}
{{ super() }}
{% endblock %}
{% block page_content %}
<div class="row">
{% include "admin/admin_tasks.html" %}
<div class="col-md-12">
<div class="panel panel-danger" id="orders">
<div class="panel-heading">Orders</div>
<div class="panel-body"><p>
<div class="no-more-tables">
<table class="table table-hover table-striped table-condensed cf">
<thead>
<tr>
<!--<th>Region</th>-->
<th>User</th>
<th>Recipe</th>
<th>param 1</th>
<th>param 2</th>
<th>param 3</th>
<th>param 4</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for order in orders %}
<tr>
<!--<td data-title="Region">region1</td>-->
<td data-title="User"><a href="{{ url_for('admin.dashboard', user_pid=order.user_id) }}">{{ order.owner.email }}</a></td>
<td data-title="Recipe"><a href="#" title="{{ order.recipe.description }}">{{ order.recipe.templatefile }}</a></td>
<td data-title="Parameter1">{{ order.parameter1 }}</td>
<td data-title="Parameter2">{{ order.parameter2 }}</td>
<td data-title="Parameter3">{{ order.parameter3 }}</td>
<td data-title="Parameter4">{{ order.parameter4 }}</td>
<td data-title="Status">{{ order.status }}</td>
<td><button class="btn btn-default" onclick="window.open('{{ url_for('vmanager.vmcreate') }}')"><span class="glyphicon glyphicon-plus" aria-hiddent="true"></span> Confirm</button></td>
{% endfor %}
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row">
</div>
</div>
{% endblock %}

View file

@ -1,3 +1,4 @@
<button class="btn btn-danger btn-md" onclick="window.open('{{ url_for('admin.list_orders') }}','_self')"><span class="glyphicon glyphicon-bell" aria-hidden="true"></span> Orders</button>
<button class="btn btn-success btn-md" onclick="window.open('{{ url_for('admin.list_deployments') }}','_self')"><span class="glyphicon glyphicon-hdd" aria-hidden="true"></span> Deployments</button>
<button class="btn btn-success btn-md" onclick="window.open('{{ url_for('admin.list_services') }}','_self')"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Services</button>
<button class="btn btn-primary btn-md" onclick="window.open('{{ url_for('admin.list_users') }}','_self')"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Users</button>

View file

@ -1,5 +1,5 @@
{% block services %}
<div id="no-more-tables">
<div class="no-more-tables">
<table class="table table-hover table-striped table-condensed cf">
<thead>
<tr>

View file

@ -83,7 +83,6 @@
</div>
<div id="misc{{ deploy.machine_id }}" class="tab-pane fade">
<br />
<p>
Unit: {{ deploy.machine_id }}<br />
State: {{ status[deploy.machine_id] }}<br />