Repository: candango/firenado (language: python)

Issue:
Delivered 0.2.14.



Discussion / hints:

Fix patch:
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index ad35167..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-# https://travis-ci.org/candango/firenado
-language: python
-python:
-  - "3.6"
-  - "3.7"
-  - "3.8"
-  - "3.9"
-install:
-  - "pip install -r requirements/basic.txt"
-  - "pip install -r requirements/all.txt"
-  - "pip install -r requirements/tests.txt"
-script:
-  - "PYTHONPATH=$PYTHONPATH:. python tests/runtests.py"
-  - ./scripts/run_behave.sh
diff --git a/docs/conf.py b/docs/conf.py
index 6235633..3505fd9 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -57,7 +57,7 @@
 # The short X.Y version.
 version = '0.2'
 # The full version, including alpha/beta/rc tags.
-release = '0.2.13'
+release = '0.2.14'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/docs/releases.rst b/docs/releases.rst
index 83f5639..c66bde8 100644
--- a/docs/releases.rst
+++ b/docs/releases.rst
@@ -4,6 +4,7 @@ Release notes
 .. toctree::
    :maxdepth: 2
 
+   releases/v0.2.14
    releases/v0.2.13
    releases/v0.2.12
    releases/v0.2.11
diff --git a/docs/releases/v0.2.14.rst b/docs/releases/v0.2.14.rst
new file mode 100644
index 0000000..544c9e9
--- /dev/null
+++ b/docs/releases/v0.2.14.rst
@@ -0,0 +1,18 @@
+What's new in Firenado 0.2.14
+=============================
+
+Dec 09, 2021
+------------
+
+We are pleased to announce the release of Firenado 0.2.14.
+
+Fixed pagination api as implemented in the new Cartola 0.14 and replaced travis
+by github actions for testing.
+
+Here are the highlights:
+
+Refactory
+~~~~~~~~~
+
+ * Update cartola paginator. `#380 <https://github.com/candango/firenado/issues/380>`_
+ * Replace travis by github actions. `#381 <https://github.com/candango/firenado/issues/381>`_
diff --git a/firenado/__init__.py b/firenado/__init__.py
index 1a6975e..aa06feb 100644
--- a/firenado/__init__.py
+++ b/firenado/__init__.py
@@ -1,6 +1,6 @@
 # -*- coding: UTF-8 -*-
 #
-# Copyright 2015-2021 Flavio Garcia
+# Copyright 2015-2022 Flavio Garcia
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
 """The Firenado Framework"""
 
 __author__ = "Flavio Garcia <piraz@candango.org>"
-__version__ = (0, 2, 13)
+__version__ = (0, 2, 14)
 __licence__ = "Apache License V2.0"
 
 
diff --git a/firenado/components/toolbox/templates/uimodules/pagination.html b/firenado/components/toolbox/templates/uimodules/pagination.html
index 432cead..73fc608 100644
--- a/firenado/components/toolbox/templates/uimodules/pagination.html
+++ b/firenado/components/toolbox/templates/uimodules/pagination.html
@@ -7,19 +7,19 @@
 	        </a>
 	    </li>
 	    <li>
-	        <a href="{{request.path}}?{{ argument }}={{ paginator.current_page-1 }}" title="Previous">
+	        <a href="{{request.path}}?{{ argument }}={{ paginator.page-1 }}" title="Previous">
 	            <span><i class="glyphicon glyphicon-fast-backward"></i></span>
 	        </a>
 	    </li>
         {% end %}
-        {% for i in paginator.block_pages %}
+        {% for i in paginator.pages_in_block %}
 
-	    <li {% if i==paginator.current_page %}class="active"{% end %}><a href="{% if i==paginator.current_page %}javascript:void(0){% else %}{{request.path}}?{{ argument }}={{ i }}{% end %}">{{ i }}</a></li>
+	    <li {% if i==paginator.page %}class="active"{% end %}><a href="{% if i==paginator.page %}javascript:void(0){% else %}{{request.path}}?{{ argument }}={{ i }}{% end %}">{{ i }}</a></li>
 		{% end %}
 
         {% if not paginator.is_last_page %}
         <li>
-	        <a href="{{request.path}}?{{ argument }}={{ paginator.current_page+1 }}" title="Next">
+	        <a href="{{request.path}}?{{ argument }}={{ paginator.page + 1 }}" title="Next">
 	            <span class="glyphicon glyphicon-forward" aria-hidden="true"></span>
 	        </a>
 	    </li>
diff --git a/firenado/components/toolbox/uimodules.py b/firenado/components/toolbox/uimodules.py
index 772cb5f..0511e5b 100644
--- a/firenado/components/toolbox/uimodules.py
+++ b/firenado/components/toolbox/uimodules.py
@@ -20,21 +20,31 @@
 
 class Paginate(tornado.web.UIModule):
 
-    def render(self, row_count, current_page, rows_per_page=None,
-               pages_per_block=None, argument="p",
-               template="toolbox:uimodules/pagination.html"):
+    def render(self, count, **kwargs):
+        name = kwargs.get("name", "paginator")
+        template = kwargs.get("template", "toolbox:uimodules/pagination.html")
+        parameters = {}
         component_conf = self.handler.component.conf
