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
7eb6a33f
authored
Jul 27, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: fix notifications
parent
4684a0a9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
circle/dashboard/models.py
+3
-1
circle/vm/models/instance.py
+11
-4
No files found.
circle/dashboard/models.py
View file @
7eb6a33f
...
@@ -70,7 +70,9 @@ class Notification(TimeStampedModel):
...
@@ -70,7 +70,9 @@ class Notification(TimeStampedModel):
def
send
(
cls
,
user
,
subject
,
template
,
context
,
def
send
(
cls
,
user
,
subject
,
template
,
context
,
valid_until
=
None
,
subject_context
=
None
):
valid_until
=
None
,
subject_context
=
None
):
hro
=
create_readable
(
template
,
user
=
user
,
**
context
)
hro
=
create_readable
(
template
,
user
=
user
,
**
context
)
subject
=
create_readable
(
subject
,
subject_context
or
context
)
if
subject_context
is
None
:
subject_context
=
context
subject
=
create_readable
(
subject
,
**
subject_context
)
return
cls
.
objects
.
create
(
to
=
user
,
return
cls
.
objects
.
create
(
to
=
user
,
subject_data
=
subject
.
to_dict
(),
subject_data
=
subject
.
to_dict
(),
message_data
=
hro
.
to_dict
(),
message_data
=
hro
.
to_dict
(),
...
...
circle/vm/models/instance.py
View file @
7eb6a33f
...
@@ -642,6 +642,13 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -642,6 +642,13 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
:param again: Notify already notified owners.
:param again: Notify already notified owners.
"""
"""
notification_msg
=
ugettext_noop
(
'Your instance <a href="
%(url)
s">
%(instance)
s</a> is going to '
'expire. It will be suspended at
%(suspend)
s and destroyed at '
'
%(delete)
s. Please, either <a href="
%(token)
s">renew</a> '
'or <a href="
%(url)
s">destroy</a> it now.'
)
if
not
again
and
self
.
_is_notified_about_expiration
():
if
not
again
and
self
.
_is_notified_about_expiration
():
return
False
return
False
success
,
failed
=
[],
[]
success
,
failed
=
[],
[]
...
@@ -672,10 +679,10 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -672,10 +679,10 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
try
:
try
:
token
=
VmRenewView
.
get_token_url
(
self
,
u
)
token
=
VmRenewView
.
get_token_url
(
self
,
u
)
u
.
profile
.
notify
(
u
.
profile
.
notify
(
_
(
'
%
s expiring soon'
)
%
unicode
(
self
),
ugettext_noop
(
'
%(instance)
s expiring soon'
),
'dashboard/notifications/vm-expiring.html'
,
notification_msg
,
url
=
self
.
get_absolute_url
()
,
{
'instance'
:
self
,
'token'
:
token
},
valid_until
=
min
(
instance
=
self
,
suspend
=
self
.
time_of_suspend
,
self
.
time_of_delete
,
self
.
time_of_suspend
)
)
token
=
token
,
delete
=
self
.
time_of_delete
)
except
Exception
as
e
:
except
Exception
as
e
:
failed
.
append
((
u
,
e
))
failed
.
append
((
u
,
e
))
else
:
else
:
...
...
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