forked from GithubBackups/healthchecks
Don't create default projects for invited users.
This commit is contained in:
parent
c1e4595ab2
commit
4ff1654806
@ -65,6 +65,8 @@ class ProfileTestCase(BaseTestCase):
|
|||||||
|
|
||||||
profile = member.user.profile
|
profile = member.user.profile
|
||||||
self.assertEqual(profile.current_project, self.project)
|
self.assertEqual(profile.current_project, self.project)
|
||||||
|
# The new user should not have their own project
|
||||||
|
self.assertFalse(member.user.project_set.exists())
|
||||||
|
|
||||||
# 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'
|
||||||
|
@ -43,33 +43,35 @@ def _is_whitelisted(path):
|
|||||||
return match.url_name in NEXT_WHITELIST
|
return match.url_name in NEXT_WHITELIST
|
||||||
|
|
||||||
|
|
||||||
def _make_user(email):
|
def _make_user(email, with_project=True):
|
||||||
username = str(uuid.uuid4())[:30]
|
username = str(uuid.uuid4())[:30]
|
||||||
user = User(username=username, email=email)
|
user = User(username=username, email=email)
|
||||||
user.set_unusable_password()
|
user.set_unusable_password()
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
project = Project(owner=user)
|
project = None
|
||||||
project.badge_key = user.username
|
if with_project:
|
||||||
project.save()
|
project = Project(owner=user)
|
||||||
|
project.badge_key = user.username
|
||||||
|
project.save()
|
||||||
|
|
||||||
|
check = Check(project=project)
|
||||||
|
check.name = "My First Check"
|
||||||
|
check.save()
|
||||||
|
|
||||||
|
channel = Channel(project=project)
|
||||||
|
channel.kind = "email"
|
||||||
|
channel.value = email
|
||||||
|
channel.email_verified = True
|
||||||
|
channel.save()
|
||||||
|
|
||||||
|
channel.checks.add(check)
|
||||||
|
|
||||||
# Ensure a profile gets created
|
# Ensure a profile gets created
|
||||||
profile = Profile.objects.for_user(user)
|
profile = Profile.objects.for_user(user)
|
||||||
profile.current_project = project
|
profile.current_project = project
|
||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
check = Check(project=project)
|
|
||||||
check.name = "My First Check"
|
|
||||||
check.save()
|
|
||||||
|
|
||||||
channel = Channel(project=project)
|
|
||||||
channel.kind = "email"
|
|
||||||
channel.value = email
|
|
||||||
channel.email_verified = True
|
|
||||||
channel.save()
|
|
||||||
|
|
||||||
channel.checks.add(check)
|
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
||||||
@ -275,7 +277,7 @@ def project(request, code):
|
|||||||
try:
|
try:
|
||||||
user = User.objects.get(email=email)
|
user = User.objects.get(email=email)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
user = _make_user(email)
|
user = _make_user(email, with_project=False)
|
||||||
|
|
||||||
project.invite(user)
|
project.invite(user)
|
||||||
ctx["team_member_invited"] = email
|
ctx["team_member_invited"] = email
|
||||||
|
Loading…
x
Reference in New Issue
Block a user