Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f08a4701
authored
Mar 20, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
request: notify user when request is accepted
parent
d09d309b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
1 deletions
+50
-1
circle/dashboard/static/dashboard/dashboard.less
+4
-0
circle/request/models.py
+46
-1
No files found.
circle/dashboard/static/dashboard/dashboard.less
View file @
f08a4701
...
@@ -1307,3 +1307,7 @@ textarea[name="new_members"] {
...
@@ -1307,3 +1307,7 @@ textarea[name="new_members"] {
min-height: 80px;
min-height: 80px;
}
}
}
}
.nowrap {
white-space: nowrap;
}
circle/request/models.py
View file @
f08a4701
...
@@ -22,7 +22,9 @@ from django.contrib.contenttypes.fields import GenericForeignKey
...
@@ -22,7 +22,9 @@ from django.contrib.contenttypes.fields import GenericForeignKey
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.core.validators
import
MinValueValidator
from
django.core.validators
import
MinValueValidator
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
from
django.utils.translation
import
(
ugettext_lazy
as
_
,
ugettext_noop
,
ungettext
)
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
model_utils.models
import
TimeStampedModel
from
model_utils.models
import
TimeStampedModel
...
@@ -36,6 +38,10 @@ class RequestAction(Model):
...
@@ -36,6 +38,10 @@ class RequestAction(Model):
def
accept
(
self
):
def
accept
(
self
):
raise
NotImplementedError
raise
NotImplementedError
@property
def
accept_msg
(
self
):
raise
NotImplementedError
class
Meta
:
class
Meta
:
abstract
=
True
abstract
=
True
...
@@ -109,6 +115,11 @@ class Request(TimeStampedModel):
...
@@ -109,6 +115,11 @@ class Request(TimeStampedModel):
self
.
closed_by
=
user
self
.
closed_by
=
user
self
.
save
()
self
.
save
()
self
.
user
.
profile
.
notify
(
ugettext_noop
(
"Request accepted"
),
self
.
action
.
accept_msg
)
def
decline
(
self
,
user
,
reason
):
def
decline
(
self
,
user
,
reason
):
self
.
status
=
"DECLINED"
self
.
status
=
"DECLINED"
self
.
closed_by
=
user
self
.
closed_by
=
user
...
@@ -154,6 +165,21 @@ class ResourceChangeAction(RequestAction):
...
@@ -154,6 +165,21 @@ class ResourceChangeAction(RequestAction):
def
accept
(
self
,
user
):
def
accept
(
self
,
user
):
self
.
instance
.
resources_request
.
async
(
user
=
user
,
resource_request
=
self
)
self
.
instance
.
resources_request
.
async
(
user
=
user
,
resource_request
=
self
)
@property
def
accept_msg
(
self
):
return
_
(
'The resources of <a href="
%(url)
s">
%(name)
s</a> were changed. '
'Number of cores:
%(num_cores)
d, RAM size: '
'<span class="nowrap">
%(ram_size)
d MiB</span>, '
'CPU priority:
%(priority)
d/100.'
)
%
{
'url'
:
self
.
instance
.
get_absolute_url
(),
'name'
:
self
.
instance
.
name
,
'num_cores'
:
self
.
num_cores
,
'ram_size'
:
self
.
ram_size
,
'priority'
:
self
.
priority
,
}
class
ExtendLeaseAction
(
RequestAction
):
class
ExtendLeaseAction
(
RequestAction
):
instance
=
ForeignKey
(
Instance
)
instance
=
ForeignKey
(
Instance
)
...
@@ -163,6 +189,16 @@ class ExtendLeaseAction(RequestAction):
...
@@ -163,6 +189,16 @@ class ExtendLeaseAction(RequestAction):
self
.
instance
.
renew
(
lease
=
self
.
lease_type
.
lease
,
save
=
True
,
force
=
True
,
self
.
instance
.
renew
(
lease
=
self
.
lease_type
.
lease
,
save
=
True
,
force
=
True
,
user
=
user
)
user
=
user
)
@property
def
accept_msg
(
self
):
return
_
(
'The lease of <a href="
%(url)
s">
%(name)
s</a> got extended. '
'(suspend:
%(suspend)
s, remove:
%(remove)
s)'
)
%
{
'name'
:
self
.
instance
.
name
,
'url'
:
self
.
instance
.
get_absolute_url
(),
'suspend'
:
self
.
lease_type
.
lease
.
get_readable_suspend_time
(),
'remove'
:
self
.
lease_type
.
lease
.
get_readable_delete_time
(),
}
class
TemplateAccessAction
(
RequestAction
):
class
TemplateAccessAction
(
RequestAction
):
template_type
=
ForeignKey
(
TemplateAccessType
)
template_type
=
ForeignKey
(
TemplateAccessType
)
...
@@ -181,6 +217,14 @@ class TemplateAccessAction(RequestAction):
...
@@ -181,6 +217,14 @@ class TemplateAccessAction(RequestAction):
for
t
in
self
.
template_type
.
templates
.
all
():
for
t
in
self
.
template_type
.
templates
.
all
():
t
.
set_user_level
(
self
.
user
,
self
.
level
)
t
.
set_user_level
(
self
.
user
,
self
.
level
)
@property
def
accept_msg
(
self
):
return
ungettext
(
"You got access to the following template:
%
s"
,
"You got access to the following templates:
%
s"
,
self
.
template_type
.
templates
.
count
()
)
%
", "
.
join
([
x
.
name
for
x
in
self
.
template_type
.
templates
.
all
()])
def
send_notification_to_superusers
(
sender
,
instance
,
created
,
**
kwargs
):
def
send_notification_to_superusers
(
sender
,
instance
,
created
,
**
kwargs
):
if
not
created
:
if
not
created
:
...
@@ -207,4 +251,5 @@ def send_notification_to_superusers(sender, instance, created, **kwargs):
...
@@ -207,4 +251,5 @@ def send_notification_to_superusers(sender, instance, created, **kwargs):
'<a href="
%(request_url)
s">link</a>.'
),
context
'<a href="
%(request_url)
s">link</a>.'
),
context
)
)
post_save
.
connect
(
send_notification_to_superusers
,
sender
=
Request
)
post_save
.
connect
(
send_notification_to_superusers
,
sender
=
Request
)
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