diff --git a/fowl/game/models.py b/fowl/game/models.py index e97ccf5..74f876e 100644 --- a/fowl/game/models.py +++ b/fowl/game/models.py @@ -33,6 +33,11 @@ class Star(models.Model): return self.division != 'other' def win_title(self, title, date, tag_partner=None): + # if they have title on that date (or won it then), don't add anything + if (self.has_title(date) or + self.reigns.filter(title=title, begin_date=date).count()): + return + # end current title reigns TitleReign.objects.filter(title=title).update(end_date=date) self.reigns.create(title=title, begin_date=date) diff --git a/fowl/game/tests.py b/fowl/game/tests.py index f10c5a2..1aa4bb7 100644 --- a/fowl/game/tests.py +++ b/fowl/game/tests.py @@ -25,6 +25,12 @@ class StarTest(TestCase): self.assertEqual(Star.objects.get(pk='cmpunk').has_title(), None) self.assertEqual(Star.objects.get(pk='danielbryan').has_title(), 'wwe') + # test multiple win does nothing + dbry.win_title('wwe', datetime.date(2012,1,1)) + dbry.win_title('wwe', datetime.date(2012,2,1)) + dbry.win_title('wwe', datetime.date(2012,3,1)) + self.assertEqual(dbry.reigns.count(), 1) + # tag belt win self.assertEqual(Star.objects.get(pk='kofi').has_title(), 'tag') self.assertEqual(Star.objects.get(pk='rtruth').has_title(), 'tag')