kopia lustrzana https://gitlab.com/marnanel/chapeau
Some more error checking in Collection.build_name
rodzic
f019d7b67e
commit
ee070e6992
|
@ -45,6 +45,9 @@ class Collection(models.Model):
|
||||||
self.name,
|
self.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# FIXME it ought to be possible to specify username and collectionname
|
||||||
|
# instead of just name here
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get(cls, name,
|
def get(cls, name,
|
||||||
create_if_missing=True):
|
create_if_missing=True):
|
||||||
|
@ -103,6 +106,12 @@ class Collection(models.Model):
|
||||||
def build_name(cls,
|
def build_name(cls,
|
||||||
username, collectionname):
|
username, collectionname):
|
||||||
|
|
||||||
|
if username is None:
|
||||||
|
raise ValueError('Username not supplied')
|
||||||
|
|
||||||
|
if collectionname is None:
|
||||||
|
raise ValueError('Collectionname not supplied')
|
||||||
|
|
||||||
if '/' in username:
|
if '/' in username:
|
||||||
raise ValueError('Username cannot contain slashes')
|
raise ValueError('Username cannot contain slashes')
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue