rename pid to id

This commit is contained in:
deflax 2024-04-03 20:31:30 +03:00
parent a29ee1bd3a
commit 1e8c520cb7
15 changed files with 28 additions and 32 deletions

View file

@ -31,7 +31,7 @@ def index():
@fresh_login_required
@admin_required
def list_users(page):
sqlquery = User.query.filter_by(active=True).order_by(User.last_seen.desc()).paginate(page=page, per_page=current_app.config['ITEMS_PER_PAGE'], error_out=False)
sqlquery = User.query.filter_by(active=True).order_by(User.last_seen.desc()).paginate(page=page, per_page=int(current_app.config['ITEMS_PER_PAGE']), error_out=False)
return render_template('admin/list_users.html', users=sqlquery.items, page=page)
@admin.route("/listitems", methods=['GET'])

View file

@ -30,7 +30,7 @@ def before_request():
#print('session: %s' % str(session))
if current_user.is_authenticated:
current_user.ping()
#print('request for {} from {}#{}'.format(request.endpoint, current_user.email, current_user.pid))
#print('request for {} from {}#{}'.format(request.endpoint, current_user.email, current_user.id))
if not current_user.confirmed and request.endpoint[:5] != 'auth.' and request.endpoint != 'static':
print(request.endpoint)
return redirect(url_for('auth.unconfirmed'))

View file

@ -25,9 +25,9 @@ from datetime import date, time, datetime
#
# form = OrderForm()
# if form.validate_on_submit():
# region = Region.query.filter_by(pid=int(form.region.data)).first()
# recipe = Recipe.query.filter_by(pid=int(form.recipe.data)).first()
# new_order = Order(user_id=int(current_user.pid), region_id=int(region.pid), recipe_id=int(recipe.pid), parameter1=str(form.alias.data), parameter2=str(form.cpu.data), parameter3=str(form.memory.data), parameter4=str(form.storage.data), status='new')
# region = Region.query.filter_by(id=int(form.region.data)).first()
# recipe = Recipe.query.filter_by(id=int(form.recipe.data)).first()
# new_order = Order(user_id=int(current_user.id), region_id=int(region.id), recipe_id=int(recipe.id), parameter1=str(form.alias.data), parameter2=str(form.cpu.data), parameter3=str(form.memory.data), parameter4=str(form.storage.data), status='new')
# db.session.add(new_order)
# db.session.commit()
# send_email(current_app.config['MAIL_USERNAME'], 'New order from {}'.format(current_user.email),
@ -37,14 +37,14 @@ from datetime import date, time, datetime
# return render_template('panel/deploy.html', form=form)
#DASHBOARD
@panel.route("/dashboard", defaults={'user_pid': 0}, methods=['GET'])
@panel.route("/dashboard/<int:user_pid>", methods=['GET'])
@panel.route("/dashboard", defaults={'user_id': 0}, methods=['GET'])
@panel.route("/dashboard/<int:user_id>", methods=['GET'])
@login_required
def dashboard(user_pid):
if user_pid == 0:
def dashboard(user_id):
if user_id == 0:
cuser = current_user
else:
cuser = User.query.filter_by(id=user_pid).first()
cuser = User.query.filter_by(id=user_id).first()
if cuser == None:
abort(404)
if not current_user.is_administrator():

View file

