Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
roomlist
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
roomlist
Commits
eb6cc946
Commit
eb6cc946
authored
Feb 21, 2015
by
Daniel W Bond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
casting problems
parent
918ed782
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
roomlist/accounts/models.py
roomlist/accounts/models.py
+16
-14
No files found.
roomlist/accounts/models.py
View file @
eb6cc946
...
...
@@ -18,42 +18,44 @@ class Major(TimeStampedModel):
class
StudentQuerySet
(
models
.
query
.
QuerySet
):
def
floor
(
self
):
return
self
.
filter
(
privacy
=
FLOOR
)
return
self
.
filter
(
privacy
=
'floor'
)
def
building
(
self
):
return
self
.
filter
(
privacy
=
BUILDING
)
return
self
.
filter
(
privacy
=
'building'
)
def
students
(
self
):
return
self
.
filter
(
privacy
=
STUDENTS
)
return
self
.
filter
(
privacy
=
'students'
)
class
StudentManager
(
models
.
Manager
):
def
get_queryset
(
self
):
return
StudentQuerySet
(
self
.
model
,
using
=
self
.
_db
)
def
floor
(
self
):
return
self
.
get_query
_
set
().
floor
()
return
self
.
get_queryset
().
floor
()
def
building
(
self
):
return
self
.
get_query
_
set
().
building
()
return
self
.
get_queryset
().
building
()
def
students
(
self
):
return
self
.
get_query
_
set
().
students
()
return
self
.
get_queryset
().
students
()
# when a student is not on a floor, but in a building
def
building_students
(
self
):
building
=
self
.
get_query
_
set
().
building
()
students
=
self
.
get_query
_
set
().
students
()
return
building
+
list
(
set
(
students
)
-
set
(
building
))
building
=
self
.
get_queryset
().
building
()
students
=
self
.
get_queryset
().
students
()
return
list
(
building
)
+
list
(
set
(
students
)
-
set
(
building
))
# when a student is on a floor
def
floor_building_students
(
self
):
floor
=
self
.
get_query
_
set
().
floor
()
building
=
self
.
get_query
_
set
().
building
()
students
=
self
.
get_query
_
set
().
students
()
floor
=
self
.
get_queryset
().
floor
()
building
=
self
.
get_queryset
().
building
()
students
=
self
.
get_queryset
().
students
()
building_students
=
building_students
()
# using the function above results in UnboundLocalError excpetion
#building_students = building_students()
building_students
=
list
(
building
)
+
list
(
set
(
students
)
-
set
(
building
))
return
floor
+
list
(
set
(
building_students
)
-
set
(
floor
))
return
list
(
floor
)
+
list
(
set
(
building_students
)
-
set
(
floor
))
class
Student
(
TimeStampedModel
):
user
=
models
.
OneToOneField
(
User
)
...
...
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