Created
October 26, 2009 21:01
-
-
Save sunlightlabs/219037 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.gis.geos import Point | |
from django.contrib.gis.measure import D | |
from django.contrib.humanize.templatetags.humanize import intcomma | |
from layar import POI, LayarView | |
from recovery.models import AwardSite | |
class RecoveryLayarView(LayarView): | |
def get_recoverygov_queryset(self, latitude, longitude, radius, | |
search_query, slider_value, **kwargs): | |
qs = AwardSite.objects.filter(location__distance_lt=(Point(longitude, latitude), | |
D(m=radius))) | |
if slider_value: | |
qs = qs.filter(amount__gte=float(slider_value)) | |
if search_query: | |
qs = qs.filter(name__icontains=search_query) | |
return qs | |
def poi_from_recoverygov_item(self, item): | |
return POI(id=item.id, lat=item.location.y, lon=item.location.x, title=item.name, | |
line2='Amount: $%s' % intcomma(item.amount), line3='Distance: %distance%') | |
recovery_layar = RecoveryLayarView() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment