Commit 9cbc7776 by Bach Dániel

one: fix site name

parent 402d32ae
...@@ -261,6 +261,7 @@ FIREWALL_SETTINGS = { ...@@ -261,6 +261,7 @@ FIREWALL_SETTINGS = {
} }
SITE_NAME = "IK Cloud" SITE_NAME = "IK Cloud"
DEFAULT_FROM_EMAIL = "noreply@cloud.ik.bme.hu" DEFAULT_FROM_EMAIL = "noreply@cloud.ik.bme.hu"
DELETE_VM = False
EMAIL_HOST='152.66.243.92' # giccero ipv4 EMAIL_HOST='152.66.243.92' # giccero ipv4
CLOUD_URL='https://cloud.ik.bme.hu/' CLOUD_URL='https://cloud.ik.bme.hu/'
RELEASE = subprocess.check_output(['git', 'rev-parse', '--symbolic-full-name', '--abbrev-ref', 'HEAD']) RELEASE = subprocess.check_output(['git', 'rev-parse', '--symbolic-full-name', '--abbrev-ref', 'HEAD'])
......
...@@ -6,7 +6,7 @@ from one.models import Instance ...@@ -6,7 +6,7 @@ from one.models import Instance
from django.template.loader import render_to_string from django.template.loader import render_to_string
from one.tasks import SendMailTask from one.tasks import SendMailTask
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from cloud.settings import CLOUD_URL as url from django.conf import settings
from django.utils import translation from django.utils import translation
class Job(HourlyJob): class Job(HourlyJob):
...@@ -16,6 +16,8 @@ class Job(HourlyJob): ...@@ -16,6 +16,8 @@ class Job(HourlyJob):
return (orig + datetime.timedelta(days=days, hours=hours)).replace(minute=0, second=0, microsecond=0) return (orig + datetime.timedelta(days=days, hours=hours)).replace(minute=0, second=0, microsecond=0)
def execute(self): def execute(self):
url = settings.CLOUD_URL
site = settings.SITE_NAME
now = datetime.datetime.utcnow().replace(tzinfo=utc) now = datetime.datetime.utcnow().replace(tzinfo=utc)
d = { d = {
'1m': self.calc(orig=now, days=30), '1m': self.calc(orig=now, days=30),
...@@ -38,14 +40,18 @@ class Job(HourlyJob): ...@@ -38,14 +40,18 @@ class Job(HourlyJob):
delete = i.time_of_delete.replace(minute=0, second=0, microsecond=0) delete = i.time_of_delete.replace(minute=0, second=0, microsecond=0)
continue continue
if i.time_of_delete < now: if i.time_of_delete < now:
# msg = render_to_string('mails/notification-delete-now.txt', { 'user': i.owner, 'instance': i, 'url': url } ) msg = render_to_string('mails/notification-delete-now.txt',
# SendMailTask.delay(to=i.owner.email, subject='[IK Cloud] %s' % i.name, msg=msg) { 'user': i.owner, 'instance': i, 'url': url, 'site': site } )
pass SendMailTask.delay(to=i.owner.email, subject='[%s] %s' %
(site, i.name), msg=msg)
i.one_delete()
else: else:
for t in d: for t in d:
if delete == d[t]: if delete == d[t]:
msg = render_to_string('mails/notification-delete.txt', { 'user': i.owner, 'instance': i, 'url': url } ) msg = render_to_string('mails/notification-delete.txt',
SendMailTask.delay(to=i.owner.email, subject='[IK Cloud] %s' % i.name, msg=msg) { 'user': i.owner, 'instance': i, 'url': url, 'site': site } )
SendMailTask.delay(to=i.owner.email, subject='[%s] %s' %
(site, i.name), msg=msg)
# suspend # suspend
for i in Instance.objects.filter(state='ACTIVE', for i in Instance.objects.filter(state='ACTIVE',
...@@ -58,11 +64,15 @@ class Job(HourlyJob): ...@@ -58,11 +64,15 @@ class Job(HourlyJob):
suspend = i.time_of_suspend.replace(minute=0, second=0, microsecond=0) suspend = i.time_of_suspend.replace(minute=0, second=0, microsecond=0)
if i.time_of_suspend < now: if i.time_of_suspend < now:
msg = render_to_string('mails/notification-suspend-now.txt', { 'user': i.owner, 'instance': i, 'url': url } ) msg = render_to_string('mails/notification-suspend-now.txt',
SendMailTask.delay(to=i.owner.email, subject='[IK Cloud] %s' % i.name, msg=msg) { 'user': i.owner, 'instance': i, 'url': url, 'site': site } )
SendMailTask.delay(to=i.owner.email, subject='[%s] %s' %
(site, i.name), msg=msg)
i.stop() i.stop()
else: else:
for t in d: for t in d:
if suspend == d[t]: if suspend == d[t]:
msg = render_to_string('mails/notification-suspend.txt', { 'user': i.owner, 'instance': i, 'url': url } ) msg = render_to_string('mails/notification-suspend.txt',
SendMailTask.delay(to=i.owner.email, subject='[IK Cloud] %s' % i.name, msg=msg) { 'user': i.owner, 'instance': i, 'url': url, 'site': site } )
SendMailTask.delay(to=i.owner.email, subject='[%s] %s' %
(site, i.name), msg=msg)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment