fix recycle bin
This commit is contained in:
parent
379f7be272
commit
ddd07804ee
4 changed files with 29 additions and 16 deletions
|
@ -56,14 +56,14 @@ def list_domains():
|
|||
alldomains = Domain.query.filter_by(cancelled=False).order_by(Domain.daysleft.asc()).all()
|
||||
return render_template('admin/list_domains.html', domains=alldomains)
|
||||
|
||||
@admin.route("/listcancelled", methods=['GET'])
|
||||
@admin.route("/listrecyclebin", methods=['GET'])
|
||||
@login_required
|
||||
@admin_required
|
||||
def list_cancelled():
|
||||
expdeployments = Deployment.query.filter_by(cancelled=True).all()
|
||||
expservices = Service.query.filter_by(cancelled=True).all()
|
||||
expdomains = Domain.query.filter_by(cancelled=True).all()
|
||||
return render_template('admin/list_cancelled.html', deployments=expdeployments, services=expservices, domains=expdomains)
|
||||
def list_recyclebin():
|
||||
deployments = Deployment.query.filter_by(protected=False).order_by(Deployment.daysleft.asc()).all()
|
||||
services = Service.query.filter_by(cancelled=True).all()
|
||||
domains = Domain.query.filter_by(cancelled=True).all()
|
||||
return render_template('admin/list_recyclebin.html', deployments=deployments, services=services, domains=domains)
|
||||
|
||||
@admin.route("/listaddresses", methods=['GET'])
|
||||
@login_required
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<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-success btn-md" onclick="window.open('{{ url_for('admin.list_domains') }}','_self')"><span class="glyphicon glyphicon-home" aria-hidden="true"></span> Domains</button>
|
||||
<button class="btn btn-danger btn-md" onclick="window.open('{{ url_for('admin.list_cancelled') }}', '_self')"><span class="glyphicon glyphicon-cd" aria-hidden="true"></span> Recycle Bin</button>
|
||||
<button class="btn btn-danger btn-md" onclick="window.open('{{ url_for('admin.list_recyclebin') }}', '_self')"><span class="glyphicon glyphicon-cd" aria-hidden="true"></span> Recycle Bin</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-usd" aria-hidden="true"></span> Transactions</button>
|
||||
<button class="btn btn-primary btn-md" onclick="window.open('{{ url_for('admin.list_addresses') }}','_self')"><span class="glyphicon glyphicon-tag" aria-hidden="true"></span> Addresses</button>
|
||||
|
|
|
@ -74,6 +74,9 @@ addEventListener("DOMContentLoaded", function() {
|
|||
</thead>
|
||||
<tbody>
|
||||
{% for deploy in deployments %}
|
||||
{% if deploy.cancelled == True %}
|
||||
<tr class="active">
|
||||
{% else %}
|
||||
{% if deploy.enabled == False %}
|
||||
<tr class="danger">
|
||||
{% else %}
|
||||
|
@ -83,15 +86,24 @@ addEventListener("DOMContentLoaded", function() {
|
|||
<tr>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<td><a href="{{ url_for('admin.dashboard', user_pid=deploy.user_id) }}">{{ deploy.owner.email }}</a></td>
|
||||
<td>{{ deploy.machine_id }}</td>
|
||||
<td>{{ deploy.machine_alias }}</font></td>
|
||||
<td>{{ deploy.machine_cpu }}</td>
|
||||
<td>{{ deploy.machine_mem }} MB</td>
|
||||
<td>{{ deploy.machine_hdd }} GB</td>
|
||||
{% if deploy.date_last_charge == None %}
|
||||
<td>Never</td>
|
||||
{% else %}
|
||||
<td>{{ moment(deploy.date_last_charge).format('lll') }} ({{ moment(deploy.date_last_charge).fromNow() }})</td>
|
||||
{% endif %}
|
||||
<td>{{ deploy.daysleft }}</td>
|
||||
<td><button class="btn btn-default btn-danger" onclick="window.open('/vmanager/vmremove/{{ deploy.machine_id }}');"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Delete</button></td>
|
||||
{% if deploy.cancelled == True %}
|
||||
<td>-deleted-</td>
|
||||
{% else %}
|
||||
<td><button class="btn btn-default btn-danger" onclick="location.reload();location.href='/vmanager/vmremove/{{ deploy.machine_id }}'"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Delete</button></td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
|
@ -76,15 +76,16 @@ def createvm():
|
|||
@login_required
|
||||
def remove(itemid=0):
|
||||
data = {}
|
||||
result = Deployment.query.filter_by(machine_id=int(itemid)).first()
|
||||
deploy = Deployment.query.filter_by(machine_id=int(itemid)).first()
|
||||
if current_user.is_administrator():
|
||||
try:
|
||||
query = contact_proxmaster(data, 'vmremove', int(itemid))
|
||||
flash('Machine {} terminated'.format(itemid))
|
||||
|
||||
deploy.cancelled = True
|
||||
db.session.commit()
|
||||
except:
|
||||
flash('Cannot delete machine {}'.format(itemid))
|
||||
return redirect(url_for('admin.list_cancelled'))
|
||||
return redirect(url_for('admin.list_recyclebin'))
|
||||
abort(404)
|
||||
|
||||
@vmanager.route('/activate/<int:itemid>', methods=['GET', 'POST'])
|
||||
|
|
Loading…
Reference in a new issue