Michael Hall has proposed merging 
lp:~mhall119/loco-directory/initial-userprofiles into lp:loco-directory.

Requested reviews:
  loco-directory-dev (loco-directory-dev)


This doesn't add any functionality yet, but it'll let us get a user's timezone 
settings from launchpad via "request.user.profile.tz", and give us a base for 
future enhancements.
-- 
https://code.launchpad.net/~mhall119/loco-directory/initial-userprofiles/+merge/32894
Your team loco-directory-dev is requested to review the proposed merge of 
lp:~mhall119/loco-directory/initial-userprofiles into lp:loco-directory.
=== modified file 'loco_directory/common/launchpad.py'
--- loco_directory/common/launchpad.py	2010-08-12 09:59:25 +0000
+++ loco_directory/common/launchpad.py	2010-08-17 16:18:44 +0000
@@ -80,3 +80,17 @@
     except HTTPError:
        # 404 or some other issue that means we should default to False
        return "https://edge.launchpad.net/api/beta/ubuntu/mugshot";
+
+def get_user_timezone(username):
+    if username is None:
+        return 'UTC'
+        
+    lp = lp_login()
+    if not lp:
+        return 'UTC'
+        
+    lp_user = lp.people[username]
+    if not lp_user:
+        return 'UTC'
+        
+    return lp_user.time_zone

=== modified file 'loco_directory/settings.py'
--- loco_directory/settings.py	2010-08-02 14:43:27 +0000
+++ loco_directory/settings.py	2010-08-17 16:18:44 +0000
@@ -115,6 +115,7 @@
     'teams',
     'venues',
     'events',
+    'userprofiles',
     'django_openid_auth',
     'south',
 )

=== added directory 'loco_directory/userprofiles'
=== added file 'loco_directory/userprofiles/__init__.py'
=== added directory 'loco_directory/userprofiles/migrations'
=== added file 'loco_directory/userprofiles/migrations/0001_initial.py'
--- loco_directory/userprofiles/migrations/0001_initial.py	1970-01-01 00:00:00 +0000
+++ loco_directory/userprofiles/migrations/0001_initial.py	2010-08-17 16:18:44 +0000
@@ -0,0 +1,87 @@
+
+from south.db import db
+from django.db import models
+from userprofiles.models import *
+
+class Migration:
+    
+    def forwards(self, orm):
+        
+        # Adding model 'UserProfile'
+        db.create_table('userprofiles_userprofile', (
+            ('id', orm['userprofiles.UserProfile:id']),
+            ('user', orm['userprofiles.UserProfile:user']),
+            ('tz', orm['userprofiles.UserProfile:tz']),
+            ('blog', orm['userprofiles.UserProfile:blog']),
+            ('twitter', orm['userprofiles.UserProfile:twitter']),
+            ('identica', orm['userprofiles.UserProfile:identica']),
+            ('picasa', orm['userprofiles.UserProfile:picasa']),
+            ('flickr', orm['userprofiles.UserProfile:flickr']),
+            ('facebook', orm['userprofiles.UserProfile:facebook']),
+            ('irc', orm['userprofiles.UserProfile:irc']),
+            ('aim', orm['userprofiles.UserProfile:aim']),
+            ('xmpp', orm['userprofiles.UserProfile:xmpp']),
+        ))
+        db.send_create_signal('userprofiles', ['UserProfile'])
+        
+    
+    
+    def backwards(self, orm):
+        
+        # Deleting model 'UserProfile'
+        db.delete_table('userprofiles_userprofile')
+        
+    
+    
+    models = {
+        'auth.group': {
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'unique_together': "(('content_type', 'codename'),)"},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'unique_together': "(('app_label', 'model'),)", 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'userprofiles.userprofile': {
+            'aim': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
+            'blog': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+            'facebook': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
+            'flickr': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'identica': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
+            'irc': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
+            'picasa': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
+            'twitter': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
+            'tz': ('django.db.models.fields.CharField', [], {'default': "'UTC'", 'max_length': '32'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'unique': 'True'}),
+            'xmpp': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'})
+        }
+    }
+    
+    complete_apps = ['userprofiles']

=== added file 'loco_directory/userprofiles/migrations/__init__.py'
=== added file 'loco_directory/userprofiles/models.py'
--- loco_directory/userprofiles/models.py	1970-01-01 00:00:00 +0000
+++ loco_directory/userprofiles/models.py	2010-08-17 16:18:44 +0000
@@ -0,0 +1,46 @@
+from django.db import models
+from django.utils.translation import ugettext_lazy as _
+from django.contrib import auth
+from common.launchpad import get_user_timezone
+# Create your models here.
+
+class UserProfile(models.Model):
+    " Store profile information about a user "
+
+    user = models.ForeignKey(auth.models.User, unique=True)
+    tz = models.CharField(verbose_name=_('Timezone'), max_length=32, default='UTC')
+
+    blog = models.URLField(verbose_name=_('Blog URL'), blank=True, null=True, verify_exists=False)
+    twitter = models.CharField(verbose_name=_('Twitter ID'), max_length=32, blank=True, null=True)
+    identica = models.CharField(verbose_name=_('Identi.ca ID'), max_length=32, blank=True, null=True)
+    picasa = models.CharField(verbose_name=_('Picasa ID'), max_length=32, blank=True, null=True)
+    flickr = models.CharField(verbose_name=_('Flickr ID'), max_length=32, blank=True, null=True)
+    facebook = models.CharField(verbose_name=_('Facebook ID'), max_length=32, blank=True, null=True)
+    irc = models.CharField(verbose_name=_('IRC Nick'), max_length=32, blank=True, null=True)
+    aim = models.CharField(verbose_name=_('AOL IM Nick'), max_length=32, blank=True, null=True)
+    xmpp = models.CharField(verbose_name=_('XMPP IM Nick'), max_length=32, blank=True, null=True)
+
+    def __unicode__(self):
+        try:
+            return "Profile for %s" % self.user.username
+        except:
+            return "Unknown Profile"
+            
+def _getUserProfile(self):
+    if not self.is_authenticated():
+        return UserProfile()
+    
+    profile, created = UserProfile.objects.get_or_create(user=self)
+    
+    if created:
+        profile.tz = get_user_timezone(self.username)
+        profile.save()
+        
+    return profile
+
+def _getAnonProfile(self):
+    return UserProfile()
+        
+auth.models.User.profile = property(_getUserProfile)
+auth.models.AnonymousUser.profile = property(_getAnonProfile)
+

=== added file 'loco_directory/userprofiles/tests.py'
--- loco_directory/userprofiles/tests.py	1970-01-01 00:00:00 +0000
+++ loco_directory/userprofiles/tests.py	2010-08-17 16:18:44 +0000
@@ -0,0 +1,23 @@
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+class SimpleTest(TestCase):
+    def test_basic_addition(self):
+        """
+        Tests that 1 + 1 always equals 2.
+        """
+        self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+

=== added file 'loco_directory/userprofiles/views.py'
--- loco_directory/userprofiles/views.py	1970-01-01 00:00:00 +0000
+++ loco_directory/userprofiles/views.py	2010-08-17 16:18:44 +0000
@@ -0,0 +1,1 @@
+# Create your views here.

_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to