summaryrefslogtreecommitdiff
path: root/main/views.py
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2011-01-20 22:54:18 +0200
committerYuval Adam <yuv.adm@gmail.com>2011-01-20 22:54:18 +0200
commitdbfbfa95c205f556d102eb1cc5bf3b67a48d456a (patch)
tree86a4adb848dd11a9729e0c5114213f5140a5f05a /main/views.py
parent69d732e1c075b7646d3cb3bbf79acde42252dd90 (diff)
rc1
Diffstat (limited to 'main/views.py')
-rw-r--r--main/views.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/main/views.py b/main/views.py
index 3dc9fd4..6400d59 100644
--- a/main/views.py
+++ b/main/views.py
@@ -4,12 +4,13 @@ from django.template import RequestContext
from fooz.main.models import Player, Match
from datetime import datetime
+from random import randint
import json
def index(request):
- matches = Match.objects.all().order_by('date')
- players = Player.objects.all()
+ matches = Match.objects.all().order_by('-date')[0:5]
+ players = Player.objects.all().order_by('name')
return render_to_response('main.html', {'matches' : matches, 'players' : players}, context_instance=RequestContext(request))
def match(request):
@@ -28,6 +29,10 @@ def match(request):
s2 = int(request.POST.get('s2'))
if None not in (p1, p2, s1, s2):
+ if randint(0,1):
+ p1, p2 = p2, p1
+ p3, p4 = p4, p3
+ s1, s2 = s2, s1
date = datetime.now()
match = Match(player1=p1, player2=p2, player3=p3, player4=p4, score1=s1, score2=s2, date=date)
match.save()