Move alt attribute to kwargs.

This commit is contained in:
Jannis 2017-01-17 15:39:42 +01:00
parent c1f191a2b0
commit a35f2bb29e
3 changed files with 6 additions and 5 deletions

View file

@ -1 +1 @@
<img src="{{ url }}" alt="{{ alt }}" width="{{ size }}" height="{{ size }}" {% for key, value in kwargs.items %}{{key}}="{{value}}" {% endfor %}/>
<img src="{{ url }}" width="{{ size }}" height="{{ size }}" {% for key, value in kwargs.items %}{{key}}="{{value}}" {% endfor %}/>

View file

@ -42,10 +42,11 @@ def avatar(user, size=settings.AVATAR_DEFAULT_SIZE, **kwargs):
else:
alt = six.text_type(user)
url = avatar_url(user, size)
kwargs.update({'alt': alt})
context = {
'user': user,
'url': url,
'alt': alt,
'size': size,
'kwargs': kwargs,
}

View file

@ -190,7 +190,7 @@ class AvatarTests(TestCase):
result = avatar_tags.avatar(self.user.username)
self.assertIn('<img src="{}"'.format(avatar.avatar_url(80)), result)
self.assertIn('alt="test" width="80" height="80" />', result)
self.assertIn('width="80" height="80" alt="test" />', result)
def test_avatar_tag_works_with_user(self):
upload_helper(self, "test.png")
@ -199,7 +199,7 @@ class AvatarTests(TestCase):
result = avatar_tags.avatar(self.user)
self.assertIn('<img src="{}"'.format(avatar.avatar_url(80)), result)
self.assertIn('alt="test" width="80" height="80" />', result)
self.assertIn('width="80" height="80" alt="test" />', result)
def test_avatar_tag_works_with_custom_size(self):
upload_helper(self, "test.png")
@ -208,7 +208,7 @@ class AvatarTests(TestCase):
result = avatar_tags.avatar(self.user, 100)
self.assertIn('<img src="{}"'.format(avatar.avatar_url(100)), result)
self.assertIn('alt="test" width="100" height="100" />', result)
self.assertIn('width="100" height="100" alt="test" />', result)
def test_avatar_tag_works_with_kwargs(self):
upload_helper(self, "test.png")