views.py 970 Bytes
Newer Older
Renfred Harper's avatar
Renfred Harper committed
1
2
from django.http import Http404
from django.shortcuts import render_to_response
3
from django.contrib.auth import authenticate, login
4
5
6
7
8
9
10
from django.contrib.auth.decorators import login_required
from django.views.generic import FormView

from django_gmucas.views import login as caslogin
from management.forms import LoginForm

@login_required(login_url='/management/login')
Renfred Harper's avatar
Renfred Harper committed
11
def index(request):
Benjamin S Waters's avatar
Benjamin S Waters committed
12
    return render_to_response('management/index.html')
13

14
15
16
17
18
19
20
21
22
def mylogin(request):
    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 and user.is_staff:
                login(request,user)
                return render_to_response('management/index.html')
23
        else:
24
            return render_to_response('403.html')
25
26
    else:
        return render_to_response('management/login.html')