Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new django-leaflet-storage:MapManager #274

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions umap/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ class Home(TemplateView, PaginatorMixin):
list_template_name = "leaflet_storage/map_list.html"

def get_context_data(self, **kwargs):
qs = Map.public
qs = Map.objects.visible(self.request)
if (settings.UMAP_EXCLUDE_DEFAULT_MAPS and
'spatialite' not in settings.DATABASES['default']['ENGINE']):
# Unsupported query type for sqlite.
qs = qs.filter(center__distance_gt=(DEFAULT_CENTER, D(km=1)))
demo_map = None
if hasattr(settings, "UMAP_DEMO_PK"):
try:
demo_map = Map.public.get(pk=settings.UMAP_DEMO_PK)
demo_map = Map.objects.visible(self.request).get(pk=settings.UMAP_DEMO_PK)
except Map.DoesNotExist:
pass
else:
qs = qs.exclude(id=demo_map.pk)
showcase_map = None
if hasattr(settings, "UMAP_SHOWCASE_PK"):
try:
showcase_map = Map.public.get(pk=settings.UMAP_SHOWCASE_PK)
showcase_map = Map.objects.visible(self.request).get(pk=settings.UMAP_SHOWCASE_PK)
except Map.DoesNotExist:
pass
else:
Expand Down Expand Up @@ -112,7 +112,7 @@ class UserMaps(DetailView, PaginatorMixin):

def get_context_data(self, **kwargs):
owner = self.request.user == self.object
manager = Map.objects if owner else Map.public
manager = Map.objects if owner else Map.objects.visible(self.request)
maps = manager.filter(Q(owner=self.object) | Q(editors=self.object))
maps = maps.distinct().order_by('-modified_at')[:50]
if owner:
Expand Down Expand Up @@ -148,7 +148,7 @@ def get_context_data(self, **kwargs):
where = "to_tsvector(name) @@ plainto_tsquery(%s)"
if getattr(settings, 'UMAP_USE_UNACCENT', False):
where = "to_tsvector(unaccent(name)) @@ to_tsquery(unaccent(%s))" # noqa
results = Map.objects.filter(share_status=Map.PUBLIC)
results = Map.objects.visible(self.request)
results = results.extra(where=[where], params=[q])
results = results.order_by('-modified_at')
print(results.query)
Expand All @@ -174,7 +174,7 @@ def get_template_names(self):
class MapsShowCase(View):

def get(self, *args, **kwargs):
maps = Map.public.filter(center__distance_gt=(DEFAULT_CENTER, D(km=1)))
maps = Map.objects.visible(self.request).filter(center__distance_gt=(DEFAULT_CENTER, D(km=1)))
maps = maps.order_by('-modified_at')[:2500]

def make(m):
Expand Down