Commit f2b8414a authored by Daniel W Bond's avatar Daniel W Bond

added number of bids and number of flags to listing serialization

parent f0af2118
......@@ -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')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment