from django.contrib.auth.models import User
from hashlib import sha1
from django.shortcuts import render
from django.contrib.auth import authenticate, login, logout
from django.http import HttpResponse, HttpResponseRedirect
# Create your views here.
'''
def signup(request):
    status = ''
    if request.method == "POST":
        try:
            preq = request.POST
            user_ed = User()
            user_ed.password = sha256(preq['drwsp'])
            user_ed.first_name = preq["co_name"]
            user_ed.last_name = preq["phone_num"]
            user_ed.email = preq["email"]
            user_ed.username = preq["email"]
            user_ed.save()

            status = "Submission Complete"
            return HttpResponseRedirect("/accounts")
            
        except:
            status = "Error During Submission."

    template = "signup.html"
    context = {"welcome":"welcome",
               "status": status,
              }
    return render(request,template,context) 
'''


def signup(request):
    status = ''
    if request.method == 'POST':
            u_data = request.POST   
            user_creator = User.objects.create_user(
                     username = u_data['email'],
                     email =  u_data['email'],
                     password =  u_data['drwsp'],
                     first_name =  u_data['co_name'],
                     last_name =  u_data['phone_num'],
                     )
            user_creator.save()
            status = "Submission Complete"
            return HttpResponseRedirect("/submit")
    
    template = "signup.html"
    context = {"welcome":"welcome",
               "status":"status"
               }
    return render(request, template, context)

             
           

    
def login_form(request):
    template = "accounts.html"
   
    context = {'welcome':'welcome'}
  
    return render(request, template, context)


def login_user(request):
    status = "Unknown"
 
    try:
        username = request.POST['email'] #Add Filtering here
    except: 
        status = "problem with username"    
        
    try:
        password = request.POST['password'] #Add Filtering here
        print password
    except:
        status = "problem with username"    
    
    status = "Problem with auth"
    user = authenticate(username = username, password = password)
    print user
   
 
    if user is not None:
        if user.is_active:
            login(request,user)
            return HttpResponseRedirect('/submit')

        else:
            return HttpResponse("Disabled Account")

    else:
        status = "Invalid Sign in"
        return HttpResponse("Invalid Login: %s" % status)

def logout_view(request):
    logout(request)
    return HttpResponseRedirect("/accounts") 

@@ -1732,39 +1732,8 @@
 t)%0A%0A
-             %0A           %0A%0A    
 %0Adef
@@ -1785,20 +1785,16 @@
 s.html%22%0A
-   %0A
     cont
@@ -1821,19 +1821,16 @@
 lcome'%7D%0A
-  %0A
     retu
@@ -2136,27 +2136,8 @@
 %0A   
-     print password
 %0A   
@@ -2298,28 +2298,12 @@
 rd)%0A
+%0A
    
- print user%0A   %0A 
 %0A   

Update views.py