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 @fresh_login_required
@admin_required @admin_required
def list_users(page): 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) return render_template('admin/list_users.html', users=sqlquery.items, page=page)
@admin.route("/listitems", methods=['GET']) @admin.route("/listitems", methods=['GET'])

View file

@ -30,7 +30,7 @@ def before_request():
#print('session: %s' % str(session)) #print('session: %s' % str(session))
if current_user.is_authenticated: if current_user.is_authenticated:
current_user.ping() 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': if not current_user.confirmed and request.endpoint[:5] != 'auth.' and request.endpoint != 'static':
print(request.endpoint) print(request.endpoint)
return redirect(url_for('auth.unconfirmed')) return redirect(url_for('auth.unconfirmed'))

View file

@ -25,9 +25,9 @@ from datetime import date, time, datetime
# #
# form = OrderForm() # form = OrderForm()
# if form.validate_on_submit(): # if form.validate_on_submit():
# region = Region.query.filter_by(pid=int(form.region.data)).first() # region = Region.query.filter_by(id=int(form.region.data)).first()
# recipe = Recipe.query.filter_by(pid=int(form.recipe.data)).first() # recipe = Recipe.query.filter_by(id=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') # 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.add(new_order)
# db.session.commit() # db.session.commit()
# send_email(current_app.config['MAIL_USERNAME'], 'New order from {}'.format(current_user.email), # 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) # return render_template('panel/deploy.html', form=form)
#DASHBOARD #DASHBOARD
@panel.route("/dashboard", defaults={'user_pid': 0}, methods=['GET']) @panel.route("/dashboard", defaults={'user_id': 0}, methods=['GET'])
@panel.route("/dashboard/<int:user_pid>", methods=['GET']) @panel.route("/dashboard/<int:user_id>", methods=['GET'])
@login_required @login_required
def dashboard(user_pid): def dashboard(user_id):
if user_pid == 0: if user_id == 0:
cuser = current_user cuser = current_user
else: else:
cuser = User.query.filter_by(id=user_pid).first() cuser = User.query.filter_by(id=user_id).first()
if cuser == None: if cuser == None:
abort(404) abort(404)
if not current_user.is_administrator(): if not current_user.is_administrator():

View file

@ -46,7 +46,7 @@ class EditProfileAdminForm(FlaskForm):
def __init__(self, user, *args, **kwargs): def __init__(self, user, *args, **kwargs):
super(EditProfileAdminForm, self).__init__(*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()] for role in Role.query.order_by(Role.name).all()]
self.user = user self.user = user

View file

@ -11,7 +11,7 @@
<div class="panel panel-info"> <div class="panel panel-info">
<div class="panel-heading">Зареждане на сметка</div> <div class="panel-heading">Зареждане на сметка</div>
<div class="panel-body"> <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> <p>
Current Value: {{ usr.wallet }}<br /> Current Value: {{ usr.wallet }}<br />
{{ form.amount.label }} {{ form.amount }}<br /> {{ form.amount.label }} {{ form.amount }}<br />

View file

@ -35,7 +35,7 @@
<!--<td data-title="Region">region1</td>--> <!--<td data-title="Region">region1</td>-->
<td data-title="IP">{{ address.ip }}</td> <td data-title="IP">{{ address.ip }}</td>
{% if address.user_id != None %} {% 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 %} {% else %}
<td></td> <td></td>
{% endif %} {% endif %}

View file

@ -88,7 +88,7 @@ addEventListener("DOMContentLoaded", function() {
{% endif %} {% endif %}
{% endif %} {% 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_alias }}</font></td>
<td>{{ deploy.machine_cpu }}</td> <td>{{ deploy.machine_cpu }}</td>
<td>{{ deploy.machine_mem }} MB</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> <td data-title="Last Charged">{{ moment(deploy.date_last_charge).format('lll') }} ({{ moment(deploy.date_last_charge).fromNow() }})</td>
{% endif %} {% endif %}
<td data-title="Days Left">{{ deploy.daysleft }}</td> <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 %} {% endfor %}
</tbody> </tbody>
</table> </table>

View file

@ -33,7 +33,7 @@
<tr> <tr>
{% endif %} {% endif %}
{% 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><b><a href="http://{{ domain.fqdn }}">{{ domain.fqdn }}</a></b></td>
<td>{{ domain.date_expire }}</td> <td>{{ domain.date_expire }}</td>
<td>{{ domain.daysleft }}</td> <td>{{ domain.daysleft }}</td>

View file

@ -30,7 +30,7 @@
<tbody> <tbody>
{% for order in neworders %} {% for order in neworders %}
<tr> <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="Region">{{ order.region.description }}</td>
<td data-title="Recipe"><a href="#" title="{{ order.recipe.description }}">{{ order.recipe.templatefile }}</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="Parameter1">{{ order.parameter1 }}</td>
@ -38,12 +38,12 @@
<td data-title="Parameter3">{{ order.parameter3 }}</td> <td data-title="Parameter3">{{ order.parameter3 }}</td>
<td data-title="Parameter4">{{ order.parameter4 }}</td> <td data-title="Parameter4">{{ order.parameter4 }}</td>
<td data-title="Status">{{ order.status }}</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 %} {% endfor %}
{% for order in oldorders %} {% for order in oldorders %}
<tr> <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="Region">{{ order.region.description }}</td>
<td data-title="Recipe"><a href="#" title="{{ order.recipe.description }}">{{ order.recipe.templatefile }}</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="Parameter1">{{ order.parameter1 }}</td>

View file

@ -33,7 +33,7 @@
<td>{{ server.hdd }}</td> <td>{{ server.hdd }}</td>
<td>{{ server.address }}</td> <td>{{ server.address }}</td>
<td>{{ server.region.name }}</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> </tr>
</tbody> </tbody>
{% endfor %} {% endfor %}

View file

@ -36,7 +36,7 @@
<tr> <tr>
{% endif %} {% endif %}
{% 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="Category">{{ service.category }}</td>
<td data-title="Description">{{ service.description }}</td> <td data-title="Description">{{ service.description }}</td>
<td data-title="Price">{{ service.price }}</td> <td data-title="Price">{{ service.price }}</td>

View file

@ -25,18 +25,18 @@
{% for transaction in transactions %} {% for transaction in transactions %}
{% if transaction.value > 0 %} {% if transaction.value > 0 %}
<tr class="default"> <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="Description">{{ transaction.description }}</td>
<td data-title="Amount">{{ transaction.value }} {{ transaction.currency }}</td> <td data-title="Amount">{{ transaction.value }} {{ transaction.currency }}</td>
<td data-title="Date">{{ moment(transaction.date_created).format('lll') }}</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 %} {% else %}
<tr class="default"> <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="Description">{{ transaction.description }}</td>
<td data-title="Amount">{{ transaction.value }} {{ transaction.currency }}</td> <td data-title="Amount">{{ transaction.value }} {{ transaction.currency }}</td>
<td data-title="Date">{{ moment(transaction.date_created).format('lll') }}</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 %} {% endif %}
</tr> </tr>
</tbody> </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="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="Wallet">{{ usr.wallet }}</td>
<td data-title="Currency">{{ usr.currency }}</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> <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_pid=usr.pid) }}" data-toggle="tooltip" title="List Transactions"><span class="glyphicon glyphicon-credit-card"></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_pid=usr.pid) }}" data-toggle="tooltip" title="Show Dashboard"><span class="glyphicon glyphicon-modal-window"></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> </tr>
{% endfor %} {% endfor %}
</tbody> </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_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>