Beispiel #1
0
 def get_initial(self):
     initial = super(UserDetailView, self).get_initial()
     contact = self._get_bind_contact()
     if contact:
         # Guess some sort of usable username
         username = flatten(contact, ".")
         if len(username) < 3:
             username = getattr(contact, "email", "").split("@")[0]
         if len(username) < 3:
             username = "******" % random.randint(0, 99999999)
         initial.update(
             username=username,
             email=getattr(contact, "email", ""),
             first_name=getattr(contact, "first_name", ""),
             last_name=getattr(contact, "last_name", ""),
         )
     return initial
Beispiel #2
0
 def get_initial(self):
     initial = super(UserDetailView, self).get_initial()
     contact = self._get_bind_contact()
     if contact:
         # Guess some sort of usable username
         username = flatten(contact, ".")
         if len(username) < 3:
             username = getattr(contact, "email", "").split("@")[0]
         if len(username) < 3:
             username = "******" % random.randint(0, 99999999)
         initial.update(
             username=username,
             email=getattr(contact, "email", ""),
             first_name=getattr(contact, "first_name", ""),
             last_name=getattr(contact, "last_name", ""),
         )
     return initial
Beispiel #3
0
def test_flatten():
    text = "Whät is Löve? Bäby Don't Hurt Me"
    assert flatten(text) == "what-is-love?-baby-don't-hurt-me"
    assert flatten(text, "/") == "what/is/love?/baby/don't/hurt/me"
Beispiel #4
0
 def save(self, *args, **kwargs):
     if not self.identifier:
         raise ValueError(u"Attribute with null identifier not allowed")
     self.identifier = flatten(("%s" % self.identifier).lower())
     return super(Attribute, self).save(*args, **kwargs)
Beispiel #5
0
 def save(self, *args, **kwargs):
     if not self.identifier:
         raise ValueError(u"Attribute with null identifier not allowed")
     self.identifier = flatten(("%s" % self.identifier).lower())
     return super(Attribute, self).save(*args, **kwargs)
Beispiel #6
0
def test_flatten():
    text = "Whät is Löve? Bäby Don't Hurt Me"
    assert flatten(text) == "what-is-love?-baby-don't-hurt-me"
    assert flatten(text, "/") == "what/is/love?/baby/don't/hurt/me"