Configuration: settings to configure count of showcased maps

- UMAP_MAPS_PER_PAGE
- UMAP_MAPS_PER_PAGE_OWNER
This commit is contained in:
Stephan Bösch-Plepelits 2016-01-02 13:42:57 +01:00
parent d783366d9d
commit e8c7b41e6d
3 changed files with 12 additions and 2 deletions

View file

@ -148,6 +148,8 @@ LEAFLET_STORAGE_EXTRA_URLS = {
SITE_URL = "http://umap.org" SITE_URL = "http://umap.org"
UMAP_DEMO_SITE = False UMAP_DEMO_SITE = False
UMAP_EXCLUDE_DEFAULT_MAPS = False UMAP_EXCLUDE_DEFAULT_MAPS = False
UMAP_MAPS_PER_PAGE = 5
UMAP_MAPS_PER_PAGE_OWNER = 10
MAP_SHORT_URL_NAME = "umap_short_url" MAP_SHORT_URL_NAME = "umap_short_url"
UMAP_USE_UNACCENT = False UMAP_USE_UNACCENT = False
UMAP_FEEDBACK_LINK = "http://wiki.openstreetmap.org/wiki/UMap#Feedback_and_help" # noqa UMAP_FEEDBACK_LINK = "http://wiki.openstreetmap.org/wiki/UMap#Feedback_and_help" # noqa

View file

@ -69,6 +69,11 @@ UMAP_DEMO_SITE = True
# the default center has not been updated) # the default center has not been updated)
UMAP_EXCLUDE_DEFAULT_MAPS = False 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" SITE_URL = "http://localhost:8019"
SHORT_SITE_URL = "http://s.hort" SHORT_SITE_URL = "http://s.hort"

View file

@ -75,7 +75,7 @@ class Home(TemplateView, PaginatorMixin):
else: else:
qs = qs.exclude(id=showcase_map.pk) qs = qs.exclude(id=showcase_map.pk)
maps = qs.order_by('-modified_at')[:50] maps = qs.order_by('-modified_at')[:50]
maps = self.paginate(maps) maps = self.paginate(maps, settings.UMAP_MAPS_PER_PAGE)
return { return {
"maps": maps, "maps": maps,
@ -115,7 +115,10 @@ class UserMaps(DetailView, PaginatorMixin):
manager = Map.objects if owner else Map.public manager = Map.objects if owner else Map.public
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]
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) maps = self.paginate(maps, per_page)
kwargs.update({ kwargs.update({
"maps": maps "maps": maps