Commit dc6fbf02 authored by Benjamin S Waters's avatar Benjamin S Waters

added login page doesn't know if can actually login

parent 125f29ec
import floppyforms as forms
class LoginForm(forms.Form):
username = forms.CharField()
password = forms.CharField(widget=forms.PasswordInput)
......@@ -2,5 +2,6 @@ from django.conf.urls import patterns, include, url
from management.views import *
urlpatterns = patterns('',
url('', index, name='index'),
url(r'^$', index, name='index'),
url(r'^login/$', mylogin, name='mylogin'),
)
from django.http import Http404
from django.shortcuts import render_to_response
from django.contrib.auth import authenticate, login
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')
def index(request):
return render_to_response('management/index.html')
def login(request):
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')
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')
else:
return render_to_response('403.html')
return render_to_response('403.html')
else:
return render_to_response('management/login.html')
......@@ -2,6 +2,7 @@ Django==1.6.2
South==0.8.4
argparse==1.2.1
django-autoslug==1.7.2
django-floppyforms==1.1.1
django-gmucas==2.1.1
django-leaflet==0.11.1
django-model-utils==2.0.2
......
......@@ -136,14 +136,17 @@ INSTALLED_APPS = (
#'guardian',
)
CAS_GATEWAY=True
ANONYMOUS_USER_ID = -1
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend', # this is default
'cas.middleware.CASMiddleware',
#'guardian.backends.ObjectPermissionBackend',
)
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
LOGIN_URL='/management/login/'
LOGIN_REDIRECT='/management'
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
......@@ -177,3 +180,5 @@ LOGGING = {
CACHE_MIDDLEWARE_ALIAS = 'default'
CACHE_MIDDLEWARE_SECONDS = 259200
CACHE_MIDDLEWARE_KEY_PREFIX = ''
......@@ -12,9 +12,8 @@ urlpatterns = patterns('',
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^admin/', include(admin.site.urls)),
url(r'^login/$', 'django.contrib.auth.views.login', {
'template_name': 'login.html'}),
url(r'^logout/$', 'django.contrib.auth.views.logout', {
'next_page': '/'}),
)
......@@ -3,5 +3,44 @@
{% block content %}
<div class="container">
<h1>Manage</h1>
<div class="row clearfix">
<div class="col-md-6 column">
<img src="https://scontent-b-iad.xx.fbcdn.net/hphotos-frc3/t1/1426197_10152387296313835_1267403148_n.jpg" height=200 width=200>
</div>
<div class="col-md-6 column">
</div>
</div>
<div class="row clearfix">
<div class="row semester-controls">
<div class="col-lg-2 col-lg-offset-7">
</div>
<div class="col-lg-2">
<a id="create" href="#Create" class="btn btn-block btn-lg btn-primary">Create Facility</a>
</div>
</div>
<div class="col-md-12 column">
<table class="table">
<thead>
<tr>
<th>
Facility
</th>
<th>
Edit
</th>
<th>
Delete
</th>
<th>
Staus
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}
{% extends 'layouts/base.html' %}
{% extends "management/layouts/base.html" %}
{% block content %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>GMU</strong>&#8203;WHATSOPEN</h1>
<p class="lead">A place for managing What's Open</p>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-lg-offset-3">
<div class="well">
{% if form.errors %}
<div class="row">
<div class="col-md-12">
<div class="alert alert-dismissable alert-danger">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Oh snap!</strong> Your username and password were not
found. Please try again.
</div>
</div>
</div>
{% endif %}
<form id="login-form" method="post" class="form-horizontal"
action=""> {% csrf_token %}
<fieldset>
<legend>Log In</legend>
<div class="form-group{%if form.errors%} has-error{%endif%}">
<label class="col-lg-2 control-label" for="username">Username</label>
<div class="col-lg-10">
<input type="username" name="username" id="username"
class="form-control" placeholder="Username" />
</div>
</div>
<div class="form-group{%if form.errors%} has-error{%endif%}">
<label class="col-lg-2 control-label" for="password">Password</label>
<div class="col-lg-10">
<input type="password" name="password" id="password"
class="form-control" placeholder="Password" />
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<input type="submit" class="btn btn-primary" value="Sign In" />
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
{% endblock %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment