def setUp(self): self.user = User.objects.create_user(username='******', email='*****@*****.**', password='******') self.client.login(username='******', password='******') self.organization = Organization(name='Foo Org') self.organization.save() assign_admin_perms(self.organization, self.user) self.url = reverse('api_retrieve_organization', args=(self.organization.id,))
def setUp(self): self.user = User.objects.create_user(username="******", email="*****@*****.**", password="******") self.org = Organization(name="Foo Org") self.org.save() assign_admin_perms(self.org, self.user) self.invite = OrganizationInvite(email="*****@*****.**", organization=self.org, user=self.user) self.invite.token = get_random_string(length=20, allowed_chars="ABCDEFGHJKMNPQRST23456789") self.invite.save()
def form_valid(self, form): org = Organization(name=form.cleaned_data['name']) org.save() self.request.user.userprofile.phone_number = form.cleaned_data['phone_number'] self.request.user.userprofile.save() assign_admin_perms(org, self.request.user) return super(OrganizationOnboardingView, self).form_valid(form)
def test_create_invite(self): self.org = Organization(name="Foo Org") self.org.save() assign_admin_perms(self.org, self.user) url = reverse("api_invite_user", args=(self.org.id,)) data = {"email": "*****@*****.**"} resp = self.client.post(url, data, format="json") self.assertEquals(20, len(resp.data["token"])) self.assertEquals(resp.data["user"]["id"], self.user.id)
def test_create_invite(self): self.org = Organization(name='Foo Org') self.org.save() assign_admin_perms(self.org, self.user) url = reverse('api_invite_user', args=(self.org.id, )) data = {"email": "*****@*****.**"} resp = self.client.post(url, data, format='json') self.assertEquals(20, len(resp.data['token'])) self.assertEquals(resp.data['user']['id'], self.user.id)
def setUp(self): self.user = User.objects.create_user(username='******', email='*****@*****.**', password='******') self.org = Organization(name='Foo Org') self.org.save() assign_admin_perms(self.org, self.user) self.invite = OrganizationInvite(email='*****@*****.**', organization=self.org, user=self.user) self.invite.token = get_random_string( length=20, allowed_chars='ABCDEFGHJKMNPQRST23456789') self.invite.save()
def post_save(self, obj, created): if created: assign_admin_perms(obj, self.request.user)