From af74cd85e8ac64b1b0e9c33d7a7aedcf7088a8bb Mon Sep 17 00:00:00 2001 From: fergalmoran Date: Tue, 23 Apr 2013 14:34:28 +0100 Subject: [PATCH] Altered process user to execute save on all --- spa/management/commands/processuser.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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)