client notify ails
This commit is contained in:
parent
d0402b56f9
commit
fdb9a8c680
7 changed files with 58 additions and 18 deletions
|
@ -61,7 +61,11 @@ def activate(itemid=0):
|
||||||
service.enabled = True
|
service.enabled = True
|
||||||
db.session.commit()
|
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.add(transaction)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<p>{{ user.email }}.<br />
|
<p>User: {{ user.email }} notified.<br />
|
||||||
<br />
|
</p>
|
||||||
{{ content }}<br />
|
<p>
|
||||||
|
Action taken: {{ content }}<br />
|
||||||
|
</p>
|
||||||
|
<p>Regards,<br />
|
||||||
|
Datapoint.bg
|
||||||
</p>
|
</p>
|
||||||
<p>Regards,
|
|
||||||
Proxadmin</p>
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
User {{ user.email }}
|
User {{ user.email }} notified.
|
||||||
|
|
||||||
{{ content }}
|
Action taken: {{ content }}
|
||||||
|
|
||||||
Regards,
|
Regards,
|
||||||
Proxadmin
|
Proxadmin
|
||||||
|
|
14
app/templates/email/client_logger.html
Normal file
14
app/templates/email/client_logger.html
Normal 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>
|
11
app/templates/email/client_logger.txt
Normal file
11
app/templates/email/client_logger.txt
Normal 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
|
|
@ -40,13 +40,13 @@ var myChart = new Chart(ctx, {
|
||||||
{% block page_content %}
|
{% block page_content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% block sidebar %}
|
{% block sidebar %}
|
||||||
<div class="col-md-4">
|
<div class="col-md-12">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-6">
|
||||||
{% include "/settings/acc_avatar.html" %}
|
{% include "/settings/acc_avatar.html" %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-6">
|
||||||
<div class="panel panel-info">
|
<div class="panel panel-info">
|
||||||
<div class="panel-heading">Wallet Graph</div>
|
<div class="panel-heading">Wallet Graph</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
@ -58,7 +58,7 @@ var myChart = new Chart(ctx, {
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<div class="col-md-8">
|
<div class="col-md-12">
|
||||||
<div class="panel panel-info">
|
<div class="panel panel-info">
|
||||||
<div class="panel-heading">Transactions</div>
|
<div class="panel-heading">Transactions</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
21
manage.py
21
manage.py
|
@ -66,10 +66,11 @@ def autodisable():
|
||||||
#print('Found {}.'.format(str(deploy.machine_alias)))
|
#print('Found {}.'.format(str(deploy.machine_alias)))
|
||||||
lastcharge = deploy.date_last_charge
|
lastcharge = deploy.date_last_charge
|
||||||
expiry = lastcharge + relativedelta(lastcharge, months=+(deploy.period))
|
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')
|
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))
|
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(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.warning = False
|
||||||
deploy.enabled = False
|
deploy.enabled = False
|
||||||
deploy.daysleft = 0
|
deploy.daysleft = 0
|
||||||
|
@ -80,10 +81,11 @@ def autodisable():
|
||||||
for service in services_ena:
|
for service in services_ena:
|
||||||
lastcharge = service.date_last_charge
|
lastcharge = service.date_last_charge
|
||||||
expiry = lastcharge + relativedelta(lastcharge, months=+(service.period))
|
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')
|
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))
|
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(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.warning = False
|
||||||
service.enabled = False
|
service.enabled = False
|
||||||
service.daysleft = 0
|
service.daysleft = 0
|
||||||
|
@ -93,10 +95,11 @@ def autodisable():
|
||||||
domains_ena = Domain.query.filter_by(deleted=False).filter_by(enabled=True).all()
|
domains_ena = Domain.query.filter_by(deleted=False).filter_by(enabled=True).all()
|
||||||
for domain in domains_ena:
|
for domain in domains_ena:
|
||||||
expiry = domain.date_expire
|
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')
|
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))
|
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(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.warning = False
|
||||||
domain.enabled = False
|
domain.enabled = False
|
||||||
domain.daysleft = 0
|
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')
|
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:
|
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(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:
|
if daysleft.days < warndays:
|
||||||
print(str(email_content))
|
print(str(email_content))
|
||||||
deploy.warning = True
|
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)))
|
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()
|
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')
|
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:
|
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(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:
|
if daysleft.days < warndays:
|
||||||
print(str(email_content))
|
print(str(email_content))
|
||||||
service.warning = True
|
service.warning = True
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
domains_ena = Domain.query.filter_by(deleted=False).filter_by(enabled=True).all()
|
domains_ena = Domain.query.filter_by(deleted=False).filter_by(enabled=True).all()
|
||||||
for domain in domains_ena:
|
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')
|
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:
|
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(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:
|
if daysleft.days < warndays:
|
||||||
print(str(email_content))
|
print(str(email_content))
|
||||||
domain.warning = True
|
domain.warning = True
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
@manager.command
|
@manager.command
|
||||||
def runserver():
|
def runserver():
|
||||||
|
|
Loading…
Reference in a new issue