diff --git a/spa/management/commands/processuser.py b/spa/management/commands/processuser.py index 02aa85a..23d1622 100644 --- a/spa/management/commands/processuser.py +++ b/spa/management/commands/processuser.py @@ -2,12 +2,12 @@ from django.contrib.auth.models import User from django.core.exceptions import ObjectDoesNotExist from django.core.management.base import NoArgsCommand, CommandError from spa.models import UserProfile - +from core.utils.url import unique_slugify class Command(NoArgsCommand): help = "Updates audio files with their durations" - def handle(self, *args, **options): + def handle(user, *args, **options): try: candidates = User.objects.all() for user in candidates: @@ -16,7 +16,13 @@ class Command(NoArgsCommand): except ObjectDoesNotExist, ce: print "Creating profile for %s" % user.get_username() UserProfile.objects.create(user=user) - finally: - user.save() + profile = user.get_profile() + + if profile.slug is None or profile.slug == '': + profile.slug = unique_slugify(profile, user.get_username()) + print "Slugified: %s" % profile.slug + profile.save() + + user.save() except Exception, ex: raise CommandError(ex.message)