@ -46,7 +46,7 @@ class EditProfileAdminForm(FlaskForm):
def __init__(self, user, *args, **kwargs):
super(EditProfileAdminForm, self).__init__(*args, **kwargs)
self.role.choices = [(role.pid, role.name)
self.role.choices = [(role.id, role.name)
for role in Role.query.order_by(Role.name).all()]
self.user = user

View file

@ -11,7 +11,7 @@
<div class="panel panel-info">
<div class="panel-heading">Зареждане на сметка</div>
<div class="panel-body">
<form method="POST" action="{{ url_for('admin.charge', user_pid=usr.pid) }}">
<form method="POST" action="{{ url_for('admin.charge', user_id=usr.id) }}">
<p>
Current Value: {{ usr.wallet }}<br />
{{ form.amount.label }} {{ form.amount }}<br />

View file

@ -35,7 +35,7 @@
<!--<td data-title="Region">region1</td>-->
<td data-title="IP">{{ address.ip }}</td>
{% if address.user_id != None %}
<td data-title="Assignee"><a href="{{ url_for('panel.dashboard', user_pid=address.user_id) }}">{{ address.owner.email }}</a></td>
<td data-title="Assignee"><a href="{{ url_for('panel.dashboard', user_id=address.user_id) }}">{{ address.owner.email }}</a></td>
{% else %}
<td></td>
{% endif %}

View file

@ -88,7 +88,7 @@ addEventListener("DOMContentLoaded", function() {
{% endif %}
{% endif %}
{% endif %}
<td><a href="{{ url_for('panel.dashboard', user_pid=deploy.user_id) }}">{{ deploy.owner.email }}</a></td>
<td><a href="{{ url_for('panel.dashboard', user_id=deploy.user_id) }}">{{ deploy.owner.email }}</a></td>
<td>{{ deploy.machine_alias }}</font></td>
<td>{{ deploy.machine_cpu }}</td>
<td>{{ deploy.machine_mem }} MB</td>

View file

@ -54,7 +54,7 @@
<td data-title="Last Charged">{{ moment(deploy.date_last_charge).format('lll') }} ({{ moment(deploy.date_last_charge).fromNow() }})</td>
{% endif %}
<td data-title="Days Left">{{ deploy.daysleft }}</td>
<td data-title="Owner"><a href="{{ url_for('panel.dashboard', user_pid=deploy.user_id) }}">{{ deploy.owner.email }}</a></td>
<td data-title="Owner"><a href="{{ url_for('panel.dashboard', user_id=deploy.user_id) }}">{{ deploy.owner.email }}</a></td>
{% endfor %}
</tbody>
</table>

View file

@ -33,7 +33,7 @@
<tr>
{% endif %}
{% endif %}
<td><a href="{{ url_for('panel.dashboard', user_pid=domain.user_id) }}">{{ domain.owner.email }}</a></td>
<td><a href="{{ url_for('panel.dashboard', user_id=domain.user_id) }}">{{ domain.owner.email }}</a></td>
<td><b><a href="http://{{ domain.fqdn }}">{{ domain.fqdn }}</a></b></td>
<td>{{ domain.date_expire }}</td>
<td>{{ domain.daysleft }}</td>

View file

@ -30,7 +30,7 @@
<tbody>
{% for order in neworders %}
<tr>
<td data-title="User"><a href="{{ url_for('panel.dashboard', user_pid=order.user_id) }}">{{ order.owner.email }}</a></td>
<td data-title="User"><a href="{{ url_for('panel.dashboard', user_id=order.user_id) }}">{{ order.owner.email }}</a></td>
<td data-title="Region">{{ order.region.description }}</td>
<td data-title="Recipe"><a href="#" title="{{ order.recipe.description }}">{{ order.recipe.templatefile }}</a></td>
<td data-title="Parameter1">{{ order.parameter1 }}</td>
@ -38,12 +38,12 @@
<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 btn-success" onclick="window.open('{{ url_for('vmanager.vmcreate', orderid=order.pid) }}','_self');"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Confirm</button></td>
<td><button class="btn btn-default btn-success" onclick="window.open('{{ url_for('vmanager.vmcreate', orderid=order.id) }}','_self');"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Confirm</button></td>
{% endfor %}
{% for order in oldorders %}
<tr>
<td data-title="User"><a href="{{ url_for('panel.dashboard', user_pid=order.user_id) }}">{{ order.owner.email }}</a></td>
<td data-title="User"><a href="{{ url_for('panel.dashboard', user_id=order.user_id) }}">{{ order.owner.email }}</a></td>
<td data-title="Region">{{ order.region.description }}</td>
<td data-title="Recipe"><a href="#" title="{{ order.recipe.description }}">{{ order.recipe.templatefile }}</a></td>
<td data-title="Parameter1">{{ order.parameter1 }}</td>

View file

@ -33,7 +33,7 @@
<td>{{ server.hdd }}</td>
<td>{{ server.address }}</td>
<td>{{ server.region.name }}</td>
<td><a href="{{ url_for('panel.dashboard', user_pid=server.owner.pid) }}">{{ server.owner.email }}</a></td>
<td><a href="{{ url_for('panel.dashboard', user_id=server.owner.id) }}">{{ server.owner.email }}</a></td>
</tr>
</tbody>
{% endfor %}

View file

@ -36,7 +36,7 @@
<tr>
{% endif %}
{% endif %}
<td data-title="Owner"><a href="{{ url_for('panel.dashboard', user_pid=service.user_id) }}">{{ service.owner.email }}</a></td>
<td data-title="Owner"><a href="{{ url_for('panel.dashboard', user_id=service.user_id) }}">{{ service.owner.email }}</a></td>
<td data-title="Category">{{ service.category }}</td>
<td data-title="Description">{{ service.description }}</td>
<td data-title="Price">{{ service.price }}</td>

View file

@ -25,18 +25,18 @@
{% for transaction in transactions %}
{% if transaction.value > 0 %}
<tr class="default">
<td data-title="ID">{{ transaction.pid }}</td>
<td data-title="ID">{{ transaction.id }}</td>
<td data-title="Description">{{ transaction.description }}</td>
<td data-title="Amount">{{ transaction.value }} {{ transaction.currency }}</td>
<td data-title="Date">{{ moment(transaction.date_created).format('lll') }}</td>
<td data-title="User"><a href="{{ url_for('admin.transaction', user_pid=transaction.owner.pid) }}">{{ transaction.owner.email }}</a></td>
<td data-title="User"><a href="{{ url_for('admin.transaction', user_id=transaction.owner.id) }}">{{ transaction.owner.email }}</a></td>
{% else %}
<tr class="default">
<td data-title="ID">{{ transaction.pid }}</td>
<td data-title="ID">{{ transaction.id }}</td>
<td data-title="Description">{{ transaction.description }}</td>
<td data-title="Amount">{{ transaction.value }} {{ transaction.currency }}</td>
<td data-title="Date">{{ moment(transaction.date_created).format('lll') }}</td>
<td data-title="User"><a href="{{ url_for('admin.transaction', user_pid=transaction.owner.pid) }}">{{ transaction.owner.email }}</a></td>
<td data-title="User"><a href="{{ url_for('admin.transaction', user_id=transaction.owner.id) }}">{{ transaction.owner.email }}</a></td>
{% endif %}
</tr>
</tbody>

View file

@ -28,9 +28,9 @@
<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="Wallet">{{ usr.wallet }}</td>
<td data-title="Currency">{{ usr.currency }}</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('panel.dashboard', user_pid=usr.pid) }}" data-toggle="tooltip" title="Show Dashboard"><span class="glyphicon glyphicon-modal-window"></span></a>
<td><a href="{{ url_for('admin.charge', user_id=usr.id) }}" data-toggle="tooltip" title="Add Funds"><span class="glyphicon glyphicon-plus"></span></a>
<a href="{{ url_for('admin.transaction', user_id=usr.id) }}" data-toggle="tooltip" title="List Transactions"><span class="glyphicon glyphicon-credit-card"></span></a>
<a href="{{ url_for('panel.dashboard', user_id=usr.id) }}" data-toggle="tooltip" title="Show Dashboard"><span class="glyphicon glyphicon-modal-window"></span></a>
</tr>
{% endfor %}
</tbody>

View file

@ -1,6 +1,2 @@
<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>
<button class="btn btn-primary btn-md" onclick="window.open('{{ url_for('admin.list_transactions') }}','_self')"><span class="glyphicon glyphicon-btc" aria-hidden="true"></span> Transactions</button>