client notify ails

This commit is contained in:
deflax 2017-12-27 03:47:26 +02:00
parent d0402b56f9
commit fdb9a8c680
7 changed files with 58 additions and 18 deletions

View file

@ -61,7 +61,11 @@ def activate(itemid=0):
service.enabled = True
db.session.commit()
transaction = Transaction(user_id=int(owner.pid), description='Deployment {} activated for {} month(s)'.format(str(service.description), form.period.data), value=-total)
email_content = 'Service {} is activated for {} month(s). It will expire at {}'.format(str(service.description), form.period.data, str((expiry + extradays).strftime('%c')))
send_email(current_app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=owner, content=str(email_content))
send_email(str(owner.email), str(email_content), 'email/client_logger', content=str(email_content))
transaction = Transaction(user_id=int(owner.pid), description=str(email_content), value=-total)
db.session.add(transaction)
db.session.commit()

View file

@ -1,6 +1,8 @@
<p>{{ user.email }}.<br />
<br />
{{ content }}<br />
<p>User: {{ user.email }} notified.<br />
</p>
<p>
Action taken: {{ content }}<br />
</p>
<p>Regards,<br />
Datapoint.bg
</p>
<p>Regards,
Proxadmin</p>

View file

@ -1,6 +1,6 @@
User {{ user.email }}
User {{ user.email }} notified.
{{ content }}
Action taken: {{ content }}
Regards,
Proxadmin

View file

@ -0,0 +1,14 @@
<p>Dear client,<br />
</p>
<p>{{ content }}
</p>
<p>Regards,<br />
Datapoint.bg<br />
<br />
52 Volga str.<br />
4002 Plovdiv, Bulgaria<br />
tel: +359 323 982 95<br />
office@datapoint.bg<br />
</p>

View file

@ -0,0 +1,11 @@
Dear client,
{{ content }}
Regards,
Datapoint.bg
52 Volga str.
4002 Plovdiv, Bulgaria
tel: +359 323 982 95
office@datapoint.bg

View file

@ -40,13 +40,13 @@ var myChart = new Chart(ctx, {
{% block page_content %}
<div class="row">
{% block sidebar %}
<div class="col-md-4">
<div class="col-md-12">
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
{% include "/settings/acc_avatar.html" %}
</div>
<div class="col-md-12">
<div class="col-md-6">
<div class="panel panel-info">
<div class="panel-heading">Wallet Graph</div>
<div class="panel-body">
@ -58,7 +58,7 @@ var myChart = new Chart(ctx, {
</div>
{% endblock %}
<div class="col-md-8">
<div class="col-md-12">
<div class="panel panel-info">
<div class="panel-heading">Transactions</div>
<div class="panel-body">

View file

@ -66,10 +66,11 @@ def autodisable():
#print('Found {}.'.format(str(deploy.machine_alias)))
lastcharge = deploy.date_last_charge
expiry = lastcharge + relativedelta(lastcharge, months=+(deploy.period))
if today > expiry:
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))
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
deploy.daysleft = 0
@ -80,10 +81,11 @@ def autodisable():
for service in services_ena:
lastcharge = service.date_last_charge
expiry = lastcharge + relativedelta(lastcharge, months=+(service.period))
if today > expiry:
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))
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
service.daysleft = 0
@ -93,10 +95,11 @@ def autodisable():
domains_ena = Domain.query.filter_by(deleted=False).filter_by(enabled=True).all()
for domain in domains_ena:
expiry = domain.date_expire
if today > expiry:
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))
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
domain.daysleft = 0
@ -121,10 +124,12 @@ def autowarn():
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 (daysleft.days / 2) == warndays:
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))
deploy.warning = True
db.session.commit()
db.session.commit()
print('\n[{}] Scan for enabled services that will expire soon and enable the warning flag:'.format(today.replace(microsecond=0)))
services_ena = Service.query.filter_by(deleted=False).filter_by(enabled=True).all()
@ -138,10 +143,12 @@ def autowarn():
email_content = 'Service "' + service.description + '" is ' + str(daysleft.days) + ' days until expiration. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c')
if daysleft.days == warndays or (daysleft.days / 2) == warndays:
send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=service.owner, content=str(email_content))
send_email(str(service.owner.email), str(email_content), 'email/client_logger', content=str(email_content))
service.warning = True
if daysleft.days < warndays:
print(str(email_content))
service.warning = True
db.session.commit()
db.session.commit()
domains_ena = Domain.query.filter_by(deleted=False).filter_by(enabled=True).all()
for domain in domains_ena:
@ -153,10 +160,12 @@ def autowarn():
email_content = 'Domain "' + domain.fqdn + '" is ' + str(daysleft.days)+ ' days until expiration. Expiry date: ' + expiry.strftime('%c')
if daysleft.days == warndays or (daysleft.days / 2) == warndays:
send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=domain.owner, content=str(email_content))
send_email(str(domain.owner.email), str(email_content), 'email/client_logger', content=str(email_content))
domain.warning = True
if daysleft.days < warndays:
print(str(email_content))
domain.warning = True
db.session.commit()
db.session.commit()
@manager.command
def runserver():