def test_canonical_map_for_tags(self):
        from maps.views import MapForTag

        #####################################################
        # Map of tagged pages on custom domain
        #####################################################

        request = self.factory.get('/map/tags/park')
        request.user = self.user
        request.META['HTTP_HOST'] = self.sf.regionsettings.domain

        with self.mock_hosts_middleware(request):
            view = MapForTag.as_view()
            response = view(request, tag='park')

            canonical_url = 'https://%s/sf/map/tags/park' % settings.MAIN_HOSTNAME
            response.render()
            self.assertTrue(self.has_canonical_url(canonical_url, request, response))

        #####################################################
        # Main map on normal region
        #####################################################

        request = self.factory.get('/sf/map/tags/park')
        request.user = self.user
        request.META['HTTP_HOST'] = settings.MAIN_HOSTNAME

        with self.mock_hosts_middleware(request):
            view = MapForTag.as_view()
            response = view(request, tag='park', region='sf')

            canonical_url = ''
            response.render()
            # No canonical URL emitted
            self.assertFalse(self.has_canonical_url(canonical_url, request, response))
示例#2
0
 def get_map_objects(self):
     if not self.tag:
         return None
     # We re-use the MapForTag view's logic here to embed a mini-map on the
     # tags list page
     map_view = MapForTag()
     map_view.kwargs = dict(tag=self.tag.slug)
     map_view.object_list = map_view.get_queryset()
     return map_view.get_map_objects()
 def get_map_objects(self):
     if not self.tag:
         return None
     # We re-use the MapForTag view's logic here to embed a mini-map on the
     # tags list page
     from maps.views import MapForTag
     map_view = MapForTag()
     map_view.request = self.request
     map_view.kwargs = dict(tag=self.tag.slug, region=self.get_region().slug)
     map_view.object_list = map_view.get_queryset()
     return map_view.get_map_objects()
示例#4
0
 def get_map_objects(self):
     if not self.tag:
         return None
     # We re-use the MapForTag view's logic here to embed a mini-map on the
     # tags list page
     map_view = MapForTag()
     map_view.kwargs = dict(tag=self.tag.slug)
     map_view.object_list = map_view.get_queryset()
     return map_view.get_map_objects()