fix tenant view temporary password email, display message if user tries to register...
[plstackapi.git] / planetstack / core / models / user.py
index fb0d232..c8df836 100644 (file)
@@ -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
@@ -139,13 +155,15 @@ class User(AbstractBaseUser): #, DiffModelMixIn):
     public_key = models.TextField(null=True, blank=True, max_length=1024, help_text="Public key string")
 
     is_active = models.BooleanField(default=True)
-    is_admin = models.BooleanField(default=True)
+    is_admin = models.BooleanField(default=False)
     is_staff = models.BooleanField(default=True)
     is_readonly = models.BooleanField(default=False)
+    is_registering = models.BooleanField(default=False)
 
     created = models.DateTimeField(auto_now_add=True)
     updated = models.DateTimeField(auto_now=True)
     enacted = models.DateTimeField(null=True, default=None)
+    policed = models.DateTimeField(null=True, default=None)
     backend_status = models.CharField(max_length=140,
                                       default="Provisioning in progress")
     deleted = models.BooleanField(default=False)
@@ -245,9 +263,10 @@ class User(AbstractBaseUser): #, DiffModelMixIn):
     def save(self, *args, **kwds):
         if not self.id:
             self.set_password(self.password)
-        if self.is_active:
-            if self.password=="!":\r
-                self.send_temporary_password()\r
+        print "XXX", self, self.is_active, self.is_registering
+        if self.is_active and self.is_registering:
+            self.send_temporary_password()\r
+            self.is_registering=False\r
 \r
         self.username = self.email
         super(User, self).save(*args, **kwds)