2013-06-02 16:05:37 +02:00
|
|
|
# Create your views here.
|
|
|
|
|
|
|
|
from django.shortcuts import render
|
|
|
|
from django.contrib.auth import authenticate, login
|
|
|
|
from django.shortcuts import redirect
|
|
|
|
|
2013-06-15 21:50:12 +02:00
|
|
|
|
|
|
|
|
2013-06-02 16:05:37 +02:00
|
|
|
def login_site(request):
|
|
|
|
return render( request, 'intern_area/login.html')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main_view(request):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def login_site2(request):
|
|
|
|
if request.method == 'POST': # If the form has been submitted...
|
|
|
|
username = request.POST['username']
|
|
|
|
password = request.POST['password']
|
|
|
|
user = authenticate(username=username, password=password)
|
|
|
|
if user is not None:
|
|
|
|
if user.is_active:
|
|
|
|
if not request.POST.get('remember', None):
|
|
|
|
request.session.set_expiry(0)
|
|
|
|
login(request, user)
|
|
|
|
return redirect( main_view )
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
# Return a 'disabled account' error message
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
# Return an 'invalid login' error message.
|
|
|
|
else:
|
2013-06-15 21:50:12 +02:00
|
|
|
return render( request, 'intern_area/login.html')
|