# Geographic browsing
url(r'^geo/$', geo_view.list_continents, name="telemeta-geo-continents"),
url(r'^geo/(?P<continent>[a-z_]+)/$', geo_view.list_countries, name="telemeta-geo-countries"),
- url(r'^geo/collections/(?P<continent>[a-z_]+)/(?P<country>[a-z_]+)/$', geo_view.list_country_collections, name="telemeta-geo-country-collections"),
- url(r'^geo/items/(?P<continent>[a-z_]+)/(?P<country>[a-z_]+)/$', geo_view.list_country_items, name="telemeta-geo-country-items"),
+ url(r'^geo/collections/(?P<continent>[a-z_]+)/(?P<country>[a-z_]+)/$', GeoCountryCollectionView.as_view(), name="telemeta-geo-country-collections"),
+ url(r'^geo/items/(?P<continent>[a-z_]+)/(?P<country>[a-z_]+)/$', GeoCountryItemView.as_view() , name="telemeta-geo-country-items"),
url(r'^geo/country_info/(?P<id>[0-9a-z]+)/$', geo_view.country_info, name="telemeta-country-info"),
# Flat pages
return list_detail.object_list(request, objects,
template_name='telemeta/geo_country_items.html', paginate_by=20,
extra_context={'country': country, 'continent': continent})
+
+
+class GeoCountryCollectionView(ListView):
+
+ model = MediaCollection
+ template_name = 'telemeta/geo_country_collections.html'
+ paginate_by = 20
+
+ def get_queryset(self):
+ country = self.kwargs['country']
+ continent = self.kwargs['continent']
+ self.continent = Location.objects.by_flatname(continent)[0]
+ self.country = Location.objects.by_flatname(country)[0]
+ return MediaCollection.objects.enriched().by_location(self.country)
+
+ def get_context_data(self, *args, **kwargs):
+ context = super(GeoCountryCollectionView, self).get_context_data(*args, **kwargs)
+ context['country'] = self.country
+ context['continent'] = self.continent
+ return context
+
+
+
+class GeoCountryItemView(ListView):
+
+ model = MediaItem
+ template_name = 'telemeta/geo_country_collections.html'
+ paginate_by = 20
+
+ def get_queryset(self):
+ country = self.kwargs['country']
+ continent = self.kwargs['continent']
+ self.continent = Location.objects.by_flatname(continent)[0]
+ self.country = Location.objects.by_flatname(country)[0]
+ return MediaItem.objects.enriched().by_location(self.country)
+
+ def get_context_data(self, *args, **kwargs):
+ context = super(GeoCountryItemView, self).get_context_data(*args, **kwargs)
+ context['country'] = self.country
+ context['continent'] = self.continent
+ return context
+
+