-        if 'pagination' in self.handler.component.conf:
-            if 'rows_per_page' in component_conf['pagination']:
-                rows_per_page = component_conf['pagination']['rows_per_page']
-            if 'pages_per_block' in component_conf['pagination']:
-                pages_per_block = component_conf['pagination'][
-                    'pages_per_block']
-        if rows_per_page is None:
-            rows_per_page = 10
-        if pages_per_block is None:
-            pages_per_block = 10
-        paginator = Paginator(row_count, current_page, rows_per_page,
-                              pages_per_block)
+        per_page = 10
+        per_block = 10
+        if 'pagination' in component_conf:
+            if 'per_page' in component_conf['pagination']:
+                per_page = component_conf['pagination']['per_page']
+            if 'per_block' in component_conf['pagination']:
+                per_block = component_conf['pagination']['per_block']
+
+        argument = kwargs.get("argument", "p")
+        page = self.request.arguments.get(argument, kwargs.get("page"))
+        if isinstance(page, list):
+            page = self.request.arguments.get(argument)[0]
+        if page:
+            page = int(page)
+        if page:
+            parameters['page'] = page
+
+        parameters['per_page'] = kwargs.get("per_page", per_page)
+        parameters['per_block'] = kwargs.get("per_block", per_block)
+        paginator = Paginator(count, **parameters)
+        setattr(self.handler, name, paginator)
         return self.render_string(template, argument=argument,
                                   paginator=paginator)
diff --git a/requirements/basic.txt b/requirements/basic.txt
index c8fc2c7..b4aa8e6 100644
--- a/requirements/basic.txt
+++ b/requirements/basic.txt
@@ -1,3 +1,3 @@
-cartola==0.13
+cartola==0.14
 pymobiledetect==1.3.2
 tornado==6.1
diff --git a/setup.py b/setup.py
index b43b672..0ba74fb 100644
--- a/setup.py
+++ b/setup.py
@@ -84,6 +84,7 @@ def resolve_requires(requirements_file):
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
+        "Programming Language :: Python :: 3 :: Only",
         "Topic :: Internet :: WWW/HTTP",
         "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
         "Topic :: Internet :: WWW/HTTP :: WSGI",


Test patch:
diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml
new file mode 100644
index 0000000..87a18e8
--- /dev/null
+++ b/.github/workflows/run_tests.yml
@@ -0,0 +1,29 @@
+name: Run firenado tests
+
+on: [push]
+
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: [3.6, 3.7, 3.8, 3.9]
+
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python-version }}
+      - name: Install dependencies
+        run: |
+          pip install -r requirements/basic.txt
+          pip install -r requirements/all.txt
+          pip install -r requirements/tests.txt
+      - name: Run python unit tests
+        run: |
+          PYTHONPATH=$PYTHONPATH:. python tests/runtests.py
+      - name: Run python behave tests
+        run: |
+          ./scripts/run_behave.sh
\ No newline at end of file
diff --git a/examples/testapp/handlers.py b/examples/testapp/handlers.py
index 1b9ee22..385d7bf 100644
--- a/examples/testapp/handlers.py
+++ b/examples/testapp/handlers.py
@@ -192,6 +192,5 @@ def get(self):
         pag_argument = "pag"
         page = self.get_argument(pag_argument, default=1)
         row_count = 316
-        paginator = Paginator(row_count, page)
-        self.render("pagination.html", row_count=row_count, page=page,
-                    paginator=paginator, pag_argument=pag_argument)
+        self.render("pagination.html", page=page, row_count=row_count,
+                    pag_argument=pag_argument)
diff --git a/examples/testapp/templates/pagination.html b/examples/testapp/templates/pagination.html
index eb6bea5..caaa07f 100644
--- a/examples/testapp/templates/pagination.html
+++ b/examples/testapp/templates/pagination.html
@@ -7,18 +7,19 @@ <h1>Pagination Test</h1>
     </ul>
 
     <h2>Pagination Component:</h2>
-    {% module Paginate(row_count, page, argument=pag_argument) %}
+    {% module Paginate(row_count, page=page, argument=pag_argument, name="pagination") %}
 
     <h2>Pagination Data:</h2>
-    <p><b>Current page:</b> {{ paginator.current_page }}</p>
-    <p><b>Row count:</b> {{ paginator.row_count }}</p>
-    <p><b>Page count:</b> {{ paginator.page_count }}</p>
-    <p><b>Rows in the last page:</b> {{ paginator.rows_last_page }}</p>
-    <p><b>Block count:</b> {{ paginator.block_count }}</p>
-    <p><b>Pages in the last block:</b> {{ paginator.pages_last_block }}</p>
-    <p><b>Current block:</b> {{ paginator.current_block }}</p>
-    <p><b>Current First Row:</b> {{ paginator.current_first_row }}</p>
-    <p><b>Current Last Row:</b> {{ paginator.current_last_row }}</p>
-    <p><b>Block First Page:</b> {{ paginator.block_first_page }}</p>
-    <p><b>Block Last Page:</b> {{ paginator.block_last_page }}</p>
+    <p><b>Current page:</b> {{ handler.pagination.page }}</p>
+    <p><b>Row count:</b> {{ handler.pagination.count }}</p>
+    <p><b>Page count:</b> {{ handler.pagination.pages }}</p>
+    <p><b>Rows in the last page:</b> {{ handler.pagination.rows_in_last_page }}</p>
+    <p><b>Block count:</b> {{ handler.pagination.blocks }}</p>
+    <p><b>Pages in the last block:</b> {{ handler.pagination.pages_last_block }}</p>
+    <p><b>Current block:</b> {{ handler.pagination.block }}</p>
+    <p><b>Current First Row:</b> {{ handler.pagination.first_row }}</p>
+    <p><b>Current Last Row:</b> {{ handler.pagination.last_row }}</p>
+    <p><b>Block First Page:</b> {{ handler.pagination.first_page_in_block }}</p>
+    <p><b>Block Last Page:</b> {{ handler.pagination.last_page_in_block }}</p>
+
 {% end %}