Ejemplo n.º 1
0
 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,))
Ejemplo n.º 2
0
 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()
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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()
Ejemplo n.º 7
0
 def post_save(self, obj, created):
     if created:
         assign_admin_perms(obj, self.request.user)
Ejemplo n.º 8
0
 def post_save(self, obj, created):
     if created:
         assign_admin_perms(obj, self.request.user)