From 3e4d0ad77e45212276efa6778acb03bdaeecbffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Weing=C3=A4rtner?= Date: Tue, 16 Mar 2021 08:46:29 -0300 Subject: [PATCH] Fix `_data_table.html` weird conditional. While troubleshooting a problem with pagination I noticed the following conditional in `horizon/templates/horizon/common/_data_table.html`: ``` {% if table.number_of_pages is defined %} {% include "horizon/common/_data_table_pagination.html" %} {% else %} {% include "horizon/common/_data_table_pagination_with_pages.html" %} {% endif %} ``` At first sight, it looks wrong. I mean, if there are number_of_pages, we should use `_data_table_pagination_with_pages.html`. However, this conditional solves to `True` if table.number_of_pages is NOT defined, and then it solves to `False`, if it is defined. It is a very weird (to me) behavior. Therefore, I am suggesting to use a more readable and understandable conditional in this patch. We can simply use `if table.number_of_pages is None`, which will behave as expected; if there are not number of pages, we use the traditional paging, and then, if there are number of pages, we use the paged data table approach. Change-Id: I933b1f9399f40569c7661c1db5776d468917b966 --- horizon/templates/horizon/common/_data_table.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/horizon/templates/horizon/common/_data_table.html b/horizon/templates/horizon/common/_data_table.html index c5f3dd7481..d29ff7c656 100644 --- a/horizon/templates/horizon/common/_data_table.html +++ b/horizon/templates/horizon/common/_data_table.html @@ -24,7 +24,7 @@ {% endif %} {% endblock table_breadcrumb %} {% if table.footer and rows %} - {% if table.number_of_pages is defined %} + {% if table.number_of_pages is None %} {% include "horizon/common/_data_table_pagination.html" %} {% else %} {% include "horizon/common/_data_table_pagination_with_pages.html" %} @@ -76,7 +76,7 @@ {% endfor %} {% endif %} - {% if table.number_of_pages is defined %} + {% if table.number_of_pages is None %} {% include "horizon/common/_data_table_pagination.html" %} {% else %} {% include "horizon/common/_data_table_pagination_with_pages.html" %}