summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2011-01-20 18:19:43 +0200
committerYuval Adam <yuv.adm@gmail.com>2011-01-20 18:19:43 +0200
commit69d732e1c075b7646d3cb3bbf79acde42252dd90 (patch)
tree64e0f1ac90d2a8bee8e098bc34916d143e9d0dd8 /main
parentfb6edb764a84bbfb9c169468d0422987b43de1e3 (diff)
works good
Diffstat (limited to 'main')
-rw-r--r--main/views.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/main/views.py b/main/views.py
index ac95d31..3dc9fd4 100644
--- a/main/views.py
+++ b/main/views.py
@@ -8,7 +8,7 @@ from datetime import datetime
import json
def index(request):
- matches = Match.objects.all().order_by('date')
+ matches = Match.objects.all().order_by('date')
players = Player.objects.all()
return render_to_response('main.html', {'matches' : matches, 'players' : players}, context_instance=RequestContext(request))
@@ -17,9 +17,11 @@ def match(request):
p2 = Player.objects.get(id=int(request.POST.get('p2')))
try:
p3 = Player.objects.get(id=int(request.POST.get('p3')))
- p4 = Player.objects.get(id=int(request.POST.get('p4')))
except:
p3 = None
+ try:
+ p4 = Player.objects.get(id=int(request.POST.get('p4')))
+ except:
p4 = None
s1 = int(request.POST.get('s1'))
@@ -27,7 +29,7 @@ def match(request):
if None not in (p1, p2, s1, s2):
date = datetime.now()
- match = Match(player1=p1, player2=p2, score1=s1, score2=s2, date=date)
+ match = Match(player1=p1, player2=p2, player3=p3, player4=p4, score1=s1, score2=s2, date=date)
match.save()
return HttpResponseRedirect('/')