Show only public map on home, search and user pages

This commit is contained in:
Yohan Boniface 2014-01-09 23:49:53 +01:00
parent c8798abb4e
commit 7dacd863c8
2 changed files with 7 additions and 4 deletions

View file

@ -83,8 +83,10 @@ ADDITIONAL_CLEANUP_FUNCTION = lambda value: saxutils.unescape(value, html_entiti
# Query configuration # Query configuration
# #
# General condition to skip indexing content # 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 sort order for queries
DEFAULT_ORDER = ('-modified_at',) DEFAULT_ORDER = ('-modified_at',)

View file

@ -34,11 +34,11 @@ class Home(TemplateView, PaginatorMixin):
list_template_name = "leaflet_storage/map_list.html" list_template_name = "leaflet_storage/map_list.html"
def get_context_data(self, **kwargs): 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 demo_map = None
if hasattr(settings, "UMAP_DEMO_PK"): if hasattr(settings, "UMAP_DEMO_PK"):
try: try:
demo_map = Map.objects.get(pk=settings.UMAP_DEMO_PK) demo_map = Map.public.get(pk=settings.UMAP_DEMO_PK)
except Map.DoesNotExist: except Map.DoesNotExist:
pass pass
else: else:
@ -79,7 +79,8 @@ class UserMaps(DetailView, PaginatorMixin):
context_object_name = "current_user" context_object_name = "current_user"
def get_context_data(self, **kwargs): 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) maps = self.paginate(maps)
kwargs.update({ kwargs.update({
"maps": maps "maps": maps