# HG changeset patch # User Madhusudan.C.S # Date 1279658248 -19800 # Node ID 250e2731039da39bbaf3537036d8268557b0cecb # Parent ec6e58c639bf017654287a56a7d9a445a4837919 Reformatted the file and imports. diff -r ec6e58c639bf -r 250e2731039d project/scipycon/user/utils.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 - diff -r ec6e58c639bf -r 250e2731039d project/scipycon/user/views.py --- 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},