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
e9ddd189
Commit
e9ddd189
authored
Aug 02, 2016
by
Daniel W Bond
Browse files
added comments to point out where the building-floors and floor-rooms issue exists and why
parent
a965fc13
Changes
1
Hide whitespace changes
Inline
Side-by-side
roomlist/api/serializers.py
View file @
e9ddd189
...
...
@@ -11,7 +11,9 @@ from accounts.models import Major
class
BuildingSerializer
(
serializers
.
ModelSerializer
):
floors
=
serializers
.
SerializerMethodField
(
'get_building_floors'
)
# using django's built-in serialization makes for many escape characters
# and lots of unnecessary fields... there has to be a way to do this with DRF
#floors = serializers.SerializerMethodField('get_building_floors')
def
get_building_floors
(
self
,
building
):
floors
=
serialize
(
'json'
,
Floor
.
objects
.
filter
(
building
=
building
),
...
...
@@ -26,6 +28,7 @@ class BuildingSerializer(serializers.ModelSerializer):
class
FloorSerializer
(
serializers
.
ModelSerializer
):
building
=
serializers
.
SerializerMethodField
(
'get_building_name'
)
#rooms = serializers.SerializerMethodField('get_floor_room')
def
get_building_name
(
self
,
floor
):
return
floor
.
building
.
name
...
...
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