Пример #1
0
def register(request, social=None, type=None):
    """
    Register view. Allow user creation.
    """
    if not type:
        if request.method == "POST":
            form = forms.RegistrationForm(request.POST)
            if form.is_valid():
                form.save(request)
            else:
                return render(request, "registration/register.html", get_context(social=social, form=form))
        else:
            form = forms.RegistrationForm()
            return render(request, "registration/register.html", get_context(social=social, form=form))
    else:
        if not has_user_related(request.user):
            UserInfo.create_user(dj_user=request.user, type=type)
        else:
            return redirect('account')

    return HttpResponseRedirect('/confirmation/')
Пример #2
0
 def save(self, request):
     # Create user
     dj_user = User.objects.create_user(
         self.cleaned_data["email"],
         self.cleaned_data["email"],
         self.cleaned_data["password"]
     )
     dj_user.is_active = False
     dj_user.save()
     # Create famille / prestataire and link to user
     user = UserInfo.create_user(dj_user=dj_user, type=self.data["type"])
     user.send_verification_email(request)