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
B
bookshare
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
30
Issues
30
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
SRCT
bookshare
Commits
f2b8414a
Commit
f2b8414a
authored
Jan 17, 2017
by
Daniel W Bond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added number of bids and number of flags to listing serialization
parent
f0af2118
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
bookshare/api/serializers.py
bookshare/api/serializers.py
+15
-7
No files found.
bookshare/api/serializers.py
View file @
f2b8414a
...
...
@@ -13,22 +13,30 @@ class ListingSerializer(serializers.HyperlinkedModelSerializer):
lookup_field
=
'slug'
)
active
=
serializers
.
SerializerMethodField
(
'active'
)
active
=
serializers
.
SerializerMethodField
(
'final_price'
)
active
=
serializers
.
SerializerMethodField
(
'old'
)
active
=
serializers
.
SerializerMethodField
()
final_price
=
serializers
.
SerializerMethodField
()
old
=
serializers
.
SerializerMethodField
()
num_bids
=
serializers
.
SerializerMethodField
()
num_flags
=
serializers
.
SerializerMethodField
()
def
active
(
self
,
listing
):
def
get_
active
(
self
,
listing
):
return
listing
.
active
()
def
final_price
(
self
,
listing
):
def
get_
final_price
(
self
,
listing
):
return
listing
.
final_price
()
def
old
(
self
,
listing
):
def
get_
old
(
self
,
listing
):
return
listing
.
old
()
def
get_num_bids
(
self
,
listing
):
return
listing
.
bid_set
.
all
().
count
()
def
get_num_flags
(
self
,
listing
):
return
listing
.
flag_set
.
all
().
count
()
class
Meta
:
model
=
Listing
fields
=
(
'url'
,
'title'
,
'author'
,
'isbn'
,
'year'
,
'edition'
,
'condition'
,
'access_code'
,
'course_abbr'
,
'description'
,
'price'
,
'photo'
,
'active'
,
'old'
,
'
num_bids'
,
'num_flags'
,
'
active'
,
'old'
,
'exchanged'
,
'cancelled'
,
'date_closed'
,
'final_price'
)
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