Altered process user to execute save on all

This commit is contained in:
fergalmoran
2013-04-23 14:34:28 +01:00
parent 69a4f73107
commit af74cd85e8

View File

@@ -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)