diff options
author | Madhusudan.C.S | 2010-07-21 02:07:28 +0530 |
---|---|---|
committer | Madhusudan.C.S | 2010-07-21 02:07:28 +0530 |
commit | 7a6629421fee64dd56c7e22259701e474ac6632f (patch) | |
tree | 0c5c79c50c3225c07e845ba6adbdf6e86fe7f95c | |
parent | 128e5621c9ae269c12294ede5ad234333743b829 (diff) | |
download | scipycon-7a6629421fee64dd56c7e22259701e474ac6632f.tar.gz scipycon-7a6629421fee64dd56c7e22259701e474ac6632f.tar.bz2 scipycon-7a6629421fee64dd56c7e22259701e474ac6632f.zip |
Reformatted the file and imports.
-rw-r--r-- | project/scipycon/user/utils.py | 7 | ||||
-rw-r--r-- | project/scipycon/user/views.py | 28 |
2 files changed, 18 insertions, 17 deletions
diff --git a/project/scipycon/user/utils.py b/project/scipycon/user/utils.py index fb9a428..c6fc35e 100644 --- a/project/scipycon/user/utils.py +++ b/project/scipycon/user/utils.py @@ -83,10 +83,13 @@ def scipycon_createuser(request, data, scope): 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 @@ def handle_uploaded_photo(user, ufile): 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 @@ def handle_uploaded_photo(user, ufile): image.save(str(foutname)) return userfilename - diff --git a/project/scipycon/user/views.py b/project/scipycon/user/views.py index d65b913..43df26b 100644 --- a/project/scipycon/user/views.py +++ b/project/scipycon/user/views.py @@ -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.contrib.auth.models import User 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 Registration 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.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.user.utils import handle_uploaded_photo +from project.scipycon.user.utils import scipycon_createuser +from project.scipycon.utils import set_message_cookie @login_required @@ -79,6 +76,7 @@ def account(request, scope, template_name="user/account.html"): 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 @@ def edit_profile(request, scope, template_name="user/editprofile.html"): 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}, |