diff --git a/umap/sesql_config.py b/umap/sesql_config.py index d9fe6f16..0df8e4da 100644 --- a/umap/sesql_config.py +++ b/umap/sesql_config.py @@ -83,8 +83,10 @@ ADDITIONAL_CLEANUP_FUNCTION = lambda value: saxutils.unescape(value, html_entiti # Query configuration # + # General condition to skip indexing content -SKIP_CONDITION = None +def SKIP_CONDITION(m): + return m.share_status != models.Map.PUBLIC # Default sort order for queries DEFAULT_ORDER = ('-modified_at',) diff --git a/umap/views.py b/umap/views.py index 6d4e0fb3..c90f12a0 100644 --- a/umap/views.py +++ b/umap/views.py @@ -34,11 +34,11 @@ class Home(TemplateView, PaginatorMixin): list_template_name = "leaflet_storage/map_list.html" def get_context_data(self, **kwargs): - qs = Map.objects.filter(center__distance_gt=(DEFAULT_CENTER, D(km=1))) + qs = Map.public.filter(center__distance_gt=(DEFAULT_CENTER, D(km=1))) demo_map = None if hasattr(settings, "UMAP_DEMO_PK"): try: - demo_map = Map.objects.get(pk=settings.UMAP_DEMO_PK) + demo_map = Map.public.get(pk=settings.UMAP_DEMO_PK) except Map.DoesNotExist: pass else: @@ -79,7 +79,8 @@ class UserMaps(DetailView, PaginatorMixin): context_object_name = "current_user" def get_context_data(self, **kwargs): - maps = Map.objects.filter(Q(owner=self.object) | Q(editors=self.object)).distinct().order_by('-modified_at')[:30] + manager = Map.objects if self.request.user == self.object else Map.public + maps = manager.filter(Q(owner=self.object) | Q(editors=self.object)).distinct().order_by('-modified_at')[:30] maps = self.paginate(maps) kwargs.update({ "maps": maps