def test_get_current_site(self):
     """
     Test of get_current_site
     """
     rf = RequestFactory()
     request = rf.get('/hello/')
     site = get_current_site(request)
     assert site
 def post(self, request, *args, **kwargs):
     self.object = self.get_object()
     invitation_backend().send_reminder(
         self.object.user, **{
             'domain': get_current_site(self.request),
             'organization': self.organization,
             'sender': request.user
         })
     return redirect(self.object)
 def save(self, **kwargs):
     """
     Create the organization, then get the user, then make the owner.
     """
     is_active = True
     try:
         user = get_user_model().objects.get(email=self.cleaned_data['email'])
     except get_user_model().DoesNotExist:
         user = invitation_backend().invite_by_email(
                 self.cleaned_data['email'],
                 **{'domain': get_current_site(self.request),
                     'organization': self.cleaned_data['name'],
                     'sender': self.request.user, 'created': True})
         is_active = False
     return create_organization(user, self.cleaned_data['name'],
             self.cleaned_data['slug'], is_active=is_active)
 def save(self, *args, **kwargs):
     """
     The save method should create a new OrganizationUser linking the User
     matching the provided email address. If not matching User is found it
     should kick off the registration process. It needs to create a User in
     order to link it to the Organization.
     """
     try:
         user = get_user_model().objects.get(email__iexact=self.cleaned_data['email'])
     except get_user_model().MultipleObjectsReturned:
         raise forms.ValidationError(_("This email address has been used multiple times."))
     except get_user_model().DoesNotExist:
         user = invitation_backend().invite_by_email(
                 self.cleaned_data['email'],
                 **{'domain': get_current_site(self.request),
                     'organization': self.organization})
     return OrganizationUser.objects.create(user=user,
             organization=self.organization,
             is_admin=self.cleaned_data['is_admin'])
Beispiel #5
0
 def save(self, **kwargs):
     """
     Create the organization, then get the user, then make the owner.
     """
     is_active = True
     try:
         user = get_user_model().objects.get(
             email=self.cleaned_data['email'])
     except get_user_model().DoesNotExist:
         user = invitation_backend().invite_by_email(
             self.cleaned_data['email'], **{
                 'domain': get_current_site(self.request),
                 'organization': self.cleaned_data['name'],
                 'sender': self.request.user,
                 'created': True
             })
         is_active = False
     return create_organization(user,
                                self.cleaned_data['name'],
                                self.cleaned_data['slug'],
                                is_active=is_active)
Beispiel #6
0
 def save(self, *args, **kwargs):
     """
     The save method should create a new OrganizationUser linking the User
     matching the provided email address. If not matching User is found it
     should kick off the registration process. It needs to create a User in
     order to link it to the Organization.
     """
     try:
         user = get_user_model().objects.get(
             email__iexact=self.cleaned_data['email'])
     except get_user_model().MultipleObjectsReturned:
         raise forms.ValidationError(
             _("This email address has been used multiple times."))
     except get_user_model().DoesNotExist:
         user = invitation_backend().invite_by_email(
             self.cleaned_data['email'], **{
                 'domain': get_current_site(self.request),
                 'organization': self.organization
             })
     return OrganizationUser.objects.create(
         user=user,
         organization=self.organization,
         is_admin=self.cleaned_data['is_admin'])