Reformatted the file and imports.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Wed, 21 Jul 2010 02:07:28 +0530
changeset 138 250e2731039d
parent 137 ec6e58c639bf
child 139 6e4719bb7df0
Reformatted the file and imports.
project/scipycon/user/utils.py
project/scipycon/user/views.py
--- a/project/scipycon/user/utils.py	Wed Jul 21 02:06:51 2010 +0530
+++ b/project/scipycon/user/utils.py	Wed Jul 21 02:07:28 2010 +0530
@@ -83,10 +83,13 @@
     return user
 
 def handle_uploaded_photo(user, ufile):
+    """Handles the upload and gives the file path to be saved.
+    """
+
     usermedia = settings.USER_MEDIA_ROOT
     filename = ufile.name
     ext = filename.split('.')[-1]
-    filesize = ufile.size
+
     filecontent = ufile.read()
     userfilename = 'user-%d.%s' % (user.id, ext)
     if not filecontent:
@@ -119,7 +122,6 @@
             th = int(round(nw / pr))
             image = image.resize((nw, th), Image.ANTIALIAS)
             t = int(round(( th - nh ) / 2.0))
-            #print((0, t, nw, t + nh))
             image = image.crop((0, t, nw, t + nh))
         else:
             # photo aspect matches the destination ratio
@@ -127,4 +129,3 @@
 
         image.save(str(foutname))
     return userfilename
-
--- a/project/scipycon/user/views.py	Wed Jul 21 02:06:51 2010 +0530
+++ b/project/scipycon/user/views.py	Wed Jul 21 02:07:28 2010 +0530
@@ -1,7 +1,6 @@
 from urlparse import urlparse
 
 import simplejson as json
-import urllib
 import os
 
 from django.conf import settings
@@ -12,7 +11,6 @@
 from django.core.exceptions import ObjectDoesNotExist
 from django.core.urlresolvers import reverse
 from django.db.models import Q
-from django.db.models.signals import post_save
 from django.http import HttpResponse
 from django.shortcuts import render_to_response
 from django.template import RequestContext
@@ -23,13 +21,12 @@
 from project.scipycon.registration.models import Wifi
 from project.scipycon.registration.forms import WifiForm
 from project.scipycon.talk.models import Talk
-from project.scipycon.utils import set_message_cookie
-
 from project.scipycon.user.forms import EditProfileForm
+from project.scipycon.user.forms import RegisterForm
+from project.scipycon.user.forms import UsernameForm
 from project.scipycon.user.utils import handle_uploaded_photo
-from project.scipycon.user.forms import RegisterForm
 from project.scipycon.user.utils import scipycon_createuser
-from project.scipycon.user.forms import UsernameForm
+from project.scipycon.utils import set_message_cookie
 
 
 @login_required
@@ -79,6 +76,7 @@
 def edit_profile(request, scope, template_name="user/editprofile.html"):
     """Allows user to edit profile
     """
+
     user = request.user
     profile = user.get_profile()
 
@@ -106,16 +104,18 @@
             redirect_to = reverse('scipycon_account',
                                   kwargs={'scope': scope})
             return set_message_cookie(redirect_to,
-                    msg = u"Your profile has been changed.")
+                    msg = u'Your profile has been changed.')
 
     else:
-        form = EditProfileForm(initial={"email" : user.email,
-                                        "email2" : user.email, # hidden field
-                                        "first_name" : user.first_name,
-                                        "last_name" : user.last_name,
-                                        "url" : profile.url,
-                                        "about" : profile.about,
-                                        })
+        form = EditProfileForm(
+            initial={
+                'email' : user.email,
+                'email2' : user.email, # hidden field
+                'first_name' : user.first_name,
+                'last_name' : user.last_name,
+                'url' : profile.url,
+                'about' : profile.about,
+            })
 
     return render_to_response(template_name, RequestContext(request, {
         'params': {'scope': scope},