예제 #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
예제 #2
0
파일: detail.py 프로젝트: ahmadzai/shuup
 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
예제 #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"
예제 #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)
예제 #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)
예제 #6
0
파일: test_text.py 프로젝트: gurch101/shuup
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"