Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
4349a128
Commit
4349a128
authored
Nov 18, 2014
by
Jason Yeomans
Browse files
Add lots of user stuff... still having issues
parent
83935a43
Changes
9
Hide whitespace changes
Inline
Side-by-side
roomlist/api/migrations/0001_initial.pyc
View file @
4349a128
No preview for this file type
roomlist/api/migrations/0002_auto_20141009_2325.pyc
View file @
4349a128
No preview for this file type
roomlist/api/migrations/__init__.pyc
View file @
4349a128
No preview for this file type
roomlist/roomlist/urls.py
View file @
4349a128
...
@@ -6,6 +6,7 @@ admin.autodiscover()
...
@@ -6,6 +6,7 @@ admin.autodiscover()
urlpatterns
=
patterns
(
''
,
urlpatterns
=
patterns
(
''
,
url
(
r
'^$'
,
views
.
index
,
name
=
'index'
),
url
(
r
'^$'
,
views
.
index
,
name
=
'index'
),
url
(
r
'^login/$'
,
views
.
login
,
name
=
'login'
),
url
(
r
'^login/$'
,
views
.
login
,
name
=
'login'
),
url
(
r
'^logout/$'
,
views
.
logout_view
,
name
=
'logout_view'
),
url
(
r
'^buildings/$'
,
views
.
buildings
,
name
=
'buildings'
),
url
(
r
'^buildings/$'
,
views
.
buildings
,
name
=
'buildings'
),
url
(
r
'^building/(?P<buildingName>[a-zA-Z]+)$'
,
views
.
building
,
name
=
'building'
),
url
(
r
'^building/(?P<buildingName>[a-zA-Z]+)$'
,
views
.
building
,
name
=
'building'
),
)
)
roomlist/roomlist/views.py
View file @
4349a128
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
,
HttpResponseRedirect
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.template
import
RequestContext
,
loader
from
django.template
import
RequestContext
,
loader
from
django.contrib.auth.forms
import
AuthenticationForm
from
django.contrib.auth
import
authenticate
,
logout
from
api.models
import
Building
,
Room
from
api.models
import
Building
,
Room
...
@@ -30,7 +32,33 @@ def building(request, buildingName):
...
@@ -30,7 +32,33 @@ def building(request, buildingName):
return
HttpResponse
(
template
.
render
(
context
))
return
HttpResponse
(
template
.
render
(
context
))
def
login
(
request
):
def
login
(
request
):
template
=
loader
.
get_template
(
'login.html'
)
# if this is a POST request we need to process the form data
context
=
RequestContext
(
request
,
{
if
request
.
method
==
'POST'
:
})
# create a form instance and populate it with data from the request:
return
HttpResponse
(
template
.
render
(
context
))
form
=
AuthenticationForm
(
data
=
request
.
POST
)
# check whether it's valid:
form
.
is_valid
()
form_data
=
form
.
clean
()
user
=
form
.
get_user
()
if
user
is
not
None
:
# the password verified for the user
if
user
.
is_active
:
print
(
"User is valid, active and authenticated"
)
else
:
print
(
"The password is valid, but the account has been disabled!"
)
else
:
# the authentication system was unable to verify the username and password
print
(
"The username and password were incorrect."
)
return
HttpResponseRedirect
(
'/'
)
# if a GET (or any other method) we'll create a blank form
else
:
form
=
AuthenticationForm
()
template
=
loader
.
get_template
(
'login.html'
)
context
=
RequestContext
(
request
,
{
'form'
:
form
,
})
return
HttpResponse
(
template
.
render
(
context
))
def
logout_view
(
request
):
logout
(
request
)
return
HttpResponseRedirect
(
'/'
)
roomlist/static/css/signin.css
View file @
4349a128
body
{
padding-top
:
40px
;
padding-bottom
:
40px
;
background-color
:
#eee
;
}
.form-signin
{
.form-signin
{
max-width
:
330px
;
max-width
:
330px
;
padding
:
15px
;
padding
:
15px
;
...
@@ -20,15 +14,15 @@ body {
...
@@ -20,15 +14,15 @@ body {
position
:
relative
;
position
:
relative
;
height
:
auto
;
height
:
auto
;
-webkit-box-sizing
:
border-box
;
-webkit-box-sizing
:
border-box
;
-moz-box-sizing
:
border-box
;
-moz-box-sizing
:
border-box
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
padding
:
10px
;
padding
:
10px
;
font-size
:
16px
;
font-size
:
16px
;
}
}
.form-signin
.form-control
:focus
{
.form-signin
.form-control
:focus
{
z-index
:
2
;
z-index
:
2
;
}
}
.form-signin
input
[
type
=
"
email
"
]
{
.form-signin
input
[
type
=
"
text
"
]
{
margin-bottom
:
-1px
;
margin-bottom
:
-1px
;
border-bottom-right-radius
:
0
;
border-bottom-right-radius
:
0
;
border-bottom-left-radius
:
0
;
border-bottom-left-radius
:
0
;
...
...
roomlist/templates/layouts/base.html
View file @
4349a128
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
{% load staticfiles %}
{% load staticfiles %}
<link
href=
"/static/css/bootstrap.min.css"
rel=
"stylesheet"
media=
"screen"
>
<link
href=
"/static/css/bootstrap.min.css"
rel=
"stylesheet"
media=
"screen"
>
<link
href=
"/static/css/style.css"
rel=
"stylesheet"
media=
"screen"
>
<link
href=
"/static/css/style.css"
rel=
"stylesheet"
media=
"screen"
>
<script
src=
"/static/js/jquery-1.1
0.2
.min.js"
></script>
<script
src=
"/static/js/jquery-
2.
1.1.min.js"
></script>
<script
src=
"/static/js/bootstrap.min.js"
></script>
<script
src=
"/static/js/bootstrap.min.js"
></script>
<link
rel=
"icon"
href=
"/static/img/favicon.ico"
>
<link
rel=
"icon"
href=
"/static/img/favicon.ico"
>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
...
...
roomlist/templates/layouts/navbar.html
View file @
4349a128
...
@@ -19,13 +19,13 @@
...
@@ -19,13 +19,13 @@
</li>
</li>
</ul>
</ul>
<ul
class=
"nav navbar-nav navbar-right"
>
<ul
class=
"nav navbar-nav navbar-right"
>
{% if use.is_authenticated %}
{% if use
r
.is_authenticated %}
<li><a
href=
"#"
>
{{ user.username }}
</a>
<li><a
href=
"#"
>
{{ user.username }}
</a>
</li>
</li>
<li><a
href=
"
#
"
>
Logout
</a>
<li><a
href=
"
/logout/
"
>
Logout
</a>
</li>
</li>
{% else %}
{% else %}
<li><a
href=
"/login"
>
Login
</a>
<li><a
href=
"/login
/
"
>
Login
</a>
</li>
</li>
{% endif %}
{% endif %}
</ul>
</ul>
...
...
roomlist/templates/login.html
View file @
4349a128
{% extends 'layouts/base.html' %} {% block title %} GMU RoomList
•
Homepage
{% endblock %} {% block content %}
{% extends 'layouts/base.html' %} {% block title %} GMU RoomList
•
Login
{% endblock %} {% block content %}
<link
href=
"/static/css/signin.css"
rel=
"stylesheet"
media=
"screen"
>
<link
href=
"/static/css/signin.css"
rel=
"stylesheet"
media=
"screen"
>
...
@@ -11,12 +11,13 @@
...
@@ -11,12 +11,13 @@
</div>
</div>
</div>
</div>
<form
class=
"form-signin"
role=
"form"
>
<form
class=
"form-signin"
role=
"form"
action=
"/login/"
method=
"post"
>
<h2
class=
"form-signin-heading"
>
Please sign in
</h2>
{% csrf_token %}
<label
for=
"inputEmail"
class=
"sr-only"
>
Username
</label>
<h2
class=
"form-signin-heading"
>
Please sign in
</h2>
{{ form.errors }} {{ form.non_field_errors }} {{ form.username.errors }}
<input
type=
"username"
id=
"inputEmail"
class=
"form-control"
placeholder=
"Email address"
required
autofocus
>
<label
for=
"{{ form.username.id_for_label }}"
class=
"sr-only"
>
NetID
</label>
<label
for=
"inputPassword"
class=
"sr-only"
>
Password
</label>
{{ form.username }} {{ form.password.errors }}
<input
type=
"password"
id=
"inputPassword"
class=
"form-control"
placeholder=
"Password"
required
>
<label
for=
"{{ form.password.id_for_label }}"
class=
"sr-only"
>
Password
</label>
{{ form.password }}
<div
class=
"checkbox"
>
<div
class=
"checkbox"
>
<label>
<label>
<input
type=
"checkbox"
value=
"remember-me"
>
Remember me
<input
type=
"checkbox"
value=
"remember-me"
>
Remember me
...
@@ -25,5 +26,4 @@
...
@@ -25,5 +26,4 @@
<button
class=
"btn btn-lg btn-primary btn-block"
type=
"submit"
>
Sign in
</button>
<button
class=
"btn btn-lg btn-primary btn-block"
type=
"submit"
>
Sign in
</button>
</form>
</form>
{% endblock %}
{% endblock %}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment