lowercase dq, new display, replace heavyweight with world
This commit is contained in:
parent
4acc63478f
commit
6022cb32ef
@ -6,20 +6,21 @@ Q = models.Q
|
|||||||
# these things are independent of the game
|
# these things are independent of the game
|
||||||
|
|
||||||
OUTCOMES = (('no contest', 'no contest'),
|
OUTCOMES = (('no contest', 'no contest'),
|
||||||
('normal', 'normal'),
|
('normal', 'pinfall/normal'),
|
||||||
('DQ', 'DQ'),
|
('dq', 'disqualification'),
|
||||||
('submission', 'submission'),
|
('submission', 'submission'),
|
||||||
('appearance', 'appearance'),
|
('appearance', 'appearance'),
|
||||||
('brawl', 'brawl'),
|
('brawl', 'brawl'),
|
||||||
)
|
)
|
||||||
|
|
||||||
TITLES = (('wwe', 'WWE'),
|
TITLES = (('wwe', 'WWE'),
|
||||||
('heavyweight', 'Heavyweight'),
|
('world', 'World Heavyweight'),
|
||||||
('ic', 'Intercontinental'),
|
('ic', 'Intercontinental'),
|
||||||
('us', 'United States'),
|
('us', 'United States'),
|
||||||
('tag', 'Tag Team'),
|
('tag', 'Tag Team'),
|
||||||
('diva', 'Divas'),
|
('diva', 'Divas'),
|
||||||
)
|
)
|
||||||
|
TITLE_DICT = dict(TITLES)
|
||||||
|
|
||||||
|
|
||||||
class Star(models.Model):
|
class Star(models.Model):
|
||||||
@ -48,8 +49,9 @@ class Star(models.Model):
|
|||||||
|
|
||||||
def has_title(self, date=None):
|
def has_title(self, date=None):
|
||||||
if date:
|
if date:
|
||||||
current_title = list(self.reigns.filter(Q(begin_date__lt=date) &
|
current_title = list(self.reigns.filter(
|
||||||
(Q(end_date__gte=date) | Q(end_date__isnull=True))))
|
Q(begin_date__lt=date) & (Q(end_date__gte=date) |
|
||||||
|
Q(end_date__isnull=True))))
|
||||||
else:
|
else:
|
||||||
current_title = list(self.reigns.filter(end_date__isnull=True))
|
current_title = list(self.reigns.filter(end_date__isnull=True))
|
||||||
if len(current_title) < 1:
|
if len(current_title) < 1:
|
||||||
@ -59,6 +61,12 @@ class Star(models.Model):
|
|||||||
else:
|
else:
|
||||||
return 'multiple' # FIXME
|
return 'multiple' # FIXME
|
||||||
|
|
||||||
|
def titled_name(self, date):
|
||||||
|
title = self.has_title(date)
|
||||||
|
name = self.name
|
||||||
|
if title:
|
||||||
|
name = '{0} ({1} Champion)'.format(name, TITLE_DICT[title])
|
||||||
|
return name
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
@ -104,7 +112,7 @@ class Event(models.Model):
|
|||||||
|
|
||||||
def add_match(self, *teams, **kwargs):
|
def add_match(self, *teams, **kwargs):
|
||||||
winner = kwargs.get('winner', None)
|
winner = kwargs.get('winner', None)
|
||||||
outcome = kwargs.get('outcome', '')
|
outcome = kwargs.get('outcome', 'no contest')
|
||||||
title_at_stake = kwargs.get('title_at_stake', None)
|
title_at_stake = kwargs.get('title_at_stake', None)
|
||||||
notes = kwargs.get('notes', '')
|
notes = kwargs.get('notes', '')
|
||||||
|
|
||||||
@ -139,7 +147,8 @@ class Event(models.Model):
|
|||||||
class Match(models.Model):
|
class Match(models.Model):
|
||||||
event = models.ForeignKey(Event, related_name='matches')
|
event = models.ForeignKey(Event, related_name='matches')
|
||||||
winner = models.ForeignKey(Star, null=True)
|
winner = models.ForeignKey(Star, null=True)
|
||||||
outcome = models.CharField(max_length=10, choices=OUTCOMES)
|
outcome = models.CharField(max_length=10, choices=OUTCOMES,
|
||||||
|
default='no contest')
|
||||||
title_at_stake = models.CharField(max_length=50, choices=TITLES, null=True)
|
title_at_stake = models.CharField(max_length=50, choices=TITLES, null=True)
|
||||||
notes = models.TextField(blank=True, default='')
|
notes = models.TextField(blank=True, default='')
|
||||||
|
|
||||||
@ -202,7 +211,7 @@ class Match(models.Model):
|
|||||||
|
|
||||||
# figure out base points for winning
|
# figure out base points for winning
|
||||||
# DQ wins are worth 1 point no matter what
|
# DQ wins are worth 1 point no matter what
|
||||||
if self.outcome == 'DQ':
|
if self.outcome == 'dq':
|
||||||
base_points = 1
|
base_points = 1
|
||||||
allies = 0 # allies don't matter in a DQ
|
allies = 0 # allies don't matter in a DQ
|
||||||
# rumble is worth participants/2
|
# rumble is worth participants/2
|
||||||
@ -221,13 +230,13 @@ class Match(models.Model):
|
|||||||
if self.title_at_stake:
|
if self.title_at_stake:
|
||||||
if winners.title == self.title_at_stake:
|
if winners.title == self.title_at_stake:
|
||||||
# title defense
|
# title defense
|
||||||
if winners.title in ('heavyweight', 'wwe'):
|
if winners.title in ('world', 'wwe'):
|
||||||
points[w.id] += 5
|
points[w.id] += 5
|
||||||
else:
|
else:
|
||||||
points[w.id] += 3
|
points[w.id] += 3
|
||||||
elif self.outcome in ('normal', 'submission'):
|
elif self.outcome in ('normal', 'submission'):
|
||||||
# title win!
|
# title win!
|
||||||
if self.title_at_stake in ('heavyweight', 'wwe'):
|
if self.title_at_stake in ('world', 'wwe'):
|
||||||
points[w.id] += 20
|
points[w.id] += 20
|
||||||
else:
|
else:
|
||||||
points[w.id] += 10
|
points[w.id] += 10
|
||||||
@ -256,11 +265,22 @@ class Match(models.Model):
|
|||||||
points[self.winner_id] += 1
|
points[self.winner_id] += 1
|
||||||
return points
|
return points
|
||||||
|
|
||||||
def __unicode__(self):
|
def fancy(self):
|
||||||
ret = ' vs. '.join(str(t) for t in
|
teams = [t.fancy(self.event.date) for t in
|
||||||
self.teams.all().prefetch_related('members'))
|
self.teams.all().order_by('-victorious')
|
||||||
if not self.winner_id:
|
.prefetch_related('members')]
|
||||||
ret += ' (no contest)'
|
if self.outcome in ('normal', 'dq', 'submission'):
|
||||||
|
ret = '{0} defeats {1}'.format(teams[0], ', '.join(teams[1:]))
|
||||||
|
ret += {'normal': '', 'dq': ' via disqualification',
|
||||||
|
'submission': ' via submission'}[self.outcome]
|
||||||
|
elif self.outcome == 'appearance':
|
||||||
|
ret = 'appearance by {0}'.format(', '.join(teams))
|
||||||
|
elif self.outcome == 'brawl':
|
||||||
|
ret = 'brawl between {0}'.format(', '.join(teams))
|
||||||
|
elif self.outcome == 'no contest':
|
||||||
|
ret = '{0} - fight to a no contest'.format(' vs. '.join(teams))
|
||||||
|
else:
|
||||||
|
print self.outcome
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
@ -270,13 +290,8 @@ class MatchTeam(models.Model):
|
|||||||
victorious = models.BooleanField(default=False)
|
victorious = models.BooleanField(default=False)
|
||||||
title = models.CharField(max_length=50, choices=TITLES, null=True)
|
title = models.CharField(max_length=50, choices=TITLES, null=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def fancy(self, date):
|
||||||
ret = ' & '.join([str(m) for m in self.members.all()])
|
return ' & '.join([m.titled_name(date) for m in self.members.all()])
|
||||||
if self.title:
|
|
||||||
ret += ' (c)'
|
|
||||||
if self.victorious:
|
|
||||||
ret += ' (v)'
|
|
||||||
return ret
|
|
||||||
|
|
||||||
|
|
||||||
# fantasy stuff
|
# fantasy stuff
|
||||||
|
@ -41,7 +41,7 @@ PPVs, since the creation of this league.</p>
|
|||||||
{% for match, tp_list in event.match_list.items %}
|
{% for match, tp_list in event.match_list.items %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p>{{match}}</p>
|
<p>{{match.fancy}}</p>
|
||||||
<p class="match-notes">{{match.notes}}</p>
|
<p class="match-notes">{{match.notes}}</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -135,17 +135,21 @@ class MatchTest(TestCase):
|
|||||||
self.event = Event.objects.create(name='Wrestlemania 29',
|
self.event = Event.objects.create(name='Wrestlemania 29',
|
||||||
date='2012-04-01')
|
date='2012-04-01')
|
||||||
|
|
||||||
def test_display(self):
|
def test_fancy_display(self):
|
||||||
|
# no contest
|
||||||
match = self.event.add_match('tripleh', 'undertaker')
|
match = self.event.add_match('tripleh', 'undertaker')
|
||||||
self.assertEqual(unicode(match),
|
self.assertEqual(match.fancy(),
|
||||||
'Triple H vs. Undertaker (no contest)')
|
'Triple H vs. Undertaker - fight to a no contest')
|
||||||
|
|
||||||
|
# normal win
|
||||||
match.record_win('undertaker', 'normal')
|
match.record_win('undertaker', 'normal')
|
||||||
self.assertEqual(unicode(match), 'Triple H vs. Undertaker (v)')
|
self.assertEqual(match.fancy(), 'Undertaker defeats Triple H')
|
||||||
|
|
||||||
_give_belt('cmpunk', 'wwe')
|
_give_belt('cmpunk', 'wwe')
|
||||||
match = self.event.add_match('cmpunk', 'reymysterio', winner='cmpunk',
|
match = self.event.add_match('cmpunk', 'reymysterio', 'danielbryan',
|
||||||
outcome='normal')
|
winner='cmpunk', outcome='submission')
|
||||||
self.assertEqual(unicode(match), 'CM Punk (c) (v) vs. Rey Mysterio')
|
self.assertEqual(match.fancy(),
|
||||||
|
'CM Punk (WWE Champion) defeats Rey Mysterio, Daniel Bryan via submission')
|
||||||
|
|
||||||
def test_to_dict(self):
|
def test_to_dict(self):
|
||||||
match = self.event.add_match('jimross', 'jerrylawler', 'michaelcole',
|
match = self.event.add_match('jimross', 'jerrylawler', 'michaelcole',
|
||||||
@ -216,7 +220,7 @@ class MatchTest(TestCase):
|
|||||||
|
|
||||||
# DQ : 1 point
|
# DQ : 1 point
|
||||||
match = self.event.add_match('kane', 'undertaker', winner='undertaker',
|
match = self.event.add_match('kane', 'undertaker', winner='undertaker',
|
||||||
outcome='DQ')
|
outcome='dq')
|
||||||
self.assertEqual(match.points(), {'undertaker': 1, 'kane': 0})
|
self.assertEqual(match.points(), {'undertaker': 1, 'kane': 0})
|
||||||
|
|
||||||
# submission: +1
|
# submission: +1
|
||||||
@ -254,7 +258,7 @@ class MatchTest(TestCase):
|
|||||||
match = self.event.add_match(['kofikingston', 'rtruth'],
|
match = self.event.add_match(['kofikingston', 'rtruth'],
|
||||||
['jackswagger', 'dolphziggler'],
|
['jackswagger', 'dolphziggler'],
|
||||||
winner='dolphziggler',
|
winner='dolphziggler',
|
||||||
outcome='DQ')
|
outcome='dq')
|
||||||
self.assertEqual(match.points(), {'jackswagger': 1,
|
self.assertEqual(match.points(), {'jackswagger': 1,
|
||||||
'dolphziggler': 1,
|
'dolphziggler': 1,
|
||||||
'kofikingston': 0,
|
'kofikingston': 0,
|
||||||
@ -336,7 +340,7 @@ class MatchTest(TestCase):
|
|||||||
|
|
||||||
# title non-defense (DQ/countout)
|
# title non-defense (DQ/countout)
|
||||||
match = self.event.add_match('christian', 'codyrhodes',
|
match = self.event.add_match('christian', 'codyrhodes',
|
||||||
winner='codyrhodes', outcome='DQ',
|
winner='codyrhodes', outcome='dq',
|
||||||
title_at_stake='ic')
|
title_at_stake='ic')
|
||||||
self.assertEqual(match.points(), {'codyrhodes': 1, 'christian': 1})
|
self.assertEqual(match.points(), {'codyrhodes': 1, 'christian': 1})
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ def league(request, league_id):
|
|||||||
'teams': {team: 0 for team in teams}},
|
'teams': {team: 0 for team in teams}},
|
||||||
'ic': {'name': None, 'points': 0, 'date': None,
|
'ic': {'name': None, 'points': 0, 'date': None,
|
||||||
'teams': {team: 0 for team in teams}},
|
'teams': {team: 0 for team in teams}},
|
||||||
'heavyweight': {'name': None, 'points': 0, 'date': None,
|
'world': {'name': None, 'points': 0, 'date': None,
|
||||||
'teams': {team: 0 for team in teams}},
|
'teams': {team: 0 for team in teams}},
|
||||||
'wwe': {'name': None, 'points': 0, 'date': None,
|
'wwe': {'name': None, 'points': 0, 'date': None,
|
||||||
'teams': {team: 0 for team in teams}},
|
'teams': {team: 0 for team in teams}},
|
||||||
@ -106,7 +106,7 @@ def league(request, league_id):
|
|||||||
# go over all events in order to determine belt holders
|
# go over all events in order to determine belt holders
|
||||||
for event in Event.objects.all().order_by('date'):
|
for event in Event.objects.all().order_by('date'):
|
||||||
# determine which belt is being competed for
|
# determine which belt is being competed for
|
||||||
belt_name = belt_mapping.get(event.name.lower(), 'heavyweight')
|
belt_name = belt_mapping.get(event.name.lower(), 'world')
|
||||||
# get team scores for this event
|
# get team scores for this event
|
||||||
team_points = TeamPoints.objects.filter(match__event=event
|
team_points = TeamPoints.objects.filter(match__event=event
|
||||||
).values('team__name').annotate(points=Sum('points'))
|
).values('team__name').annotate(points=Sum('points'))
|
||||||
@ -132,7 +132,7 @@ def league(request, league_id):
|
|||||||
belts[belt_name]['name'] = ew
|
belts[belt_name]['name'] = ew
|
||||||
belts[belt_name]['date'] = event.date
|
belts[belt_name]['date'] = event.date
|
||||||
# do WWE belt check on PPVs
|
# do WWE belt check on PPVs
|
||||||
if belt_name == 'heavyweight':
|
if belt_name == 'world':
|
||||||
belt_name = 'wwe'
|
belt_name = 'wwe'
|
||||||
if belts[belt_name]['teams'][ew] > belts[belt_name]['points']:
|
if belts[belt_name]['teams'][ew] > belts[belt_name]['points']:
|
||||||
belts[belt_name]['points'] = belts[belt_name]['teams'][ew]
|
belts[belt_name]['points'] = belts[belt_name]['teams'][ew]
|
||||||
|
@ -8,7 +8,7 @@ Team.objects.all().delete()
|
|||||||
Event.objects.all().delete()
|
Event.objects.all().delete()
|
||||||
|
|
||||||
_give_belt('cmpunk', 'wwe')
|
_give_belt('cmpunk', 'wwe')
|
||||||
_give_belt('sheamus', 'heavyweight')
|
_give_belt('sheamus', 'world')
|
||||||
_give_belt('kofikingston', 'tag')
|
_give_belt('kofikingston', 'tag')
|
||||||
_give_belt('rtruth', 'tag')
|
_give_belt('rtruth', 'tag')
|
||||||
_give_belt('layla', 'diva')
|
_give_belt('layla', 'diva')
|
||||||
@ -56,7 +56,7 @@ event.add_match(['brodusclay', 'kofikingston', 'rtruth'],
|
|||||||
['themiz', 'jackswagger', 'dolphziggler'],
|
['themiz', 'jackswagger', 'dolphziggler'],
|
||||||
winner='brodusclay', outcome='normal')
|
winner='brodusclay', outcome='normal')
|
||||||
event.add_match('chrisjericho', 'randyorton',
|
event.add_match('chrisjericho', 'randyorton',
|
||||||
winner='chrisjericho', outcome='DQ',
|
winner='chrisjericho', outcome='dq',
|
||||||
notes='Sheamus interfered, giving Jericho the win')
|
notes='Sheamus interfered, giving Jericho the win')
|
||||||
event.add_match('paulheyman', outcome='appearance',
|
event.add_match('paulheyman', outcome='appearance',
|
||||||
notes='Paul Heyman is going to sue for Bork Laser')
|
notes='Paul Heyman is going to sue for Bork Laser')
|
||||||
@ -93,7 +93,7 @@ event.add_match('layla', 'bethphoenix', winner='layla',
|
|||||||
outcome='normal', title_at_stake='diva')
|
outcome='normal', title_at_stake='diva')
|
||||||
event.add_match('sheamus', 'randyorton', 'chrisjericho', 'albertodelrio',
|
event.add_match('sheamus', 'randyorton', 'chrisjericho', 'albertodelrio',
|
||||||
winner='sheamus', outcome='normal',
|
winner='sheamus', outcome='normal',
|
||||||
title_at_stake='heavyweight')
|
title_at_stake='world')
|
||||||
event.add_match('brodusclay', 'themiz', winner='brodusclay', outcome='normal')
|
event.add_match('brodusclay', 'themiz', winner='brodusclay', outcome='normal')
|
||||||
m = event.add_match('christian', 'codyrhodes', winner='christian',
|
m = event.add_match('christian', 'codyrhodes', winner='christian',
|
||||||
outcome='normal', title_at_stake='ic')
|
outcome='normal', title_at_stake='ic')
|
||||||
@ -113,8 +113,8 @@ event.add_match('davidotunga', 'johncena', winner='johncena',
|
|||||||
# Brawl: Tyler Reks & Curt Hawkins & Titus O'Neil & Daren Young & Sheamus
|
# Brawl: Tyler Reks & Curt Hawkins & Titus O'Neil & Daren Young & Sheamus
|
||||||
# Brawl: Santino vs. Ricardo
|
# Brawl: Santino vs. Ricardo
|
||||||
event.add_match('albertodelrio', 'randyorton', winner='randyorton',
|
event.add_match('albertodelrio', 'randyorton', winner='randyorton',
|
||||||
outcome='DQ', notes='Jericho codebreaks RKO, Orton wins')
|
outcome='dq', notes='Jericho codebreaks RKO, Orton wins')
|
||||||
event.add_match('danielbryan', 'kane', winner='danielbryan', outcome='DQ',
|
event.add_match('danielbryan', 'kane', winner='danielbryan', outcome='dq',
|
||||||
notes='Kane uses chair, Bryan wins')
|
notes='Kane uses chair, Bryan wins')
|
||||||
event.add_match('christian', 'jindermahal', winner='christian', outcome='normal')
|
event.add_match('christian', 'jindermahal', winner='christian', outcome='normal')
|
||||||
event.add_match('bethphoenix', 'kellykelly', winner='bethphoenix',
|
event.add_match('bethphoenix', 'kellykelly', winner='bethphoenix',
|
||||||
|
Loading…
Reference in New Issue
Block a user