Added creation of profile to user creation since signals were removed.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Wed, 21 Jul 2010 03:29:21 +0530
changeset 143 ea9477690acd
parent 142 70fcb57d8d15
child 144 27bde1b86666
Added creation of profile to user creation since signals were removed.
project/scipycon/user/utils.py
--- a/project/scipycon/user/utils.py	Wed Jul 21 03:28:40 2010 +0530
+++ b/project/scipycon/user/utils.py	Wed Jul 21 03:29:21 2010 +0530
@@ -6,10 +6,11 @@
 
 from PIL import Image
 
+from project.scipycon.base.models import Event
 from project.scipycon.user.models import UserProfile
 
 
-def scipycon_createregistrant(request, data):
+def scipycon_createregistrant(request, data, scope):
     """Create user
     """
 
@@ -32,6 +33,14 @@
     user.last_name = last_name
     user.save()
 
+    scope_entity = Event.objects.get(scope=scope)
+    try:
+        profile = user.get_profile()
+    except:
+        profile, new = UserProfile.objects.get_or_create(
+            user=user, scope=scope_entity)
+        profile.save()
+
     return user
 
 def scipycon_createuser(request, data, scope):
@@ -41,8 +50,6 @@
     from django.contrib.auth import authenticate
     from django.contrib.auth import login
 
-    from project.scipycon.base.models import Event
-
     email = data.get('email')
     username = data.get('username')
     password = data.get('password_1')