diff options
Diffstat (limited to 'chimere/rss/feeds.py')
-rw-r--r-- | chimere/rss/feeds.py | 94 |
1 files changed, 53 insertions, 41 deletions
diff --git a/chimere/rss/feeds.py b/chimere/rss/feeds.py index c24281c..af7956b 100644 --- a/chimere/rss/feeds.py +++ b/chimere/rss/feeds.py @@ -32,7 +32,6 @@ class LatestPOIsByCategory(Feed): ''' Last Points of interests by category in Feeds ''' - title_template = "rss_title.html" description_template = "rss_descr.html" # Get extra url, after rss/category/ -> bits[0]=id of category @@ -42,7 +41,7 @@ class LatestPOIsByCategory(Feed): return Category.objects.get(id__exact=bits[0]) # Define the title of the feed, here The name of the category def title(self, obj): - return "Chimere - %s" % obj.name + return u"%s - %s" % (settings.PROJECT_NAME, obj.name) # Define the link of the feed. Feeds agregators update at this link def link(self, obj): if not obj: @@ -57,15 +56,19 @@ class LatestPOIsByCategory(Feed): # Get thirst the attribute point of the marker # Then we had to transform this to the good system metric. From srid=4326 to srid=900913 coord = item.point - coord.transform(settings.EPSG_PROJECTION) - return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + #coord.transform(settings.EPSG_PROJECTION) + lnk = settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + \ +str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + return lnk # Date of the Marker when it has been available def item_pubdate(self,item): - return item.avail_date + return item.available_date # Requests to marker where its category match the category is requested AND its status is available # This returns a list of the 15 last markers/POIs ordering by date def items(self, obj): - return Marker.objects.filter(subcategory__category__id__exact=obj.id, status__exact='A').order_by('-avail_date')[:15] + return Marker.objects.filter(status__exact='A', + categories__subcategory__category__id__exact=obj.id).order_by( + '-available_date')[:15] class LatestPOIsBySubCategory(Feed): ''' @@ -73,14 +76,14 @@ class LatestPOIsBySubCategory(Feed): ''' title_template = "rss_title.html" description_template = "rss_descr.html" - def get_object(self, bits): if len(bits) != 1: raise ObjectDoesNotExist return SubCategory.objects.get(id__exact=bits[0]) def title(self, obj): - return obj.category.name + "Chimere - %s" % obj.name + return obj.category.name + u"%s - %s" % (settings.PROJECT_NAME, + obj.name) def link(self, obj): if not obj: @@ -93,14 +96,16 @@ class LatestPOIsBySubCategory(Feed): def item_link(self, item): # Renvoyer le permalink du POI : coord = item.point - coord.transform(settings.EPSG_PROJECTION) - return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + #coord.transform(settings.EPSG_PROJECTION) + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + \ +str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' def item_pubdate(self,item): - return item.avail_date + return item.available_date def items(self, obj): - return Marker.objects.filter(subcategory__id__exact=obj.id, status__exact='A').order_by('-avail_date')[:15] + return Marker.objects.filter(categories_subcategory__id__exact=obj.id, + status__exact='A').order_by('-available_date')[:15] class LatestPOIs(Feed): ''' @@ -110,7 +115,7 @@ class LatestPOIs(Feed): description_template = "rss_descr.html" def title(self): - return "Chimere - Last POIs" + return u"%s - Last POIs" % settings.PROJECT_NAME def link(self): return settings.BASE_URL + 'rss/categories/' @@ -121,14 +126,16 @@ class LatestPOIs(Feed): def item_link(self, item): # Renvoyer le permalink du POI : coord = item.point - coord.transform(settings.EPSG_PROJECTION) - return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + #coord.transform(settings.EPSG_PROJECTION) + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + \ +str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' def item_pubdate(self,item): - return item.avail_date + return item.available_date def items(self): - return Marker.objects.filter(status__exact='A').order_by('-avail_date')[:15] + return Marker.objects.filter(status__exact='A' + ).order_by('-available_date')[:15] class LatestPOIsByZone(Feed): @@ -146,18 +153,19 @@ class LatestPOIsByZone(Feed): def get_object(self, bits): if len(bits) != 1: raise ObjectDoesNotExist - # Get the extra url. Parameters are the coordinates of the zone (the upper left and lower right points) + # Get the extra url. Parameters are the coordinates of the zone (the + # upper left and lower right points) # Then define the upper right and lower left points coordinates = str(bits[0]).split(',') upper_left_lat = float(coordinates[0]) upper_left_lon = float(coordinates[1]) lower_right_lat = float(coordinates[2]) lower_right_lon = float(coordinates[3]) - + """ upper_right_lat = upper_left_lat upper_right_lon = lower_right_lon lower_left_lat = lower_right_lat - lower_left_lon = upper_left_lon + lower_left_lon = upper_left_lon""" # Define a Polygon with the 4 points of the zone. # Cordinates are define with a srid=900913, use by google, yahoo but no OpenStreeMap areaBox = Polygon(((upper_left_lon, upper_left_lat), @@ -167,36 +175,42 @@ class LatestPOIsByZone(Feed): (upper_left_lon, upper_left_lat)), srid=settings.EPSG_PROJECTION) # OSM uses the standard srid=4326, wich uses the real pairs latitude/longitude in degrees. - areaBox.transform(settings.EPSG_DISPLAY_PROJECTION) + #areaBox.transform(settings.EPSG_DISPLAY_PROJECTION) return areaBox - + def title(self, obj): - return "Chimere - Last POIs by area" + return u"%s - Last POIs by area" % settings.PROJECT_NAME # Define the link of the feed. It's the same url as we get in the method get_object def link(self, obj): if not obj: raise FeedDoesNotExist - return settings.BASE_URL + 'rss/area/' + str(self.upper_left_lat) + ',' + str(self.upper_left_lon) + ',' + str(self.lower_right_lat) + ',' + str(self.lower_right_lon) + return settings.BASE_URL + 'rss/area/' \ + + str(self.upper_left_lat) + ',' + str(self.upper_left_lon) + \ + ',' + str(self.lower_right_lat) + ',' + str(self.lower_right_lon) def description(self, obj): return "" - + # Link of the item/POI. Here the link is the permalink of the marker/POI def item_link(self, item): # Return the permalink of the POI : # Get thirst the attribute point of the marker # Then we had to transform this to the good system metric. From srid=4326 to srid=900913 coord = item.point - coord.transform(settings.EPSG_PROJECTION) - return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + #coord.transform(settings.EPSG_PROJECTION) + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + \ +str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + # Return the date of the Marker def item_pubdate(self,item): - return item.avail_date + return item.available_date + # Request to return Markers WHERE there points are containes in the zone which is requested. # This returns a list of the 15 last markers/POIs ordering by date def items(self, obj): - return Marker.objects.filter(point__contained=obj, status__exact='A').order_by('-avail_date')[:15] + return Marker.objects.filter(point__contained=obj, status__exact='A' + ).order_by('-available_date')[:15] class LatestPOIsByZoneID(Feed): ''' @@ -204,15 +218,14 @@ class LatestPOIsByZoneID(Feed): ''' title_template = "rss_title.html" description_template = "rss_descr.html" - + def get_object(self, bits): if len(bits) != 1: raise ObjectDoesNotExist - return Area.objects.get(id__exact=bits[0]) def title(self, obj): - return "Chimere - Last POIs of %s" % obj.name + return u"%s - Last POIs of %s" % (settings.PROJECT_NAME, obj.name) def link(self, obj): if not obj: @@ -225,29 +238,28 @@ class LatestPOIsByZoneID(Feed): def item_link(self, item): coord = item.point coord.transform(settings.EPSG_PROJECTION) - return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' + return settings.BASE_URL + '?zoom=16&lat=' + str(coord.y) + '&lon=' + \ +str(coord.x) + '&layers=BTT&checked_categories=1&display_submited=false' def item_pubdate(self,item): - return item.avail_date + return item.available_date def items(self, obj): upper_left_lat = float(obj.upper_left_corner.x) upper_left_lon = float(obj.upper_left_corner.y) lower_right_lat = float(obj.lower_right_corner.x) lower_right_lon = float(obj.lower_right_corner.y) - + ''' upper_right_lat = upper_left_lat upper_right_lon = lower_right_lon lower_left_lat = lower_right_lat lower_left_lon = upper_left_lon - - areaBox = Polygon(((upper_left_lon, upper_left_lat), + ''' + areaBox = Polygon(((upper_left_lon, upper_left_lat), (upper_right_lon, upper_right_lat), (lower_right_lon, lower_right_lat), (lower_left_lon, lower_left_lat), (upper_left_lon, upper_left_lat)), srid=settings.EPSG_PROJECTION) - - areaBox.transform(settings.EPSG_DISPLAY_PROJECTION) - - return Marker.objects.filter(point__contained=areaBox) + #areaBox.transform(settings.EPSG_DISPLAY_PROJECTION) + return Marker.objects.filter(point__contained=areaBox) |