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:
2a4565c
)
user model needed its GetValidators method
author
Scott Baker
<smbaker@gmail.com>
Tue, 6 Jan 2015 01:26:36 +0000
(17:26 -0800)
committer
Scott Baker
<smbaker@gmail.com>
Tue, 6 Jan 2015 01:26:36 +0000
(17:26 -0800)
planetstack/core/models/user.py
patch
|
blob
|
history
diff --git
a/planetstack/core/models/user.py
b/planetstack/core/models/user.py
index
fb0d232
..
7fdde19
100644
(file)
--- a/
planetstack/core/models/user.py
+++ b/
planetstack/core/models/user.py
@@
-112,6
+112,22
@@
class User(AbstractBaseUser): #, DiffModelMixIn):
def get_field_diff(self, field_name):
return self.diff.get(field_name, None)
def get_field_diff(self, field_name):
return self.diff.get(field_name, None)
+
+ #classmethod
+ def getValidators(cls):
+ """ primarily for REST API, return a dictionary of field names mapped
+ to lists of the type of validations that need to be applied to
+ those fields.
+ """
+ validators = {}
+ for field in cls._meta.fields:
+ l = []
+ if field.blank==False:
+ l.append("notBlank")
+ if field.__class__.__name__=="URLField":
+ l.append("url")
+ validators[field.name] = l
+ return validators
# ---- end copy stuff from DiffModelMixin ----
@property
# ---- end copy stuff from DiffModelMixin ----
@property