Beispiel #1
0
def register(request):
    user = UserForm()

    if request.method == "POST":
        user_input = UserForm(request.POST)

        user_input.save(commit=True)

    else:
        return render(request, 'register.html', {'user': user})
Beispiel #2
0
def register(request):
    registered = False

    if request.method == 'POST':
        user_form = UserForm(data=request.POST)
        profile_form = UserProfileInfoForm(data=request.POST)

        if user_form.is_valid() and profile_form.is_valid():
            user = user_form.save()
            user.set_password(user.password)
            user.save()

            profile = profile_form.save(commit=False)
            profile.user = user

            if 'profile_pic' in request.FILES:
                profile.profile_pic = request.FILES['profile_pic']

            profile.save()
            registered = True
        else:
            print(user_form.errors, profile_form.errors)

    else:
        user_form = UserForm()
        profile_form = UserProfileInfoForm()

    return render(
        request, 'register.html', {
            'user_form': user_form,
            'profile_form': profile_form,
            'registered': registered
        })
Beispiel #3
0
def register(request):
    context = RequestContext(request)
    registered = False
    if request.method == 'POST':
        user_form = UserForm(data=request.POST)
        profile_form = UserProfileForm(data=request.POST)
        if user_form.is_valid() and profile_form.is_valid():
            user = user_form.save()
            user.set_password(user.password)
            user.username=user.email
            user.is_active = False
            user.save()
            profile = profile_form.save(commit=False)
            profile.user = user
            profile.save()
            subject = "Gracias por Registarse a nustra red social cristiana DITAM te ama"
            var1 = str(user.email)+str(user.pk)+"ditam"
            var1 = var1.encode('utf-8')
            var2 = hashlib.md5(var1)
            var2 = var2.hexdigest()
            message = "Para confirmar su cuenta con la red DITAM haga click en el siguiente enlace: http://192.168.1.102:8000/confirmacion?hash="+str(var2)+"&token="+str(user.pk)+""

            from_email = settings.EMAIL_HOST_USER
            to_list = [user.email, settings.EMAIL_HOST_USER]
            send_mail(subject,message,from_email,to_list,fail_silently=False);
            registered = True
            return render(request,'registroCompleto.html',{})

        else:
            pass
    else:
        user_form = UserForm()
        profile_form = UserProfileForm()
    return render_to_response(
            'register.html',
            {'user_form': user_form, 'profile_form': profile_form, 'registered': registered},
            context)