diff --git a/umap/templates/umap/map_table.html b/umap/templates/umap/map_table.html
index 954c12ed..965521db 100644
--- a/umap/templates/umap/map_table.html
+++ b/umap/templates/umap/map_table.html
@@ -1,5 +1,6 @@
{% load umap_tags umap_tags i18n %}
+ {% if not is_ajax %}
{% blocktrans %}Map{% endblocktrans %} |
@@ -10,6 +11,7 @@
{% blocktrans %}Actions{% endblocktrans %} |
+ {% endif %}
{% for map_inst in maps %}
@@ -31,3 +33,9 @@
{% endfor %}
+{% if maps.has_next %}
+
+{% endif %}
diff --git a/umap/views.py b/umap/views.py
index da8eccf8..75e87e87 100644
--- a/umap/views.py
+++ b/umap/views.py
@@ -77,7 +77,7 @@ PRIVATE_IP = re.compile(
ANONYMOUS_COOKIE_MAX_AGE = 60 * 60 * 24 * 30 # One month
-class PaginatorMixin(object):
+class PaginatorMixin:
per_page = 5
def paginate(self, qs, per_page=None):
@@ -94,6 +94,18 @@ class PaginatorMixin(object):
qs = paginator.page(paginator.num_pages)
return qs
+ def get_context_data(self, **kwargs):
+ kwargs.update({"is_ajax": is_ajax(self.request)})
+ return super().get_context_data(**kwargs)
+
+ def get_template_names(self):
+ """
+ Dispatch template according to the kind of request: ajax or normal.
+ """
+ if is_ajax(self.request):
+ return [self.list_template_name]
+ return super().get_template_names()
+
class PublicMapsMixin(object):
def get_public_maps(self):
@@ -108,7 +120,7 @@ class PublicMapsMixin(object):
return maps
-class Home(TemplateView, PublicMapsMixin, PaginatorMixin):
+class Home(PaginatorMixin, TemplateView, PublicMapsMixin):
template_name = "umap/home.html"
list_template_name = "umap/map_list.html"
@@ -141,15 +153,6 @@ class Home(TemplateView, PublicMapsMixin, PaginatorMixin):
"showcase_map": showcase_map,
}
- def get_template_names(self):
- """
- Dispatch template according to the kind of request: ajax or normal.
- """
- if is_ajax(self.request):
- return [self.list_template_name]
- else:
- return [self.template_name]
-
home = Home.as_view()
@@ -161,7 +164,7 @@ class About(Home):
about = About.as_view()
-class UserMaps(DetailView, PaginatorMixin):
+class UserMaps(PaginatorMixin, DetailView):
model = User
slug_url_kwarg = "identifier"
slug_field = settings.USER_URL_FIELD
@@ -189,15 +192,6 @@ class UserMaps(DetailView, PaginatorMixin):
kwargs.update({"maps": self.paginate(self.get_maps(), self.per_page)})
return super().get_context_data(**kwargs)
- def get_template_names(self):
- """
- Dispatch template according to the kind of request: ajax or normal.
- """
- if is_ajax(self.request):
- return [self.list_template_name]
- else:
- return super(UserMaps, self).get_template_names()
-
user_maps = UserMaps.as_view()
@@ -226,7 +220,7 @@ class SearchMixin:
return Map.objects.annotate(search=vector).filter(search=query)
-class Search(TemplateView, PublicMapsMixin, PaginatorMixin, SearchMixin):
+class Search(PaginatorMixin, TemplateView, PublicMapsMixin, SearchMixin):
template_name = "umap/search.html"
list_template_name = "umap/map_list.html"
@@ -243,15 +237,6 @@ class Search(TemplateView, PublicMapsMixin, PaginatorMixin, SearchMixin):
kwargs.update({"maps": results, "count": qs_count})
return kwargs
- def get_template_names(self):
- """
- Dispatch template according to the kind of request: ajax or normal.
- """
- if is_ajax(self.request):
- return [self.list_template_name]
- else:
- return super(Search, self).get_template_names()
-
@property
def per_page(self):
return settings.UMAP_MAPS_PER_SEARCH
@@ -260,9 +245,10 @@ class Search(TemplateView, PublicMapsMixin, PaginatorMixin, SearchMixin):
search = Search.as_view()
-class UserDashboard(DetailView, PaginatorMixin, SearchMixin):
+class UserDashboard(PaginatorMixin, DetailView, SearchMixin):
model = User
template_name = "umap/user_dashboard.html"
+ list_template_name = "umap/map_table.html"
def get_object(self):
return self.get_queryset().get(pk=self.request.user.pk)