increase separation between fantasy and... wrestling

This commit is contained in:
James Turk 2012-05-27 20:13:16 -04:00
parent e5731e334b
commit ec7fb9492a
2 changed files with 5 additions and 8 deletions

View File

@ -34,9 +34,6 @@ class Star(models.Model):
tag_partner.title = title tag_partner.title = title
tag_partner.save() tag_partner.save()
def drafted(self, league):
return self.teams.filter(league=league).count() >= 1
def __unicode__(self): def __unicode__(self):
return self.name return self.name
@ -221,11 +218,11 @@ class Team(models.Model):
stars = models.ManyToManyField(Star, related_name='teams') stars = models.ManyToManyField(Star, related_name='teams')
def add_star(self, pk): def add_star(self, pk):
member = Star.objects.get(pk=pk) star = Star.objects.get(pk=pk)
if member.drafted(self.league): if self.league.teams.filter(stars=star).count() >= 1:
raise ValueError('cannot add {0}, already drafted in {1}'.format( raise ValueError('cannot add {0}, already drafted in {1}'.format(
member, self.league)) star, self.league))
self.stars.add(member) self.stars.add(star)
def drop_star(self, pk): def drop_star(self, pk):
member = Star.objects.get(pk=pk) member = Star.objects.get(pk=pk)

View File

@ -7,7 +7,7 @@ def _give_belt(star, belt):
Star.objects.get(pk=star).win_title(belt) Star.objects.get(pk=star).win_title(belt)
class StarTest(TestCase): class StarTest(TestCase):
def test_win_belt(self): def test_win_title(self):
cmpunk = Star.objects.create(pk='cmpunk', name='CM Punk', title='wwe') cmpunk = Star.objects.create(pk='cmpunk', name='CM Punk', title='wwe')
dbry = Star.objects.create(pk='danielbryan', name='Daniel Bryan') dbry = Star.objects.create(pk='danielbryan', name='Daniel Bryan')
kofi = Star.objects.create(pk='kofi', name='Kofi Kingston', kofi = Star.objects.create(pk='kofi', name='Kofi Kingston',