mirror of
https://github.com/umap-project/umap.git
synced 2025-05-04 13:41:49 +02:00
django-leaflet-storage replaced PublicManager by MapManager; adhere changes
This commit is contained in:
parent
608d74853b
commit
43e0f721ae
1 changed files with 6 additions and 6 deletions
|
@ -53,7 +53,7 @@ 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.public
|
qs = Map.objects.visible(self.request)
|
||||||
if (settings.UMAP_EXCLUDE_DEFAULT_MAPS and
|
if (settings.UMAP_EXCLUDE_DEFAULT_MAPS and
|
||||||
'spatialite' not in settings.DATABASES['default']['ENGINE']):
|
'spatialite' not in settings.DATABASES['default']['ENGINE']):
|
||||||
# Unsupported query type for sqlite.
|
# Unsupported query type for sqlite.
|
||||||
|
@ -61,7 +61,7 @@ class Home(TemplateView, PaginatorMixin):
|
||||||
demo_map = None
|
demo_map = None
|
||||||
if hasattr(settings, "UMAP_DEMO_PK"):
|
if hasattr(settings, "UMAP_DEMO_PK"):
|
||||||
try:
|
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:
|
except Map.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -69,7 +69,7 @@ class Home(TemplateView, PaginatorMixin):
|
||||||
showcase_map = None
|
showcase_map = None
|
||||||
if hasattr(settings, "UMAP_SHOWCASE_PK"):
|
if hasattr(settings, "UMAP_SHOWCASE_PK"):
|
||||||
try:
|
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:
|
except Map.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -112,7 +112,7 @@ class UserMaps(DetailView, PaginatorMixin):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
owner = self.request.user == self.object
|
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 = manager.filter(Q(owner=self.object) | Q(editors=self.object))
|
||||||
maps = maps.distinct().order_by('-modified_at')[:50]
|
maps = maps.distinct().order_by('-modified_at')[:50]
|
||||||
if owner:
|
if owner:
|
||||||
|
@ -148,7 +148,7 @@ class Search(TemplateView, PaginatorMixin):
|
||||||
where = "to_tsvector(name) @@ plainto_tsquery(%s)"
|
where = "to_tsvector(name) @@ plainto_tsquery(%s)"
|
||||||
if getattr(settings, 'UMAP_USE_UNACCENT', False):
|
if getattr(settings, 'UMAP_USE_UNACCENT', False):
|
||||||
where = "to_tsvector(unaccent(name)) @@ to_tsquery(unaccent(%s))" # noqa
|
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.extra(where=[where], params=[q])
|
||||||
results = results.order_by('-modified_at')
|
results = results.order_by('-modified_at')
|
||||||
print(results.query)
|
print(results.query)
|
||||||
|
@ -174,7 +174,7 @@ search = Search.as_view()
|
||||||
class MapsShowCase(View):
|
class MapsShowCase(View):
|
||||||
|
|
||||||
def get(self, *args, **kwargs):
|
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]
|
maps = maps.order_by('-modified_at')[:2500]
|
||||||
|
|
||||||
def make(m):
|
def make(m):
|
||||||
|
|
Loading…
Reference in a new issue