Added management command to rebuild avatars. This is useful for when an administrator wishes to change the size of the auto-generated avatar sizes.

git-svn-id: http://django-avatar.googlecode.com/svn/trunk@25 c76b2324-5f53-0410-85ac-b1078a54aeeb
This commit is contained in:
Eric Florenzano 2008-08-16 06:00:00 +00:00
parent 3a56d30243
commit 7d6c3f70d5

View file

@ -0,0 +1,15 @@
from django.core.management.base import NoArgsCommand
from django.conf import settings
from avatar.models import Avatar
AUTO_GENERATE_AVATAR_SIZES = getattr(settings, 'AUTO_GENERATE_AVATAR_SIZES', (80,))
class Command(NoArgsCommand):
help = "Import avatars from Gravatar, and store them locally."
def handle_noargs(self, **options):
for avatar in Avatar.objects.all():
for size in AUTO_GENERATE_AVATAR_SIZES:
print "Rebuilding Avatar id=%s at size %s." % (avatar.id, size)
avatar.create_thumbnail(size)