From a73822e33003754fce58f5b4084ba34c7a2128a9 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 6 May 2020 12:21:49 +0000 Subject: [PATCH] template: only show the first 25 releases in "Releases Table" https://github.com/open-contracting/cove-ocds/issues/31 --- cove_ocds/fixtures/30_releases.json | 124 ++++++++++++++++++ cove_ocds/locale/en/LC_MESSAGES/django.po | 48 ++++--- cove_ocds/locale/es/LC_MESSAGES/django.po | 55 ++++---- .../templates/cove_ocds/explore_release.html | 9 +- cove_ocds/tests_functional.py | 28 ++++ requirements.txt | 8 +- requirements_dev.txt | 10 +- 7 files changed, 228 insertions(+), 54 deletions(-) create mode 100644 cove_ocds/fixtures/30_releases.json diff --git a/cove_ocds/fixtures/30_releases.json b/cove_ocds/fixtures/30_releases.json new file mode 100644 index 00000000..23c4c5e9 --- /dev/null +++ b/cove_ocds/fixtures/30_releases.json @@ -0,0 +1,124 @@ +{ + "releases": [ + { + "ocid": "ocds-example-1", + "id": "ocds-example-1-1" + }, + { + "ocid": "ocds-example-1", + "id": "ocds-example-1-2" + }, + { + "ocid": "ocds-example-1", + "id": "ocds-example-1-3" + }, + { + "ocid": "ocds-example-1", + "id": "ocds-example-1-4" + }, + { + "ocid": "ocds-example-1", + "id": "ocds-example-1-5" + }, + { + "ocid": "ocds-example-2", + "id": "ocds-example-2-1" + }, + { + "ocid": "ocds-example-2", + "id": "ocds-example-2-2" + }, + { + "ocid": "ocds-example-2", + "id": "ocds-example-2-3" + }, + { + "ocid": "ocds-example-2", + "id": "ocds-example-2-4" + }, + { + "ocid": "ocds-example-2", + "id": "ocds-example-2-5" + }, + { + "ocid": "ocds-example-3", + "id": "ocds-example-3-1" + }, + { + "ocid": "ocds-example-3", + "id": "ocds-example-3-2" + }, + { + "ocid": "ocds-example-3", + "id": "ocds-example-3-3" + }, + { + "ocid": "ocds-example-3", + "id": "ocds-example-3-4" + }, + { + "ocid": "ocds-example-3", + "id": "ocds-example-3-5" + }, + { + "ocid": "ocds-example-4", + "id": "ocds-example-4-1" + }, + { + "ocid": "ocds-example-4", + "id": "ocds-example-4-2" + }, + { + "ocid": "ocds-example-4", + "id": "ocds-example-4-3" + }, + { + "ocid": "ocds-example-4", + "id": "ocds-example-4-4" + }, + { + "ocid": "ocds-example-4", + "id": "ocds-example-4-5" + }, + { + "ocid": "ocds-example-5", + "id": "ocds-example-5-1" + }, + { + "ocid": "ocds-example-5", + "id": "ocds-example-5-2" + }, + { + "ocid": "ocds-example-5", + "id": "ocds-example-5-3" + }, + { + "ocid": "ocds-example-5", + "id": "ocds-example-5-4" + }, + { + "ocid": "ocds-example-5", + "id": "ocds-example-5-5" + }, + { + "ocid": "ocds-example-6", + "id": "ocds-example-6-1" + }, + { + "ocid": "ocds-example-6", + "id": "ocds-example-6-2" + }, + { + "ocid": "ocds-example-6", + "id": "ocds-example-6-3" + }, + { + "ocid": "ocds-example-6", + "id": "ocds-example-6-4" + }, + { + "ocid": "ocds-example-6", + "id": "ocds-example-6-5" + } + ] +} diff --git a/cove_ocds/locale/en/LC_MESSAGES/django.po b/cove_ocds/locale/en/LC_MESSAGES/django.po index a2d3290e..4302aeb4 100644 --- a/cove_ocds/locale/en/LC_MESSAGES/django.po +++ b/cove_ocds/locale/en/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-26 08:10+0000\n" +"POT-Creation-Date: 2020-05-06 10:17+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -23,7 +23,7 @@ msgstr "" #: cove_ocds/lib/exceptions.py:11 cove_ocds/lib/exceptions.py:31 #: cove_ocds/lib/exceptions.py:54 cove_ocds/lib/exceptions.py:74 -#: cove_ocds/views.py:80 cove_ocds/views.py:98 +#: cove_ocds/views.py:81 cove_ocds/views.py:99 msgid "Try Again" msgstr "" @@ -551,12 +551,12 @@ msgid "Records Table:" msgstr "" #: cove_ocds/templates/cove_ocds/explore_record.html:170 -#: cove_ocds/templates/cove_ocds/explore_release.html:422 +#: cove_ocds/templates/cove_ocds/explore_release.html:427 msgid "Explore your data:" msgstr "" #: cove_ocds/templates/cove_ocds/explore_record.html:175 -#: cove_ocds/templates/cove_ocds/explore_release.html:427 +#: cove_ocds/templates/cove_ocds/explore_release.html:432 msgid "" "This section provides a visual representation of the data, use it to check " "whether the data makes sense in the type of tool a user might use to explore " @@ -564,14 +564,14 @@ msgid "" msgstr "" #: cove_ocds/templates/cove_ocds/explore_record.html:178 -#: cove_ocds/templates/cove_ocds/explore_release.html:430 +#: cove_ocds/templates/cove_ocds/explore_release.html:435 msgid "" "Extensions and additional fields are hidden by default, click the 'Extra " "fields' buttons or open the 'Extra fields' section to view them." msgstr "" #: cove_ocds/templates/cove_ocds/explore_record.html:181 -#: cove_ocds/templates/cove_ocds/explore_release.html:433 +#: cove_ocds/templates/cove_ocds/explore_release.html:438 msgid "" "When viewing an OCDS record, use the numbers at the top of the visualization " "to browse the change history. New and changed fields are highlighted, use " @@ -837,55 +837,61 @@ msgstr "" msgid "Releases Table:" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:348 +#: cove_ocds/templates/cove_ocds/explore_release.html:346 +msgid "" +"Showing the first 25 releases. To explore all your data in a tabular format, " +"convert it to a spreadsheet using the \"Convert\" section, above." +msgstr "" + +#: cove_ocds/templates/cove_ocds/explore_release.html:353 msgid "Release Date" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:349 +#: cove_ocds/templates/cove_ocds/explore_release.html:354 msgid "Tags" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:350 +#: cove_ocds/templates/cove_ocds/explore_release.html:355 msgid "Descriptions" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:351 +#: cove_ocds/templates/cove_ocds/explore_release.html:356 msgid "Purchasers" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:363 +#: cove_ocds/templates/cove_ocds/explore_release.html:368 msgid "Tender Title:" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:366 +#: cove_ocds/templates/cove_ocds/explore_release.html:371 msgid "Tender Description:" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:370 +#: cove_ocds/templates/cove_ocds/explore_release.html:375 msgid "Tender Item Description:" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:375 +#: cove_ocds/templates/cove_ocds/explore_release.html:380 msgid "Award Title:" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:378 +#: cove_ocds/templates/cove_ocds/explore_release.html:383 msgid "Award Description:" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:383 +#: cove_ocds/templates/cove_ocds/explore_release.html:388 msgid "Contract Title:" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:386 +#: cove_ocds/templates/cove_ocds/explore_release.html:391 msgid "Contract Description:" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:394 +#: cove_ocds/templates/cove_ocds/explore_release.html:399 msgid "Buyer:" msgstr "" -#: cove_ocds/templates/cove_ocds/explore_release.html:400 +#: cove_ocds/templates/cove_ocds/explore_release.html:405 msgid "Procuring Entity:" msgstr "" @@ -1127,11 +1133,11 @@ msgstr "" msgid "Line:" msgstr "" -#: cove_ocds/views.py:78 cove_ocds/views.py:96 +#: cove_ocds/views.py:79 cove_ocds/views.py:97 msgid "Sorry, we can't process that data" msgstr "" -#: cove_ocds/views.py:100 +#: cove_ocds/views.py:101 msgid "" "OCDS JSON should have an object as the top level, the JSON you supplied does " "not." diff --git a/cove_ocds/locale/es/LC_MESSAGES/django.po b/cove_ocds/locale/es/LC_MESSAGES/django.po index 7347ac05..2254c9d6 100644 --- a/cove_ocds/locale/es/LC_MESSAGES/django.po +++ b/cove_ocds/locale/es/LC_MESSAGES/django.po @@ -4,22 +4,22 @@ # FIRST AUTHOR , YEAR. # # Translators: -# Bibiana Cristòfol , 2020 # Romina Fernandez , 2020 # Amy Guy , 2020 # Ben Webb , 2020 # Eduardo Gomez , 2020 # James Baster , 2020 # Maria Esther Cervantes , 2020 +# Bibiana Cristòfol , 2020 # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-18 15:26+0000\n" +"POT-Creation-Date: 2020-05-06 10:17+0000\n" "PO-Revision-Date: 2020-01-02 14:12+0000\n" -"Last-Translator: Maria Esther Cervantes , 2020\n" +"Last-Translator: Bibiana Cristòfol , 2020\n" "Language-Team: Spanish (https://www.transifex.com/OpenDataServices/teams/59127/es/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -33,7 +33,7 @@ msgstr "Versión del esquema no reconocida" #: cove_ocds/lib/exceptions.py:11 cove_ocds/lib/exceptions.py:31 #: cove_ocds/lib/exceptions.py:54 cove_ocds/lib/exceptions.py:74 -#: cove_ocds/views.py:80 cove_ocds/views.py:98 +#: cove_ocds/views.py:81 cove_ocds/views.py:99 msgid "Try Again" msgstr "Inténtelo de nuevo" @@ -632,12 +632,12 @@ msgid "Records Table:" msgstr "Tabla de Registros:" #: cove_ocds/templates/cove_ocds/explore_record.html:170 -#: cove_ocds/templates/cove_ocds/explore_release.html:422 +#: cove_ocds/templates/cove_ocds/explore_release.html:427 msgid "Explore your data:" msgstr "Explora tus datos:" #: cove_ocds/templates/cove_ocds/explore_record.html:175 -#: cove_ocds/templates/cove_ocds/explore_release.html:427 +#: cove_ocds/templates/cove_ocds/explore_release.html:432 msgid "" "This section provides a visual representation of the data, use it to check " "whether the data makes sense in the type of tool a user might use to explore" @@ -648,7 +648,7 @@ msgstr "" "podría usar para explorarlos." #: cove_ocds/templates/cove_ocds/explore_record.html:178 -#: cove_ocds/templates/cove_ocds/explore_release.html:430 +#: cove_ocds/templates/cove_ocds/explore_release.html:435 msgid "" "Extensions and additional fields are hidden by default, click the 'Extra " "fields' buttons or open the 'Extra fields' section to view them." @@ -658,7 +658,7 @@ msgstr "" "adicionales\" para verlos." #: cove_ocds/templates/cove_ocds/explore_record.html:181 -#: cove_ocds/templates/cove_ocds/explore_release.html:433 +#: cove_ocds/templates/cove_ocds/explore_release.html:438 msgid "" "When viewing an OCDS record, use the numbers at the top of the visualization" " to browse the change history. New and changed fields are highlighted, use " @@ -935,55 +935,64 @@ msgstr "" msgid "Releases Table:" msgstr "Tabla de Entregas:" -#: cove_ocds/templates/cove_ocds/explore_release.html:348 +#: cove_ocds/templates/cove_ocds/explore_release.html:346 +msgid "" +"Showing the first 25 releases. To explore all your data in a tabular format," +" convert it to a spreadsheet using the \"Convert\" section, above." +msgstr "" +"Mostrando los primeros 25 lanzamientos. Para explorar todos tus datos en " +"formato tabular, conviértalos a una hoja de cálculo usando la sección " +"\"Convertir\", arriba." + +#: cove_ocds/templates/cove_ocds/explore_release.html:353 msgid "Release Date" msgstr "Fecha de Entrega" -#: cove_ocds/templates/cove_ocds/explore_release.html:349 +#: cove_ocds/templates/cove_ocds/explore_release.html:354 msgid "Tags" msgstr "Etiquetas" -#: cove_ocds/templates/cove_ocds/explore_release.html:350 +#: cove_ocds/templates/cove_ocds/explore_release.html:355 msgid "Descriptions" msgstr "Descripciones" -#: cove_ocds/templates/cove_ocds/explore_release.html:351 +#: cove_ocds/templates/cove_ocds/explore_release.html:356 msgid "Purchasers" msgstr "Compradores" -#: cove_ocds/templates/cove_ocds/explore_release.html:363 +#: cove_ocds/templates/cove_ocds/explore_release.html:368 msgid "Tender Title:" msgstr "Título de la Licitación:" -#: cove_ocds/templates/cove_ocds/explore_release.html:366 +#: cove_ocds/templates/cove_ocds/explore_release.html:371 msgid "Tender Description:" msgstr "Descripción de la Licitación:" -#: cove_ocds/templates/cove_ocds/explore_release.html:370 +#: cove_ocds/templates/cove_ocds/explore_release.html:375 msgid "Tender Item Description:" msgstr "Descripción del Artículo de la Licitación:" -#: cove_ocds/templates/cove_ocds/explore_release.html:375 +#: cove_ocds/templates/cove_ocds/explore_release.html:380 msgid "Award Title:" msgstr "Título de la Adjudicación:" -#: cove_ocds/templates/cove_ocds/explore_release.html:378 +#: cove_ocds/templates/cove_ocds/explore_release.html:383 msgid "Award Description:" msgstr "Descripción de la Adjudicación:" -#: cove_ocds/templates/cove_ocds/explore_release.html:383 +#: cove_ocds/templates/cove_ocds/explore_release.html:388 msgid "Contract Title:" msgstr "Título del Contrato:" -#: cove_ocds/templates/cove_ocds/explore_release.html:386 +#: cove_ocds/templates/cove_ocds/explore_release.html:391 msgid "Contract Description:" msgstr "Descripción del Contrato:" -#: cove_ocds/templates/cove_ocds/explore_release.html:394 +#: cove_ocds/templates/cove_ocds/explore_release.html:399 msgid "Buyer:" msgstr "Comprador:" -#: cove_ocds/templates/cove_ocds/explore_release.html:400 +#: cove_ocds/templates/cove_ocds/explore_release.html:405 msgid "Procuring Entity:" msgstr "Entidad Contratante:" @@ -1284,11 +1293,11 @@ msgstr "Ruta:" msgid "Line:" msgstr "Línea:" -#: cove_ocds/views.py:78 cove_ocds/views.py:96 +#: cove_ocds/views.py:79 cove_ocds/views.py:97 msgid "Sorry, we can't process that data" msgstr "Lo sentimos, no podemos procesar esos datos" -#: cove_ocds/views.py:100 +#: cove_ocds/views.py:101 msgid "" "OCDS JSON should have an object as the top level, the JSON you supplied does" " not." diff --git a/cove_ocds/templates/cove_ocds/explore_release.html b/cove_ocds/templates/cove_ocds/explore_release.html index a1771c14..f255e1a3 100644 --- a/cove_ocds/templates/cove_ocds/explore_release.html +++ b/cove_ocds/templates/cove_ocds/explore_release.html @@ -334,13 +334,18 @@

