def create_view(self, request): """ Initiates the organization and user account creation process """ try: if request.user.is_authenticated(): return redirect("organization_add") except TypeError: if request.user.is_authenticated: return redirect("organization_add") form = org_registration_form(self.org_model)(request.POST or None) if form.is_valid(): try: user = self.user_model.objects.get( email=form.cleaned_data['email']) except self.user_model.DoesNotExist: user = self.user_model.objects.create( username=self.get_username(), email=form.cleaned_data['email'], password=self.user_model.objects.make_random_password()) user.is_active = False user.save() else: return redirect("organization_add") organization = create_organization(user, form.cleaned_data['name'], form.cleaned_data['slug'], is_active=False) return render(request, self.activation_success_template, { 'user': user, 'organization': organization }) return render(request, self.registration_form_template, {'form': form})
def create_view(self, request): """ Initiates the organization and user account creation process """ if request.user.is_authenticated: return redirect("organization_add") form = org_registration_form(self.org_model)(request.POST or None) if form.is_valid(): try: user = self.user_model.objects.get(email=form.cleaned_data["email"]) except self.user_model.DoesNotExist: user = self.user_model.objects.create( username=self.get_username(), email=form.cleaned_data["email"], password=self.user_model.objects.make_random_password(), ) user.is_active = False user.save() else: return redirect("organization_add") organization = create_organization( user, form.cleaned_data["name"], form.cleaned_data["slug"], is_active=False, ) return render( request, self.activation_success_template, {"user": user, "organization": organization}, ) return render(request, self.registration_form_template, {"form": form})
def create_view(self, request): """ Initiates the organization and user account creation process """ if request.user.is_authenticated(): return redirect("organization_add") form = org_registration_form(self.org_model)(request.POST or None) if form.is_valid(): try: user = self.user_model.objects.get(email=form.cleaned_data['email']) except self.user_model.DoesNotExist: user = self.user_model.objects.create(username=self.get_username(), email=form.cleaned_data['email'], password=self.user_model.objects.make_random_password()) user.is_active = False user.save() else: return redirect("organization_add") organization = create_organization(user, form.cleaned_data['name'], form.cleaned_data['slug'], is_active=False) return render(request, self.activation_success_template, {'user': user, 'organization': organization}) return render(request, self.registration_form_template, {'form': form})
def create_view(self, request): """ Initiates the organization and user account creation process """ try: if request.user.is_authenticated(): return redirect("organization_add") except TypeError: if request.user.is_authenticated: return redirect("organization_add") form = org_registration_form(self.org_model)(request.POST or None) if form.is_valid(): try: user = self.user_model.objects.get(email=form.cleaned_data["email"]) except self.user_model.DoesNotExist: user = self.user_model.objects.create( username=self.get_username(), email=form.cleaned_data["email"], password=self.user_model.objects.make_random_password(), ) user.is_active = False user.save() else: return redirect("organization_add") organization = create_organization( user, form.cleaned_data["name"], form.cleaned_data["slug"], is_active=False, ) return render( request, self.activation_success_template, {"user": user, "organization": organization}, ) return render(request, self.registration_form_template, {"form": form})