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
d4e4ec59
Commit
d4e4ec59
authored
Feb 18, 2015
by
Daniel W Bond
Browse files
beginning of student filtering by permission
parent
b25fa7c8
Changes
1
Hide whitespace changes
Inline
Side-by-side
roomlist/housing/views.py
View file @
d4e4ec59
...
...
@@ -36,14 +36,58 @@ class DetailFloor(LoginRequiredMixin, DetailView):
context_object_name
=
'floor'
template_name
=
detail_floor
.
html
def
onFloor
():
# if self.request.user is on the floor
return
False
def
inBuilding
():
inBuilding
=
False
# if self.request.user is in the building
return
False
rooms
=
Room
.
objects
.
filter
(
floor
=
self
.
get_object
()).
order_by
(
'-number'
)
floor_students
=
[]
for
room
in
rooms
:
if
onFloor
():
floor_students
.
extend
(
Student
.
objects
.
filter
(
room
=
room
).
floor_building_students
())
elif
inBuilding
():
floor_students
.
extend
(
Student
.
objects
.
filter
(
room
=
room
).
building_students
())
else
:
floor_students
.
extend
(
Student
.
objects
.
filter
(
room
=
room
).
students
())
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
DetailFloor
,
self
):
# perhaps change to get the students, and then list by rooms?
context
[
'rooms'
]
=
Room
.
objects
.
filter
(
floor
=
self
.
get_object
()).
order_by
(
'-number'
)
context
[
'students'
]
=
floor_students
return
context
login_url
=
'/'
# deleted 'DetailRoom' view-- inhabitants will be listed on the floor page
class
DetailRoom
(
LoginRequiredMixin
,
DetailView
):
model
=
Room
context_object_name
=
'room'
template_name
=
'detailBuilding.html'
def
onFloor
():
# if self.request.user is on the floor
return
False
def
inBuilding
():
inBuilding
=
False
# if self.request.user is in the building
return
False
if
onFloor
():
students
=
Student
.
objects
.
filter
(
room
=
self
.
get_object
()).
floor_building_students
()
elif
inBuilding
():
students
=
Student
.
objects
.
filter
(
room
=
self
.
get_object
()).
building_students
()
else
:
students
=
Student
.
objects
.
filter
(
room
=
self
.
get_object
()).
students
()
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
DetailRoom
,
self
):
context
[
'students'
]
=
students
return
context
login_url
=
'/'
# deleted 'UpdateRoom' view-- that will be handled on the user's page
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