示例#1
0
 def save(self, *args, **kwargs):
     if self.email:
         gravatar_url = get_gravatar_link(email=self.email)
     else:
         gravatar_url = get_gravatar_link(email=None)
     self.avatar = gravatar_url
     super(KantaskerUser, self).save(*args, **kwargs)
 def test_gravatar_for_another_default(self):
     email = None
     expected = self.generate_expected_gravatar(
         '00000000000000000000000000000000',
         default='monsterid')
     result = get_gravatar_link(email, default_image_index=2)
     assert_that(result, equal_to(expected))
 def test_gravatar_for_another_size(self):
     email = None
     size = 150
     expected = self.generate_expected_gravatar(
         '00000000000000000000000000000000',
         size=size)
     result = get_gravatar_link(email, size=size)
     assert_that(result, equal_to(expected))
 def test_gravatar_for_normal_mail(self):
     email = '*****@*****.**'
     expected = self.generate_expected_gravatar('fafa6e91aafb9444528f3b44eb3c3cf4')
     result = get_gravatar_link(email)
     assert_that(result, equal_to(expected))
 def test_gravatar_for_empty_mail(self):
     email = None
     expected = self.generate_expected_gravatar('00000000000000000000000000000000')
     result = get_gravatar_link(email)
     assert_that(result, equal_to(expected))