git://git.onelab.eu
/
plstackapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7d45990
)
raise validation error if slice name prefix is incorrect
author
Tony Mack
<tmack@tux.cs.princeton.edu>
Wed, 3 Sep 2014 17:19:42 +0000
(13:19 -0400)
committer
Tony Mack
<tmack@tux.cs.princeton.edu>
Wed, 3 Sep 2014 17:20:06 +0000
(13:20 -0400)
planetstack/core/models/slice.py
patch
|
blob
|
history
diff --git
a/planetstack/core/models/slice.py
b/planetstack/core/models/slice.py
index
e474560
..
0ecc99d
100644
(file)
--- a/
planetstack/core/models/slice.py
+++ b/
planetstack/core/models/slice.py
@@
-11,6
+11,7
@@
from core.models import Tag
from django.contrib.contenttypes import generic
from core.models import Service
from core.models import Deployment
from django.contrib.contenttypes import generic
from core.models import Service
from core.models import Deployment
+from django.core.exceptions import ValidationError
# Create your models here.
# Create your models here.
@@
-38,6
+39,11
@@
class Slice(PlCoreBase):
return "%s_%s" % (self.site.login_base, self.name)
def save(self, *args, **kwds):
return "%s_%s" % (self.site.login_base, self.name)
def save(self, *args, **kwds):
+
+ site = Site.objects.get(id=self.site.id)
+ if not self.name.startswith(site.login_base):
+ raise ValidationError('slice name must begin with %s' % site.login_base)
+
if self.serviceClass is None:
# We allowed None=True for serviceClass because Django evolution
# will fail unless it is allowed. But, we we really don't want it to
if self.serviceClass is None:
# We allowed None=True for serviceClass because Django evolution
# will fail unless it is allowed. But, we we really don't want it to