From ca36ecfc10a44f7554c0c891a87f4531bf66a3fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sat, 2 Jan 2016 12:59:34 +0100 Subject: [PATCH 1/3] Configuration: default map location for new maps --- umap/settings/local.py.sample | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/umap/settings/local.py.sample b/umap/settings/local.py.sample index 0bc52bdf..4f32b40e 100644 --- a/umap/settings/local.py.sample +++ b/umap/settings/local.py.sample @@ -90,3 +90,8 @@ MEDIA_ROOT = '/home/umap/.virtualenvs/umap/var/uploads' # MapQuest API key MAPQUEST_KEY = '' + +# Default map location for new maps +LEAFLET_LONGITUDE = 2 +LEAFLET_LATITUDE = 51 +LEAFLET_ZOOM = 6 From d783366d9da3efd83a550e62962f9cd14b61630d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sat, 2 Jan 2016 13:21:24 +0100 Subject: [PATCH 2/3] Configuration: new setting UMAP_EXCLUDE_DEFAULT_MAPS - This setting will exclude default maps (maps where the default center has not been updated) - until now, the default was to exclude default maps - new default: not exclude --- umap/settings/base.py | 1 + umap/settings/local.py.sample | 5 +++++ umap/views.py | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/umap/settings/base.py b/umap/settings/base.py index 2bc90cc2..3bb20b7c 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -147,6 +147,7 @@ LEAFLET_STORAGE_EXTRA_URLS = { } SITE_URL = "http://umap.org" UMAP_DEMO_SITE = False +UMAP_EXCLUDE_DEFAULT_MAPS = False MAP_SHORT_URL_NAME = "umap_short_url" UMAP_USE_UNACCENT = False UMAP_FEEDBACK_LINK = "http://wiki.openstreetmap.org/wiki/UMap#Feedback_and_help" # noqa diff --git a/umap/settings/local.py.sample b/umap/settings/local.py.sample index 4f32b40e..fce8e8d7 100644 --- a/umap/settings/local.py.sample +++ b/umap/settings/local.py.sample @@ -64,6 +64,11 @@ SOCIAL_AUTH_BACKEND_ERROR_URL = "/" # UMAP_SHOWCASE_PK = 1156 LEAFLET_STORAGE_ALLOW_ANONYMOUS = True UMAP_DEMO_SITE = True + +# This setting will exclude empty maps (in fact, it will exclude all maps where +# the default center has not been updated) +UMAP_EXCLUDE_DEFAULT_MAPS = False + SITE_URL = "http://localhost:8019" SHORT_SITE_URL = "http://s.hort" diff --git a/umap/views.py b/umap/views.py index 6aacf319..93fe7e08 100644 --- a/umap/views.py +++ b/umap/views.py @@ -54,8 +54,9 @@ class Home(TemplateView, PaginatorMixin): def get_context_data(self, **kwargs): qs = Map.public - if 'spatialite' not in settings.DATABASES['default']['ENGINE']: - # Unsupported query type for sqlite. + 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"): From e8c7b41e6da34d655c98cfc18a9024dd23b3ee39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sat, 2 Jan 2016 13:42:57 +0100 Subject: [PATCH 3/3] Configuration: settings to configure count of showcased maps - UMAP_MAPS_PER_PAGE - UMAP_MAPS_PER_PAGE_OWNER --- umap/settings/base.py | 2 ++ umap/settings/local.py.sample | 5 +++++ umap/views.py | 7 +++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/umap/settings/base.py b/umap/settings/base.py index 3bb20b7c..6f08f060 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -148,6 +148,8 @@ LEAFLET_STORAGE_EXTRA_URLS = { SITE_URL = "http://umap.org" UMAP_DEMO_SITE = False UMAP_EXCLUDE_DEFAULT_MAPS = False +UMAP_MAPS_PER_PAGE = 5 +UMAP_MAPS_PER_PAGE_OWNER = 10 MAP_SHORT_URL_NAME = "umap_short_url" UMAP_USE_UNACCENT = False UMAP_FEEDBACK_LINK = "http://wiki.openstreetmap.org/wiki/UMap#Feedback_and_help" # noqa diff --git a/umap/settings/local.py.sample b/umap/settings/local.py.sample index fce8e8d7..f65e4993 100644 --- a/umap/settings/local.py.sample +++ b/umap/settings/local.py.sample @@ -69,6 +69,11 @@ UMAP_DEMO_SITE = True # the default center has not been updated) UMAP_EXCLUDE_DEFAULT_MAPS = False +# How many maps should be showcased on the main page resp. on the user page +UMAP_MAPS_PER_PAGE = 5 +# How many maps should be showcased on the user page, if owner +UMAP_MAPS_PER_PAGE_OWNER = 10 + SITE_URL = "http://localhost:8019" SHORT_SITE_URL = "http://s.hort" diff --git a/umap/views.py b/umap/views.py index 93fe7e08..397874fc 100644 --- a/umap/views.py +++ b/umap/views.py @@ -75,7 +75,7 @@ class Home(TemplateView, PaginatorMixin): else: qs = qs.exclude(id=showcase_map.pk) maps = qs.order_by('-modified_at')[:50] - maps = self.paginate(maps) + maps = self.paginate(maps, settings.UMAP_MAPS_PER_PAGE) return { "maps": maps, @@ -115,7 +115,10 @@ class UserMaps(DetailView, PaginatorMixin): manager = Map.objects if owner else Map.public maps = manager.filter(Q(owner=self.object) | Q(editors=self.object)) maps = maps.distinct().order_by('-modified_at')[:50] - per_page = 10 if owner else self.per_page + if owner: + per_page = settings.UMAP_MAPS_PER_PAGE_OWNER + else: + per_page = settings.UMAP_MAPS_PER_PAGE maps = self.paginate(maps, per_page) kwargs.update({ "maps": maps