Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaldera committed Aug 31, 2014
2 parents ddaf569 + 50bac89 commit 55aaafc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
13 changes: 10 additions & 3 deletions realestate/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class PropertySerializer(serializers.Serializer):
title = serializers.CharField(required=False, max_length=100)
description = serializers.CharField(widget=widgets.Textarea, max_length=1000)
absolute_url = serializers.URLField(required=False)
price = serializers.FloatField(required=False)
price = serializers.SerializerMethodField('get_price')
currency = serializers.SerializerMethodField('get_currency')
address = serializers.CharField(required=False, max_length=255)
type = serializers.CharField(required=False, max_length=30)
offer = serializers.CharField(required=False, max_length=10)
Expand All @@ -21,5 +22,11 @@ class PropertySerializer(serializers.Serializer):
last_modified = serializers.CharField(required=False, max_length=100)
images = serializers.SerializerMethodField('get_images')

def get_images(self, obj):
return obj.image_list
def get_images(self, listing):
return listing.image_list

def get_price(self, listing):
return listing.price.amount

def get_currency(self, listing):
return listing.price.currency
2 changes: 1 addition & 1 deletion realestate/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PropiedadViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = PropertySerializer

def get_queryset(self):
queryset = Listing.objects.all()
queryset = Listing.objects.active()

last_modified = self.request.QUERY_PARAMS.get('modified_from')
if last_modified is not None:
Expand Down
1 change: 1 addition & 0 deletions testproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
],
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
'realestate.api.authentication.ApiKeyAuthentication', # this should be the last one cause it never returns none
)
Expand Down

0 comments on commit 55aaafc

Please sign in to comment.