Author: jtauber
Date: Sat Sep 27 03:45:09 2008
New Revision: 943
Added:
trunk/local_apps/account/management/ (props changed)
trunk/local_apps/account/management/__init__.py
trunk/local_apps/account/management/commands/ (props changed)
trunk/local_apps/account/management/commands/__init__.py
trunk/local_apps/account/management/commands/create_accounts_from_profiles.py
Modified:
trunk/local_apps/account/models.py
trunk/local_apps/profiles/models.py
Log:
model changes (and migration management command) to split account and other
services info out from profile model -- note: nothing has been changed to
use this yet
Added: trunk/local_apps/account/management/__init__.py
==============================================================================
Added: trunk/local_apps/account/management/commands/__init__.py
==============================================================================
Added:
trunk/local_apps/account/management/commands/create_accounts_from_profiles.py
==============================================================================
--- (empty file)
+++
trunk/local_apps/account/management/commands/create_accounts_from_profiles.py
Sat Sep 27 03:45:09 2008
@@ -0,0 +1,31 @@
+from django.core.management.base import NoArgsCommand
+from profiles.models import Profile
+from account.models import Account, OtherServiceInfo
+from django.contrib.auth.models import User
+from django.conf import settings
+
+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):
+
+ 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:
+ OtherServiceInfo(user=user, key="twitter_user",
value=profile.twitter_user).save()
+ if profile.twitter_password:
+ OtherServiceInfo(user=user, key="twitter_password",
value=profile.twitter_password).save()
+ if profile.pownce_user:
+ OtherServiceInfo(user=user, key="pownce_user",
value=profile.pownce_user).save()
+ if profile.pownce_password:
+ OtherServiceInfo(user=user, key="pownce_password",
value=profile.pownce_password).save()
Modified: trunk/local_apps/account/models.py
==============================================================================
--- trunk/local_apps/account/models.py (original)
+++ trunk/local_apps/account/models.py Sat Sep 27 03:45:09 2008
@@ -1,3 +1,42 @@
from django.db import models
+from django.conf import settings
+from django.contrib.auth.models import User
+from django.db.models.signals import post_save
+from django.utils.translation import ugettext_lazy as _
-# Create your models here.
+from timezones.fields import TimeZoneField
+
+class Account(models.Model):
+
+ user = models.ForeignKey(User, unique=True, verbose_name=_('user'))
+
+ timezone = TimeZoneField(_('timezone'))
+ language = models.CharField(_('language'), max_length=10,
choices=settings.LANGUAGES, default=settings.LANGUAGE_CODE)
+
+ def __unicode__(self):
+ return self.user.username
+
+
+class OtherServiceInfo(models.Model):
+
+ # eg blogrss, twitter_user, twitter_password, pownce_user,
pownce_password
+
+ user = models.ForeignKey(User, verbose_name=_('user'))
+ key = models.CharField(_('Other Service Info Key'), max_length=50)
+ value = models.TextField(_('Other Service Info Value'))
+
+ class Meta:
+ unique_together = [('user', 'key')]
+
+ def __unicode__(self):
+ return u"%s for %s" % (self.key, self.user)
+
+
+def create_account(sender, instance=None, **kwdargs):
+ if instance is None:
+ return
+ account, created = Account.objects.get_or_create(user=instance)
+ if created:
+ account.save()
+
+post_save.connect(create_account, sender=User)
Modified: trunk/local_apps/profiles/models.py
==============================================================================
--- trunk/local_apps/profiles/models.py (original)
+++ trunk/local_apps/profiles/models.py Sat Sep 27 03:45:09 2008
@@ -13,18 +13,19 @@
about = models.TextField(_('about'), null=True, blank=True)
location = models.CharField(_('location'), max_length=40, null=True,
blank=True)
website = models.URLField(_('website'), null=True, blank=True,
verify_exists=False)
+
+ # @@@ the following are all deprecated - see account/models.py
blogrss = models.URLField(_('blog rss/atom'), null=True, blank=True,
verify_exists=False)
timezone = TimeZoneField(_('timezone'))
twitter_user = models.CharField(_('Twitter Username'), max_length=50,
blank=True)
twitter_password = models.CharField(_('Twitter Password'),
max_length=50, blank=True)
pownce_user = models.CharField(_('Pownce Username'), max_length=50,
blank=True)
pownce_password = models.CharField(_('Pownce Password'),
max_length=50, blank=True)
- # enable_lifestream = models.BooleanField(_('Enable LifeStream'))
language = models.CharField(_('language'), max_length=10,
choices=settings.LANGUAGES, default=settings.LANGUAGE_CODE)
-
+
def __unicode__(self):
return self.user.username
-
+
class Meta:
verbose_name = _('profile')
verbose_name_plural = _('profiles')
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---