Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
58e3efb0
authored
May 14, 2015
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: display renew url in email notifications
parent
02116654
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletions
+16
-1
circle/dashboard/models.py
+13
-0
circle/dashboard/templates/dashboard/notifications/email.txt
+3
-1
No files found.
circle/dashboard/models.py
View file @
58e3efb0
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
datetime
import
timedelta
from
itertools
import
chain
from
itertools
import
chain
from
hashlib
import
md5
from
hashlib
import
md5
from
logging
import
getLogger
from
logging
import
getLogger
...
@@ -31,6 +32,7 @@ from django.db.models import (
...
@@ -31,6 +32,7 @@ from django.db.models import (
)
)
from
django.db.models.signals
import
post_save
,
pre_delete
,
post_delete
from
django.db.models.signals
import
post_save
,
pre_delete
,
post_delete
from
django.templatetags.static
import
static
from
django.templatetags.static
import
static
from
django.utils
import
timezone
from
django.utils.html
import
escape
from
django.utils.html
import
escape
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
django_sshkey.models
import
UserKey
from
django_sshkey.models
import
UserKey
...
@@ -132,6 +134,17 @@ class Notification(TimeStampedModel):
...
@@ -132,6 +134,17 @@ class Notification(TimeStampedModel):
def
message
(
self
,
value
):
def
message
(
self
,
value
):
self
.
message_data
=
None
if
value
is
None
else
value
.
to_dict
()
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
):
class
ConnectCommand
(
Model
):
user
=
ForeignKey
(
User
,
related_name
=
'command_set'
)
user
=
ForeignKey
(
User
,
related_name
=
'command_set'
)
...
...
circle/dashboard/templates/dashboard/notifications/email.txt
View file @
58e3efb0
...
@@ -4,7 +4,9 @@
...
@@ -4,7 +4,9 @@
{% blocktrans count n=messages|length %}You have a new notification:{% plural %}You have {{n}} new notifications:{% endblocktrans %}
{% 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 %}
{% endfor %}
{% blocktrans with url=url count n=messages|length %}See it in detail on <{{url}}>.{% plural %} See them in detail on <{{url}}>.{% endblocktrans %}
{% blocktrans with url=url count n=messages|length %}See it in detail on <{{url}}>.{% plural %} See them in detail on <{{url}}>.{% endblocktrans %}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment