forked from GithubBackups/healthchecks
Prepare for the removal of Profile.current_team_id
This commit is contained in:
parent
0994006603
commit
77e3212956
@ -180,13 +180,13 @@ class Profile(models.Model):
|
|||||||
return self.member_set.count() < self.team_limit
|
return self.member_set.count() < self.team_limit
|
||||||
|
|
||||||
def invite(self, user):
|
def invite(self, user):
|
||||||
for project in self.user.project_set.all():
|
project = self.get_own_project()
|
||||||
member = Member(team=self, user=user, project=project)
|
Member.objects.create(team=self, user=user, project=project)
|
||||||
member.save()
|
|
||||||
|
|
||||||
# Switch the invited user over to the new team so they
|
# Switch the invited user over to the new team so they
|
||||||
# notice the new team on next visit:
|
# notice the new team on next visit:
|
||||||
user.profile.current_team = self
|
user.profile.current_team = self
|
||||||
|
user.profile.current_project = project
|
||||||
user.profile.save()
|
user.profile.save()
|
||||||
|
|
||||||
user.profile.send_instant_login_link(self)
|
user.profile.send_instant_login_link(self)
|
||||||
|
@ -142,13 +142,11 @@ class ProfileTestCase(BaseTestCase):
|
|||||||
members = self.project.member_set.all()
|
members = self.project.member_set.all()
|
||||||
self.assertEqual(members.count(), 2)
|
self.assertEqual(members.count(), 2)
|
||||||
|
|
||||||
frank_found = False
|
member = Member.objects.get(project=self.project,
|
||||||
for member in members.all():
|
user__email="frank@example.org")
|
||||||
self.assertEqual(member.project, self.project)
|
|
||||||
if member.user.email == "frank@example.org":
|
|
||||||
frank_found = True
|
|
||||||
|
|
||||||
self.assertTrue(frank_found)
|
profile = member.user.profile
|
||||||
|
self.assertEqual(profile.current_project, self.project)
|
||||||
|
|
||||||
# And an email should have been sent
|
# And an email should have been sent
|
||||||
subj = ('You have been invited to join'
|
subj = ('You have been invited to join'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user