Fixed Ticket#01
This commit is contained in:
@@ -38,7 +38,12 @@ from tipp.forms import *
|
|||||||
from openliga import *
|
from openliga import *
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from PIL import Image as PImage
|
from PIL import Image as PImage
|
||||||
import urllib2, pytz, os
|
import urllib2, pytz, os, sys
|
||||||
|
|
||||||
|
# setting utf-8 as default encoding to avoid errors in file
|
||||||
|
# uploads and form data
|
||||||
|
reload(sys)
|
||||||
|
sys.setdefaultencoding('utf8')
|
||||||
|
|
||||||
timezoneLocal = pytz.timezone('Europe/Berlin')
|
timezoneLocal = pytz.timezone('Europe/Berlin')
|
||||||
|
|
||||||
@@ -68,25 +73,17 @@ def profile(request, pk):
|
|||||||
|
|
||||||
# If it's a HTTP POST, we're interested in processing form data.
|
# If it's a HTTP POST, we're interested in processing form data.
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
# Attempt to grab information from the raw form information.
|
|
||||||
# Note that we make use of both UserForm and UserProfileForm.
|
|
||||||
user_form = UserForm(data=request.POST, instance=user)
|
user_form = UserForm(data=request.POST, instance=user)
|
||||||
profile_form = UserProfileForm(data=request.POST, instance=profile)
|
profile_form = UserProfileForm(data=request.POST, instance=profile)
|
||||||
|
|
||||||
# If the two forms are valid...
|
|
||||||
if user_form.is_valid() and profile_form.is_valid():
|
if user_form.is_valid() and profile_form.is_valid():
|
||||||
|
|
||||||
# Save the user's form data to the database.
|
|
||||||
user = user_form.save()
|
user = user_form.save()
|
||||||
|
|
||||||
# Now sort out the UserProfile instance.
|
|
||||||
# Since we need to set the user attribute ourselves, we set commit=False.
|
|
||||||
# This delays saving the model until we're ready to avoid integrity problems.
|
|
||||||
profile = profile_form.save(commit=False)
|
profile = profile_form.save(commit=False)
|
||||||
profile.user = user
|
profile.user = user
|
||||||
|
|
||||||
# Did the user provide a profile picture?
|
# Did the user provide a profile picture?
|
||||||
# If so, we need to get it from the input form and put it in the UserProfile model.
|
|
||||||
if 'avatar' in request.FILES:
|
if 'avatar' in request.FILES:
|
||||||
profile.avatar = request.FILES['avatar']
|
profile.avatar = request.FILES['avatar']
|
||||||
# Now we save the UserProfile model instance.
|
# Now we save the UserProfile model instance.
|
||||||
|
|||||||
Reference in New Issue
Block a user