diff --git a/app/admin/routes.py b/app/admin/routes.py index c62465f..4c4117d 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -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 diff --git a/app/templates/admin/admin_tasks.html b/app/templates/admin/admin_tasks.html index 871ff59..3d5c9a0 100644 --- a/app/templates/admin/admin_tasks.html +++ b/app/templates/admin/admin_tasks.html @@ -6,7 +6,7 @@ - + diff --git a/app/templates/admin/list_cancelled.html b/app/templates/admin/list_recyclebin.html similarity index 83% rename from app/templates/admin/list_cancelled.html rename to app/templates/admin/list_recyclebin.html index df12531..44c39ba 100644 --- a/app/templates/admin/list_cancelled.html +++ b/app/templates/admin/list_recyclebin.html @@ -74,14 +74,18 @@ addEventListener("DOMContentLoaded", function() { {% for deploy in deployments %} - {% if deploy.enabled == False %} + {% if deploy.cancelled == True %} + + {% else %} + {% if deploy.enabled == False %} - {% else %} - {% if deploy.warning == True %} + {% else %} + {% if deploy.warning == True %} - {% else %} + {% else %} - {% endif %} + {% endif %} + {% endif %} {% endif %} {{ deploy.owner.email }} {{ deploy.machine_id }} @@ -89,9 +93,17 @@ addEventListener("DOMContentLoaded", function() { {{ deploy.machine_cpu }} {{ deploy.machine_mem }} MB {{ deploy.machine_hdd }} GB + {% if deploy.date_last_charge == None %} + Never + {% else %} {{ moment(deploy.date_last_charge).format('lll') }} ({{ moment(deploy.date_last_charge).fromNow() }}) + {% endif %} {{ deploy.daysleft }} - + {% if deploy.cancelled == True %} + -deleted- + {% else %} + + {% endif %} {% endfor %} diff --git a/app/vmanager/routes.py b/app/vmanager/routes.py index 44b9b17..aae41cd 100644 --- a/app/vmanager/routes.py +++ b/app/vmanager/routes.py @@ -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/', methods=['GET', 'POST'])