fixed conflicts

This commit is contained in:
Erin Braswell 2012-05-27 12:55:03 -04:00
commit 10d08a8f8a
6 changed files with 90 additions and 99 deletions

View File

@ -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(
return "{0} received {1} points for {2}'s performance in {3}".format(
self.team, self.points, self.star, self.match)

View File

@ -12,6 +12,7 @@
padding-top: 60px;
padding-bottom: 40px;
}
.event-title { font-size: 125%; }
</style>
<link href="{% static "assets/css/bootstrap-responsive.css" %}" rel="stylesheet">

View File

@ -5,102 +5,56 @@
{% block content %}
<header class="jumbotron subhead" id="overview">
<h1>Events</h1>
<p class="lead">Every event that has taken place on RAW, Smackdown, and on PPVs, since the creation of this league.</p>
<p class="lead">Every event that has taken place on RAW, Smackdown, and on
PPVs, since the creation of this league.</p>
</header>
<div class="accordion" id="accordion2">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
RAW 5/20/2012 3-9-3
</a>
</div>
<div id="collapseOne" class="accordion-body collapse in">
<div class="accordion-inner">
{% for event in events.values %}
<table class="table">
<thead>
<tr>
<th>Event</th>
<th>Points</th>
</tr>
</thead>
<tbody>
<tr>
<td>Rey Mysterio vs Sin Cara</td>
<td>
<ul>
<li>GM Punk gets 2 points for Sin Cara victory</li>
<li>COBRA! gets 0 points for Sin Cara victory</li>
</ul>
</td>
</tr>
<tr>
<td>Big Show & Kane vs Kaval</td>
<td>
<ul>
<li>COBRA! gets 2 points for Big Show Victory</li>
<li>GM Punk gets 2 points for Kane victory</li>
<li>COBRA! & GM Punk get -2 points for murder</li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
Smackdown 5/25/2012 0-4-2
<a class="accordion-toggle event-title" data-toggle="collapse"
data-parent="#accordion" href="#event-{{event.id}}">
{{event.name}} - {{event.date}}
</a>
{% for team,score in event.scores.iteritems %}
{{team}}: {{score}}
{% endfor %}
</div>
<div id="collapseTwo" class="accordion-body collapse">
<div id="event-{{event.id}}" class="accordion-body collapse in">
<div class="accordion-inner">
<table class="table">
<thead>
<tr>
<th>Event</th>
<th>Points</th>
<th>Scoring</th>
</tr>
</thead>
<tbody>
{% for match, tp_list in event.match_list.items %}
<tr>
<td>Cody Rhodes vs John Cena</td>
<td>{{match}}</td>
<td>
<ul>
<li>GM Punk gets 2 points for Cody Rhodes victory</li>
<li>I'm AWEsome gets 0 points for Cody Rhodes victory</li>
</ul>
</td>
</tr>
<tr>
<td>The Miz vs Santino</td>
<td>
<ul>
<li>COBRA! gets 2 points for Santino Victory</li>
<li>COBRA! gets 4 points for US Championship title defense</li>
{% for tp in tp_list %}
{% if tp.points %}
<li> {{tp.team}} received {{tp.points}}
point{{tp.points|pluralize}} for {{tp.star}}
</li>
{% endif %}
{% endfor %}
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseThree">
Summerslam 2012 ?-?-?
</a>
</div>
<div id="collapseThree" class="accordion-body collapse">
<div class="accordion-inner">
Didn't want to get presumptious with the scores on this one
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endblock %}

View File

@ -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")

View File

@ -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',
)

View File

@ -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')
@ -27,3 +28,17 @@ cobras = ('santinomarella', 'dolphziggler', 'kofikingston', 'albertodelrio',
'randyorton', 'bigshow', 'christian', 'layla', 'natalya')
for person in cobras:
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)