Ejemplo n.º 1
0
def nuevo_usuario(request):
    context = RequestContext(request)
    if request.method == 'POST':
        username = request.POST['username']
        try:
            user = User.objects.get(username=username)
            return HttpResponse(status=203)
        except User.DoesNotExist:
            n_u = User()
            n_u.username = username
            n_u.email = request.POST['email']
            password = request.POST['password']
            n_u.set_password(password)
            n_u.save()
            user = authenticate(username=username, password=password)
            login(request, user)

            ####AUTOSEGUIRSE
            toFollow = request.user
            seguir = Follow()
            seguir.following = request.user  #YO
            seguir.follower = toFollow  #YO
            seguir.save()

            return HttpResponse(status=204)
    return render_to_response('nuevousuario.html', context)
Ejemplo n.º 2
0
def ingreso_usuario(request):
    context = RequestContext(request)
    if not request.user.is_authenticated():
        if request.method == 'POST':
            username = request.POST['username']
            password = request.POST['password']
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
                    if not Follow.objects.filter(
                            follower=request.user,
                            following=request.user).exists():
                        toFollow = request.user
                        seguir = Follow()
                        seguir.following = request.user  #YO
                        seguir.follower = toFollow  #YO
                        seguir.save()
                    return HttpResponse("")
                else:
                    return HttpResponse(status=203)
            else:
                return HttpResponse(status=203)
        else:
            return render_to_response('loguear.html', context)
    else:
        return render_to_response('loguear.html', context)
Ejemplo n.º 3
0
def nuevo_usuario(request):
    context = RequestContext(request)
    if request.method=='POST':
        username=request.POST['username']
        try:
            user = User.objects.get(username=username)
            return HttpResponse(status=203)
        except User.DoesNotExist:
            n_u=User()
            n_u.username=username
            n_u.email=request.POST['email']
            password=request.POST['password']
            n_u.set_password(password)
            n_u.save()
            user = authenticate(username=username, password=password)
            login(request, user)

            ####AUTOSEGUIRSE
            toFollow = request.user
            seguir = Follow()
            seguir.following = request.user #YO
            seguir.follower = toFollow #YO
            seguir.save()

            return HttpResponse(status=204)
    return render_to_response('nuevousuario.html',
                              context)
Ejemplo n.º 4
0
def ingreso_usuario(request):
    context = RequestContext(request)
    if not request.user.is_authenticated():
        if request.method=='POST':
            username=request.POST['username']
            password=request.POST['password']
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
                    if not Follow.objects.filter(follower=request.user, following=request.user).exists():
                        toFollow = request.user
                        seguir = Follow()
                        seguir.following = request.user #YO
                        seguir.follower = toFollow #YO
                        seguir.save()
                    return HttpResponse("");
                else:
                    return HttpResponse(status=203)
            else:
                return HttpResponse(status=203)
        else:
            return render_to_response('loguear.html',
                                              context)
    else:
        return render_to_response('loguear.html',
                                              context)
Ejemplo n.º 5
0
def follow(request, toFollow_un):
    context = RequestContext(request)
    toFollow = User.objects.get(username=toFollow_un)
    seguir = Follow()
    seguir.following = request.user  #YO
    seguir.follower = toFollow  #El Otro
    seguir.save()

    return redirect('/')
Ejemplo n.º 6
0
def follow(request, toFollow_un):
    context = RequestContext(request)
    toFollow = User.objects.get(username=toFollow_un)
    seguir = Follow()
    seguir.following = request.user #YO
    seguir.follower = toFollow #El Otro
    seguir.save()

    return redirect('/')