{% trans 'Documents' %}

-
+

{% trans "Releases Table:" %}

+ {% if releases|length > 25 %} +

+ {% blocktrans %}Showing the first 25 releases. To explore all your data in a tabular format, convert it to a spreadsheet using the "Convert" section, above.{% endblocktrans %} +

+ {% endif %} @@ -352,7 +357,7 @@

- {% for release in releases %} + {% for release in releases|slice:":25" %} diff --git a/cove_ocds/tests_functional.py b/cove_ocds/tests_functional.py index 3d665a44..21a69cc3 100644 --- a/cove_ocds/tests_functional.py +++ b/cove_ocds/tests_functional.py @@ -1097,3 +1097,31 @@ def test_additional_checks_error_modal( browser.find_element_by_css_selector( "div.modal.additional-checks-1 button.close" ).click() + + +def test_release_table_25_rows(url_input_browser): + """ + Check that when there are more than 25 releases, only 25 are shown in the + table, and there is a message. + """ + + browser = url_input_browser("30_releases.json") + assert "This file contains 30 releases" in browser.find_element_by_tag_name("body").text + panel = browser.find_element_by_css_selector("#releases-table-panel") + assert "first 25 releases" in panel.text + table_rows = browser.find_elements_by_css_selector("#releases-table-panel table tbody tr") + assert len(table_rows) == 25 + + +def test_release_table_7_rows(url_input_browser): + """ + Check that when there are less than 25 releases, they are all shown in the + table, and there is no message. + """ + + browser = url_input_browser("tenders_releases_7_releases_check_ocids.json") + assert "This file contains 7 releases" in browser.find_element_by_tag_name("body").text + panel = browser.find_element_by_css_selector("#releases-table-panel") + assert "first 25 releases" not in panel.text + table_rows = browser.find_elements_by_css_selector("#releases-table-panel table tbody tr") + assert len(table_rows) == 7 diff --git a/requirements.txt b/requirements.txt index 9745eab1..ad1bc674 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ # -e git+https://github.com/OpenDataServices/lib-cove-web.git@v0.14.0#egg=libcoveweb # via -r requirements.in attrs==19.3.0 # via jsonschema -bleach==3.1.4 # via -r requirements.in, libcove, libcoveocds +bleach==3.1.5 # via -r requirements.in, libcove, libcoveocds cached-property==1.5.1 # via -r requirements.in, libcove, libcoveocds, libcoveweb certifi==2020.4.5.1 # via requests, sentry-sdk chardet==3.0.4 # via requests @@ -14,7 +14,7 @@ commonmark==0.9.1 # via -r requirements.in, libcove, libcoveocds contextlib2==0.6.0.post1 # via schema dealer==2.1.0 # via -r requirements.in, libcoveweb defusedxml==0.6.0 # via odfpy -django-bootstrap3==12.0.3 # via -r requirements.in, libcoveweb +django-bootstrap3==12.1.0 # via -r requirements.in, libcoveweb django-debug-toolbar==2.2 # via -r requirements.in, libcoveweb django-environ==0.4.5 # via -r requirements.in, libcoveweb django==2.2.12 # via -r requirements.in, django-debug-toolbar, libcove, libcoveocds, libcoveweb @@ -32,6 +32,8 @@ libcoveocds==0.7.4 # via -r requirements.in lxml==4.5.0 # via flattentool odfpy==1.4.1 # via flattentool openpyxl==2.6.4 # via -r requirements.in, flattentool, libcoveweb +packaging==20.3 # via bleach +pyparsing==2.4.7 # via packaging pyrsistent==0.16.0 # via jsonschema python-dateutil==2.8.1 # via -r requirements.in, libcoveweb pytz==2020.1 # via django, flattentool @@ -41,7 +43,7 @@ rfc3987==1.3.8 # via -r requirements.in, libcove, libcoveweb rfc6266==0.0.4 # via -r requirements.in, libcoveweb schema==0.7.2 # via flattentool sentry-sdk==0.14.3 # via -r requirements.in, libcoveweb -six==1.14.0 # via bleach, jsonschema, pyrsistent, python-dateutil +six==1.14.0 # via bleach, jsonschema, packaging, pyrsistent, python-dateutil sqlparse==0.3.1 # via django, django-debug-toolbar strict-rfc3339==0.7 # via -r requirements.in, libcove, libcoveweb urllib3==1.25.9 # via requests, sentry-sdk diff --git a/requirements_dev.txt b/requirements_dev.txt index e9faed59..66b18901 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -8,7 +8,7 @@ alabaster==0.7.12 # via sphinx attrs==19.3.0 # via -r requirements.txt, hypothesis, jsonschema, pytest babel==2.8.0 # via sphinx -bleach==3.1.4 # via -r requirements.txt, libcove, libcoveocds +bleach==3.1.5 # via -r requirements.txt, libcove, libcoveocds cached-property==1.5.1 # via -r requirements.txt, libcove, libcoveocds, libcoveweb certifi==2020.4.5.1 # via -r requirements.txt, requests, sentry-sdk chardet==3.0.4 # via -r requirements.txt, requests @@ -19,7 +19,7 @@ coverage==4.5.4 # via -r requirements_dev.in, coveralls, hypothesis, p coveralls==2.0.0 # via -r requirements_dev.in dealer==2.1.0 # via -r requirements.txt, libcoveweb defusedxml==0.6.0 # via -r requirements.txt, odfpy -django-bootstrap3==12.0.3 # via -r requirements.txt, libcoveweb +django-bootstrap3==12.1.0 # via -r requirements.txt, libcoveweb django-debug-toolbar==2.2 # via -r requirements.txt, libcoveweb django-environ==0.4.5 # via -r requirements.txt, libcoveweb django==2.2.12 # via -r requirements.txt, django-debug-toolbar, libcove, libcoveocds, libcoveweb @@ -47,14 +47,14 @@ mccabe==0.6.1 # via flake8 more-itertools==8.2.0 # via pytest odfpy==1.4.1 # via -r requirements.txt, flattentool openpyxl==2.6.4 # via -r requirements.txt, flattentool, libcoveweb -packaging==20.3 # via pytest, sphinx -pip-tools==5.1.0 # via -r requirements_dev.in +packaging==20.3 # via -r requirements.txt, bleach, pytest, sphinx +pip-tools==5.1.2 # via -r requirements_dev.in pluggy==0.13.1 # via pytest py==1.8.1 # via pytest pycodestyle==2.5.0 # via flake8 pyflakes==2.1.1 # via flake8 pygments==2.6.1 # via sphinx -pyparsing==2.4.7 # via packaging +pyparsing==2.4.7 # via -r requirements.txt, packaging pyrsistent==0.16.0 # via -r requirements.txt, jsonschema pytest-cov==2.8.1 # via -r requirements_dev.in pytest-django==3.9.0 # via -r requirements_dev.in
{{ release.ocid }} {{ release.date|date:"j M Y, H:i (e)" }}