diff --git a/fowl/game/models.py b/fowl/game/models.py index db1b49e..cdd4724 100644 --- a/fowl/game/models.py +++ b/fowl/game/models.py @@ -202,7 +202,7 @@ class Match(models.Model): return points def __unicode__(self): - return ' vs. '.join(str(t) for t in self.teams.all()) + return ' vs. '.join(str(t) for t in self.teams.all().prefetch_related('members')) admin.site.register(Match) @@ -227,5 +227,5 @@ class TeamPoints(models.Model): match = models.ForeignKey(Match) def __unicode__(self): - return "{0} recieved {1} points for {2}'s performance in {3}".format( - self.team, self.points, self.star, self.match) \ No newline at end of file + return "{0} received {1} points for {2}'s performance in {3}".format( + self.team, self.points, self.star, self.match) diff --git a/fowl/game/templates/base.html b/fowl/game/templates/base.html index ffe633b..aa92ff1 100644 --- a/fowl/game/templates/base.html +++ b/fowl/game/templates/base.html @@ -12,6 +12,7 @@ padding-top: 60px; padding-bottom: 40px; } + .event-title { font-size: 125%; } diff --git a/fowl/game/templates/events.html b/fowl/game/templates/events.html index 32cc252..63443f8 100644 --- a/fowl/game/templates/events.html +++ b/fowl/game/templates/events.html @@ -5,102 +5,56 @@ {% block content %}

Events

-

Every event that has taken place on RAW, Smackdown, and on PPVs, since the creation of this league.

+

Every event that has taken place on RAW, Smackdown, and on +PPVs, since the creation of this league.

-
-
- -
-
+{% for event in events.values %} - - - - - - - - - - - - - - - - - -
EventPoints
Rey Mysterio vs Sin Cara -
    -
  • GM Punk gets 2 points for Sin Cara victory
  • -
  • COBRA! gets 0 points for Sin Cara victory
  • -
-
Big Show & Kane vs Kaval -
    -
  • COBRA! gets 2 points for Big Show Victory
  • -
  • GM Punk gets 2 points for Kane victory
  • -
  • COBRA! & GM Punk get -2 points for murder
  • -
-
+
+
+ + {{event.name}} - {{event.date}} + + {% for team,score in event.scores.iteritems %} + {{team}}: {{score}} + {% endfor %} +
-
-
-
-
- -
-
- - - - - - - - - - - - - - - - - -
EventPoints
Cody Rhodes vs John Cena -
    -
  • GM Punk gets 2 points for Cody Rhodes victory
  • -
  • I'm AWEsome gets 0 points for Cody Rhodes victory
  • -
-
The Miz vs Santino -
    -
  • COBRA! gets 2 points for Santino Victory
  • -
  • COBRA! gets 4 points for US Championship title defense
  • -
-
-
-
-
-
- -
-
- Didn't want to get presumptious with the scores on this one -
-
-
-
+
+
+ + + + + + + + + {% for match, tp_list in event.match_list.items %} + + + + + {% endfor %} + +
EventScoring
{{match}} +
    + {% for tp in tp_list %} + {% if tp.points %} +
  • {{tp.team}} received {{tp.points}} + point{{tp.points|pluralize}} for {{tp.star}} +
  • + {% endif %} + {% endfor %} +
+
+ +
+
+
+ +{% endfor %} + {% endblock %} diff --git a/fowl/game/views.py b/fowl/game/views.py index 99c5da3..e58068f 100644 --- a/fowl/game/views.py +++ b/fowl/game/views.py @@ -1,7 +1,24 @@ +from collections import defaultdict from django.shortcuts import render +from fowl.game.models import TeamPoints + def events(request): - return render(request, "events.html") + events = {} + points = TeamPoints.objects.filter().order_by('match', + 'team').select_related() + for tp in points: + event_id = tp.match.event_id + if event_id not in events: + events[event_id] = tp.match.event + events[event_id].scores = {} + events[event_id].match_list = {} + events[event_id].match_list.setdefault(tp.match, [] + ).append(tp) + events[event_id].scores.setdefault(tp.team.name, 0) + events[event_id].scores[tp.team.name] += tp.points + return render(request, "events.html", {'events': events}) + def stables(request): return render(request, "stables.html") diff --git a/fowl/settings.py b/fowl/settings.py index c7b77e1..aa4dd4d 100644 --- a/fowl/settings.py +++ b/fowl/settings.py @@ -77,10 +77,13 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', + 'debug_toolbar.middleware.DebugToolbarMiddleware', # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) +INTERNAL_IPS = ('127.0.0.1',) + ROOT_URLCONF = 'fowl.urls' # Python dotted path to the WSGI application used by Django's runserver. @@ -100,6 +103,7 @@ INSTALLED_APPS = ( 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', + 'debug_toolbar', 'fowl.game', ) diff --git a/setup_league.py b/setup_league.py index aabbbbd..2c2ec7c 100644 --- a/setup_league.py +++ b/setup_league.py @@ -4,6 +4,7 @@ from fowl.game.models import League, Star, Team, Event, Match User.objects.all().delete() League.objects.all().delete() Team.objects.all().delete() +Event.objects.all().delete() james = User.objects.create_superuser('james', 'james.p.turk@gmail.com', 'james') erin = User.objects.create_user('erin', 'erin.braswell@gmail.com', 'erin') @@ -26,4 +27,18 @@ for person in awesomes: cobras = ('santinomarella', 'dolphziggler', 'kofikingston', 'albertodelrio', 'randyorton', 'bigshow', 'christian', 'layla', 'natalya') for person in cobras: - cobra.add_star(pk=person) \ No newline at end of file + cobra.add_star(pk=person) + +event = Event.objects.create(name='RAW', date='2012-05-14') +event.add_match(['cmpunk', 'santinomarella'], ['codyrhodes', 'danielbryan'], + winner='cmpunk', win_type='pin') +event.add_match('aliciafox', 'bethphoenix', winner='bethphoenix', + win_type='pin') +event.add_match('bigshow', 'kane', winner='kane', win_type='pin') +event.add_match(['brodusclay', 'kofikingston', 'rtruth'], + ['themiz', 'jackswagger', 'dolphziggler'], + winner='brodusclay', win_type='pin') +event.add_match('chrisjericho', 'randyorton', + winner='chrisjericho', win_type='DQ', + note='Sheamus interfered, giving Jericho the win') +league.score_event(event)