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
058cf5bc
Commit
058cf5bc
authored
Nov 22, 2014
by
Daniel W Bond
Browse files
fixed merge conflicts
parents
4e45f236
a0398989
Changes
1
Hide whitespace changes
Inline
Side-by-side
roomlist/housing/views.py
View file @
058cf5bc
...
...
@@ -40,58 +40,3 @@ class DetailStudent(LoginRequiredMixin, DetailStudent):
# update a room
# update a building
def
index
(
request
):
template
=
loader
.
get_template
(
'index.html'
)
context
=
RequestContext
(
request
,
{
})
return
HttpResponse
(
template
.
render
(
context
))
def
buildings
(
request
):
building_list
=
Building
.
objects
.
order_by
(
'name'
)[:
5
]
template
=
loader
.
get_template
(
'buildings.html'
)
context
=
RequestContext
(
request
,
{
'building_list'
:
building_list
,
})
return
HttpResponse
(
template
.
render
(
context
))
def
building
(
request
,
buildingName
):
building
=
Building
.
objects
.
get
(
name__iexact
=
''
+
buildingName
)
room_list
=
Room
.
objects
.
filter
(
building__name
=
''
+
building
.
name
).
order_by
(
'number'
)
template
=
loader
.
get_template
(
'building.html'
)
context
=
RequestContext
(
request
,
{
'building'
:
building
,
'room_list'
:
room_list
,
})
return
HttpResponse
(
template
.
render
(
context
))
def
login
(
request
):
# if this is a POST request we need to process the form data
if
request
.
method
==
'POST'
:
# create a form instance and populate it with data from the request:
# check whether it's valid:
username
=
request
.
POST
[
'username'
]
password
=
request
.
POST
[
'password'
]
user
=
authenticate
(
username
=
username
,
password
=
password
)
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
(
'/'
)
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