X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetstack%2Fcore%2Fmodels%2Fuser.py;h=7fdde19c379478344fcfba5229f14a7023c6ea67;hb=30ad06ab91677fd02a2f16fc88fc47071a8c50f2;hp=fb0d2321a9d2389d7b831c84a2d65ba7e92d25bc;hpb=2a4565c5624f40d2e72e9e0d98396d79fb30d616;p=plstackapi.git diff --git a/planetstack/core/models/user.py b/planetstack/core/models/user.py index fb0d232..7fdde19 100644 --- 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) + + #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