From b6234c2f265dd0ccf62370b815c9cedb7c404b86 Mon Sep 17 00:00:00 2001 From: deflax Date: Tue, 22 May 2018 15:28:06 +0300 Subject: [PATCH] enable sending mail on warn event in the cron command for deployments --- app/panel/routes.py | 2 +- app/templates/main/footer_index.html | 3 +-- app/templates/news/latest.html | 10 ---------- app/templates/panel/dashboard.html | 2 ++ manage.py | 13 +++++++------ 5 files changed, 11 insertions(+), 19 deletions(-) delete mode 100644 app/templates/news/latest.html diff --git a/app/panel/routes.py b/app/panel/routes.py index 604a8b6..6851e5b 100644 --- a/app/panel/routes.py +++ b/app/panel/routes.py @@ -55,7 +55,7 @@ def dashboard(user_pid): abort(404) #hidden 403 inv_addresses = cuser.inv_addresses.order_by(Address.ip.asc()).all() - inv_deployments = cuser.inv_deployments.filter_by(deleted=False).order_by(Deployment.date_created.desc()).all() + inv_deployments = cuser.inv_deployments.filter_by(deleted=False).order_by(Deployment.machine_alias.asc()).all() regions = {} for region in sys_regions: regions[region.pid] = region.description diff --git a/app/templates/main/footer_index.html b/app/templates/main/footer_index.html index 41d6396..da1fa3b 100644 --- a/app/templates/main/footer_index.html +++ b/app/templates/main/footer_index.html @@ -2,8 +2,7 @@
-

News

- +
diff --git a/app/templates/news/latest.html b/app/templates/news/latest.html deleted file mode 100644 index 932d80a..0000000 --- a/app/templates/news/latest.html +++ /dev/null @@ -1,10 +0,0 @@ -{% block page_content %} -

News

- {% for item in result %} -

- {{ item['message'] }} - {{ item['created_time'] | fbtime }} -

- {% endfor %} - >>> -{% endblock %} diff --git a/app/templates/panel/dashboard.html b/app/templates/panel/dashboard.html index 90cf0fe..4ce823d 100644 --- a/app/templates/panel/dashboard.html +++ b/app/templates/panel/dashboard.html @@ -123,6 +123,7 @@ addEventListener("DOMContentLoaded", function() { IP Region Reverse DNS + Deployment @@ -131,6 +132,7 @@ addEventListener("DOMContentLoaded", function() { {{ address.ip }} {{ regions[address.region_id] }} {{ address.rdns }} + {{ address.assignee.deploy.machine_alias }} {% endfor %} diff --git a/manage.py b/manage.py index 94f09ee..32fa8fb 100644 --- a/manage.py +++ b/manage.py @@ -69,7 +69,7 @@ def autodisable(): if today >= expiry: email_content = '[!] Deployment "' + deploy.machine_alias + '" is past expiration date and will be marked INACTIVE. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c') print(str(email_content) + " [mail sent]") - #send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=deploy.owner, content=str(email_content)) + send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=deploy.owner, content=str(email_content)) #send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content)) deploy.warning = False deploy.enabled = False @@ -84,7 +84,7 @@ def autodisable(): if today >= expiry: email_content = '[!] Service "' + service.description + '" is past expiration date and will be marked INACTIVE. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c') print(str(email_content) + " [mail sent]") - #send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=service.owner, content=str(email_content)) + send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=service.owner, content=str(email_content)) #send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content)) service.warning = False service.enabled = False @@ -98,7 +98,7 @@ def autodisable(): if today >= expiry: email_content = '[!] Domain "' + domain.fqdn + '" is past expiration date and will be marked as INACTIVE. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c') print(str(email_content) + " [mail sent]") - #send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=domain.owner, content=str(email_content)) + send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=domain.owner, content=str(email_content)) #send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content)) domain.warning = False domain.enabled = False @@ -122,10 +122,11 @@ def autowarn(): db.session.commit() warndays = deploy.period * 5 email_content = 'Deployment "' + deploy.machine_alias + '" is ' + str(daysleft.days) + ' days until expiration. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c') - if daysleft.days == warndays or round(daysleft.days / 2) == warndays: + #if daysleft.days == warndays or round(daysleft.days * 2) == warndays: + if round(daysleft.days * 2) == warndays: print(str(email_content) + " [mail sent]") - #send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=deploy.owner, content=str(email_content)) - #send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content)) + send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=deploy.owner, content=str(email_content)) + send_email(str(deploy.owner.email), str(email_content), 'email/client_logger', content=str(email_content)) deploy.warning = True if daysleft.days < warndays: print(str(email_content))