Skip to content

Commit

Permalink
Rename util -> utils, fix URL issue
Browse files Browse the repository at this point in the history
  • Loading branch information
grantmcconnaughey committed Feb 9, 2016
1 parent a6b4c2b commit 5cbd095
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 25 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ Changelog
* Added the ability to use a Facebook Graph avatar as a backup.
* Added a way to customize where avatars are stored.
* Added a setting to disable the avatar cache.
* Updated thumbnail creation to preserve RGBA.
* Fixed issue where ``render_primary`` would not work if username/email was greater than 30 characters.
* Fixed issue where cache was not invalidated after updating avatar
* Renamed the ``avatar.util`` module to ``avatar.utils``.
* **Backwards Incompatible:** Renamed the ``avatar.util`` module to ``avatar.utils``.

* 2.2.1 (January 11, 2016)
* Added AVATAR_GRAVATAR_FIELD setting to define the user field to get the gravatar email.
Expand Down
2 changes: 1 addition & 1 deletion avatar/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from avatar.models import Avatar
from avatar.signals import avatar_updated
from avatar.util import get_user_model
from avatar.utils import get_user_model


class AvatarAdmin(admin.ModelAdmin):
Expand Down
2 changes: 1 addition & 1 deletion avatar/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.db.models import signals

from avatar.conf import settings
from avatar.util import get_username, force_bytes, invalidate_cache
from avatar.utils import get_username, force_bytes, invalidate_cache

try:
from django.utils.timezone import now
Expand Down
4 changes: 2 additions & 2 deletions avatar/templatetags/avatar_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from django.utils.module_loading import import_string

from avatar.conf import settings
from avatar.util import (get_primary_avatar, get_default_avatar_url,
cache_result, get_user_model, get_user, force_bytes)
from avatar.utils import (get_primary_avatar, get_default_avatar_url,
cache_result, get_user_model, get_user, force_bytes)
from avatar.models import Avatar

register = template.Library()
Expand Down
2 changes: 1 addition & 1 deletion avatar/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
url(r'^add/$', views.add, name='avatar_add'),
url(r'^change/$', views.change, name='avatar_change'),
url(r'^delete/$', views.delete, name='avatar_delete'),
url(r'^render_primary/(?P<user>[\w\d\@\.\-_]{3,30})/(?P<size>[\d]+)/$',
url(r'^render_primary/(?P<user>[\w\d\@\.\-_]+)/(?P<size>[\d]+)/$',
views.render_primary,
name='avatar_render_primary'),
]
1 change: 0 additions & 1 deletion avatar/util.py → avatar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def cache_result(default_size=settings.AVATAR_DEFAULT_SIZE):
Decorator to cache the result of functions that take a ``user`` and a
``size`` value.
"""

if not settings.AVATAR_CACHE_ENABLED:
def decorator(func):
return func
Expand Down
4 changes: 2 additions & 2 deletions avatar/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from avatar.forms import PrimaryAvatarForm, DeleteAvatarForm, UploadAvatarForm
from avatar.models import Avatar
from avatar.signals import avatar_updated
from avatar.util import (get_primary_avatar, get_default_avatar_url,
invalidate_cache)
from avatar.utils import (get_primary_avatar, get_default_avatar_url,
invalidate_cache)


def _get_next(request):
Expand Down
18 changes: 9 additions & 9 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from avatar.admin import AvatarAdmin
from avatar.conf import settings
from avatar.util import get_primary_avatar, get_user_model
from avatar.utils import get_primary_avatar, get_user_model
from avatar.models import Avatar
from PIL import Image

Expand Down Expand Up @@ -158,14 +158,6 @@ def test_too_many_avatars(self):
self.assertNotEqual(response.context['upload_avatar_form'].errors, {})
self.assertEqual(count_before, count_after)

# def testAvatarOrder
# def testReplaceAvatarWhenMaxIsOne
# def testHashFileName
# def testHashUserName
# def testChangePrimaryAvatar
# def testDeleteThumbnailAndRecreation
# def testAutomaticThumbnailCreation

@override_settings(AVATAR_THUMB_FORMAT='png')
def testAutomaticThumbnailCreationRGBA(self):
upload_helper(self, "django.png")
Expand All @@ -178,3 +170,11 @@ def testAutomaticThumbnailCreationCMYK(self):
avatar = get_primary_avatar(self.user)
image = Image.open(avatar.avatar.storage.open(avatar.avatar_name(settings.AVATAR_DEFAULT_SIZE), 'rb'))
self.assertEqual(image.mode, 'RGB')

# def testAvatarOrder
# def testReplaceAvatarWhenMaxIsOne
# def testHashFileName
# def testHashUserName
# def testChangePrimaryAvatar
# def testDeleteThumbnailAndRecreation
# def testAutomaticThumbnailCreation
11 changes: 4 additions & 7 deletions tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
try:
from django.conf.urls import patterns, include
except ImportError:
from django.conf.urls.defaults import patterns, include
from django.conf.urls import include, url


urlpatterns = patterns('',
(r'^avatar/', include('avatar.urls')),
)
urlpatterns = [
url(r'^avatar/', include('avatar.urls')),
]

0 comments on commit 5cbd095

Please sign in to comment.