from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth import authenticate, login
from django.contrib.auth import logout
from django.shortcuts import render_to_response
from django.contrib.auth.decorators import login_required
from models import ToDoItem
from forms import ToDoItemForm
from django.forms.models import modelformset_factory


def welcome(request):
    return render_to_response("welcome.html",{})

# Not being used currently
def login_view(request):
    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)
            return HttpResponse('ToDoProject/profile')
            # Redirect to a success page.
        else:
            print ("Your account has been disabled.")
            # Return a 'disabled account' error message
    else:
        print ("The username and password were incorrect.")
        # Return an 'invalid login' error message.

def logout_view(request):
    logout(request)
    return HttpResponseRedirect('/')

@login_required
def profile(request):
    ToDoItemFormSet = modelformset_factory(ToDoItem, ToDoItemForm)
    response = {"name":request.user, "form": ToDoItemFormSet}
    return render_to_response('profile.html',response)

#def changeProfileView(request):


d056c0f7ad884c80d47d824e0a22772d2f0b2466
<mask token>


def login_view(request):
    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)
            return HttpResponse('ToDoProject/profile')
        else:
            print('Your account has been disabled.')
    else:
        print('The username and password were incorrect.')


<mask token>

<mask token>


def welcome(request):
    return render_to_response('welcome.html', {})


def login_view(request):
    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)
            return HttpResponse('ToDoProject/profile')
        else:
            print('Your account has been disabled.')
    else:
        print('The username and password were incorrect.')


<mask token>


@login_required
def profile(request):
    ToDoItemFormSet = modelformset_factory(ToDoItem, ToDoItemForm)
    response = {'name': request.user, 'form': ToDoItemFormSet}
    return render_to_response('profile.html', response)

<mask token>


def welcome(request):
    return render_to_response('welcome.html', {})


def login_view(request):
    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)
            return HttpResponse('ToDoProject/profile')
        else:
            print('Your account has been disabled.')
    else:
        print('The username and password were incorrect.')


def logout_view(request):
    logout(request)
    return HttpResponseRedirect('/')


@login_required
def profile(request):
    ToDoItemFormSet = modelformset_factory(ToDoItem, ToDoItemForm)
    response = {'name': request.user, 'form': ToDoItemFormSet}
    return render_to_response('profile.html', response)

from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth import authenticate, login
from django.contrib.auth import logout
from django.shortcuts import render_to_response
from django.contrib.auth.decorators import login_required
from models import ToDoItem
from forms import ToDoItemForm
from django.forms.models import modelformset_factory


def welcome(request):
    return render_to_response('welcome.html', {})


def login_view(request):
    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)
            return HttpResponse('ToDoProject/profile')
        else:
            print('Your account has been disabled.')
    else:
        print('The username and password were incorrect.')


def logout_view(request):
    logout(request)
    return HttpResponseRedirect('/')


@login_required
def profile(request):
    ToDoItemFormSet = modelformset_factory(ToDoItem, ToDoItemForm)
    response = {'name': request.user, 'form': ToDoItemFormSet}
    return render_to_response('profile.html', response)

from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth import authenticate, login
from django.contrib.auth import logout
from django.shortcuts import render_to_response
from django.contrib.auth.decorators import login_required
from models import ToDoItem
from forms import ToDoItemForm
from django.forms.models import modelformset_factory


def welcome(request):
    return render_to_response("welcome.html",{})

# Not being used currently
def login_view(request):
    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)
            return HttpResponse('ToDoProject/profile')
            # Redirect to a success page.
        else:
            print ("Your account has been disabled.")
            # Return a 'disabled account' error message
    else:
        print ("The username and password were incorrect.")
        # Return an 'invalid login' error message.

def logout_view(request):
    logout(request)
    return HttpResponseRedirect('/')

@login_required
def profile(request):
    ToDoItemFormSet = modelformset_factory(ToDoItem, ToDoItemForm)
    response = {"name":request.user, "form": ToDoItemFormSet}
    return render_to_response('profile.html',response)

#def changeProfileView(request):

