From 6332b49eacf4cf5a3646e5b149fffd1311e40645 Mon Sep 17 00:00:00 2001 From: Martin Bley Date: Mon, 15 Feb 2016 18:02:39 +0100 Subject: [PATCH 1/4] Fixed Ticket#01 --- tipp/views.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tipp/views.py b/tipp/views.py index 3c2319a..8455a19 100644 --- a/tipp/views.py +++ b/tipp/views.py @@ -38,7 +38,12 @@ from tipp.forms import * from openliga import * from datetime import datetime 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') @@ -68,25 +73,17 @@ def profile(request, pk): # If it's a HTTP POST, we're interested in processing form data. 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) profile_form = UserProfileForm(data=request.POST, instance=profile) - # If the two forms are valid... if user_form.is_valid() and profile_form.is_valid(): - # Save the user's form data to the database. 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.user = user # 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: profile.avatar = request.FILES['avatar'] # Now we save the UserProfile model instance. From 7c66399c8fc384e0aa0c48d989b732322f5ddb53 Mon Sep 17 00:00:00 2001 From: Martin Bley Date: Wed, 24 Feb 2016 14:37:07 +0100 Subject: [PATCH 2/4] Some blank lines --- tipp/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tipp/views.py b/tipp/views.py index 8455a19..4c1abac 100644 --- a/tipp/views.py +++ b/tipp/views.py @@ -105,8 +105,6 @@ def profile(request, pk): for item in request.POST: debug.append(str(item) + " -> " + str(request.POST[item])) - - # Invalid form or forms - mistakes or something else? # Print problems to the terminal. # They'll also be shown to the user. @@ -114,6 +112,7 @@ def profile(request, pk): print user_form.errors, profile_form.errors return redirect( '/accounts/profile/' + str(user.id) ) + # Not a HTTP POST, so we render our form using two ModelForm instances. # These forms will be blank, ready for user input. else: From de904d4ad49dfe81a440929bb16d067c0ecaae1c Mon Sep 17 00:00:00 2001 From: Martin Bley Date: Wed, 24 Feb 2016 15:36:00 +0100 Subject: [PATCH 3/4] Fixed 'None' items in charts --- tipp/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tipp/views.py b/tipp/views.py index 4c1abac..a629a81 100644 --- a/tipp/views.py +++ b/tipp/views.py @@ -397,8 +397,11 @@ def charts(request, ls, season, pos='default', template_name='charts.html'): # get user object, then fetch matches for user user = User.objects.get(id=userid) score = Tipp.objects.filter(matchID__in=matches, tipperID=user).aggregate(Sum('score')) - - user_dict[user.first_name] = score['score__sum'] + + if score['score__sum'] is None: + user_dict[user.first_name] = 0 + else: + user_dict[user.first_name] = score['score__sum'] mandant_dict[mandant.name] = sorted(user_dict.items(), key=lambda x: x[1], reverse=True) From 364166d84b99ff5732691626e4eb72619de1d433 Mon Sep 17 00:00:00 2001 From: Martin Bley Date: Wed, 24 Feb 2016 16:00:34 +0100 Subject: [PATCH 4/4] Fixed 'None' items in mate table --- tipp/views.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tipp/views.py b/tipp/views.py index a629a81..e64bd89 100644 --- a/tipp/views.py +++ b/tipp/views.py @@ -331,7 +331,13 @@ def matchday(request, ls, season, matchday, template_name='md.html'): try: matetipp = Tipp.objects.get(tipperID=mate['mate'],matchID=match.matchID) if match_started is True: - mate['tipps'].append(str(matetipp.pointsTeam1) + ":" + str(matetipp.pointsTeam2) + "(" + str(matetipp.score) + ")") + if matetipp.score is None: + score = u'\u231B' + else: + score = matetipp.score + + mate['tipps'].append(str(matetipp.pointsTeam1) + ":" + str(matetipp.pointsTeam2) + \ + "(" + str(score) + ")") if match.finished is True: mate['sum_score'] += matetipp.score else: