Author: leidel
Date: Sat Sep 27 15:16:01 2008
New Revision: 963
Modified:
trunk/local_apps/account/management/commands/create_accounts_from_profiles.py
Log:
Made the import of the Profile model in the create_accounts_from_profiles
management command implicit
Modified:
trunk/local_apps/account/management/commands/create_accounts_from_profiles.py
==============================================================================
---
trunk/local_apps/account/management/commands/create_accounts_from_profiles.py
(original)
+++
trunk/local_apps/account/management/commands/create_accounts_from_profiles.py
Sat Sep 27 15:16:01 2008
@@ -1,24 +1,27 @@
-from django.core.management.base import NoArgsCommand
-from profiles.models import Profile
-from account.models import Account, OtherServiceInfo
+from django.core.management.base import NoArgsCommand, CommandError
from django.contrib.auth.models import User
from django.conf import settings
+from account.models import Account, OtherServiceInfo
class Command(NoArgsCommand):
help = 'Create an account object for users which do not have one and
copy over info from profile.'
def handle_noargs(self, **options):
-
+ try:
+ from profiles.models import Profile
+ except ImportError:
+ raise CommandError("The profile app could not be imported.")
+
for user in User.objects.all():
profile = Profile.objects.get(user=user)
account, created = Account.objects.get_or_create(user=user)
-
+
if created:
account.timezone = profile.timezone
account.language = account.language
account.save()
print "created account for %s" % user
-
+
if profile.blogrss:
OtherServiceInfo(user=user, key="blogrss",
value=profile.blogrss).save()
if profile.twitter_user:
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---