Skip to content

Commit

Permalink
Merge pull request #5130 from onepercentclub/hotfix/team-captian-with…
Browse files Browse the repository at this point in the history
…out-a-team

Fix checking for team captian without a team
  • Loading branch information
gannetson authored Jun 20, 2022
2 parents 135936f + 2a31ab6 commit fa9c7ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bluebottle/activities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def owner(self):

@property
def is_team_captain(self):
return self.user == self.team.owner
return self.team and self.user == self.team.owner

@property
def date(self):
Expand Down
17 changes: 16 additions & 1 deletion bluebottle/activities/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.test import TestCase

from bluebottle.initiatives.tests.factories import InitiativeFactory
from bluebottle.time_based.tests.factories import PeriodActivityFactory
from bluebottle.time_based.tests.factories import PeriodActivityFactory, PeriodParticipantFactory
from bluebottle.segments.tests.factories import SegmentFactory, SegmentTypeFactory
from bluebottle.test.factory_models.accounts import BlueBottleUserFactory
from bluebottle.test.factory_models.geo import LocationFactory
Expand Down Expand Up @@ -98,3 +98,18 @@ def test_office_location_not_required(self):
initiative=InitiativeFactory.create(is_global=False)
)
self.assertFalse('office_location' in activity.required_fields)

def test_is_team_captain_no_team(self):
activity = PeriodActivityFactory.create()
participant = PeriodParticipantFactory.create(activity=activity)
self.assertFalse(participant.is_team_captain)

def test_is_team_captain_with_team(self):
activity = PeriodActivityFactory.create(team_activity='teams')
participant = PeriodParticipantFactory.create(activity=activity)
self.assertTrue(participant.is_team_captain)

participant = PeriodParticipantFactory.create(
activity=activity, accepted_invite=participant.invite
)
self.assertFalse(participant.is_team_captain)

0 comments on commit fa9c7ce

Please sign in to comment.