Commit 58e3efb0 by Bach Dániel

dashboard: display renew url in email notifications

parent 02116654
......@@ -17,6 +17,7 @@
from __future__ import absolute_import
from datetime import timedelta
from itertools import chain
from hashlib import md5
from logging import getLogger
......@@ -31,6 +32,7 @@ from django.db.models import (
)
from django.db.models.signals import post_save, pre_delete, post_delete
from django.templatetags.static import static
from django.utils import timezone
from django.utils.html import escape
from django.utils.translation import ugettext_lazy as _
from django_sshkey.models import UserKey
......@@ -132,6 +134,17 @@ class Notification(TimeStampedModel):
def message(self, value):
self.message_data = None if value is None else value.to_dict()
@property
def has_valid_renew_url(self):
params = self.message_data['params']
return ('token' in params and 'suspend' in params and
self.modified > timezone.now() - timedelta(days=3))
@property
def renew_url(self):
return (settings.DJANGO_URL.rstrip("/") +
str(self.message_data['params'].get('token')))
class ConnectCommand(Model):
user = ForeignKey(User, related_name='command_set')
......
......@@ -4,7 +4,9 @@
{% blocktrans count n=messages|length %}You have a new notification:{% plural %}You have {{n}} new notifications:{% endblocktrans %}
{% for msg in messages %} * {{msg.subject}}
{% for msg in messages %} * {{msg.subject}}{% if msg.has_valid_renew_url %}
{% trans "You can renew it without logging in:" %}
{{ msg.renew_url }}{% endif %}
{% endfor %}
{% blocktrans with url=url count n=messages|length %}See it in detail on <{{url}}>.{% plural %} See them in detail on <{{url}}>.{% endblocktrans %}
......
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