Skip to content

Commit

Permalink
template: only show the first 25 releases in "Releases Table"
Browse files Browse the repository at this point in the history
  • Loading branch information
Bjwebb committed May 6, 2020
1 parent cf0eb7d commit e5d7c33
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 31 deletions.
124 changes: 124 additions & 0 deletions cove_ocds/fixtures/30_releases.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
52 changes: 31 additions & 21 deletions cove_ocds/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 09:32+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -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 ""

Expand Down Expand Up @@ -551,27 +551,27 @@ 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:431
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:436
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 "
"it."
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:439
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:442
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 "
Expand Down Expand Up @@ -837,55 +837,65 @@ msgstr ""
msgid "Releases Table:"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:348
#: cove_ocds/templates/cove_ocds/explore_release.html:346
msgid ""
"\n"
" Showing the first 25 releases. To explore all your data in a\n"
" tabular format, convert it to a spreadsheet using the \"Convert"
"\"\n"
" section, above.\n"
" "
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:357
msgid "Release Date"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:349
#: cove_ocds/templates/cove_ocds/explore_release.html:358
msgid "Tags"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:350
#: cove_ocds/templates/cove_ocds/explore_release.html:359
msgid "Descriptions"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:351
#: cove_ocds/templates/cove_ocds/explore_release.html:360
msgid "Purchasers"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:363
#: cove_ocds/templates/cove_ocds/explore_release.html:372
msgid "Tender Title:"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:366
#: cove_ocds/templates/cove_ocds/explore_release.html:375
msgid "Tender Description:"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:370
#: cove_ocds/templates/cove_ocds/explore_release.html:379
msgid "Tender Item Description:"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:375
#: cove_ocds/templates/cove_ocds/explore_release.html:384
msgid "Award Title:"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:378
#: cove_ocds/templates/cove_ocds/explore_release.html:387
msgid "Award Description:"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:383
#: cove_ocds/templates/cove_ocds/explore_release.html:392
msgid "Contract Title:"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:386
#: cove_ocds/templates/cove_ocds/explore_release.html:395
msgid "Contract Description:"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:394
#: cove_ocds/templates/cove_ocds/explore_release.html:403
msgid "Buyer:"
msgstr ""

#: cove_ocds/templates/cove_ocds/explore_release.html:400
#: cove_ocds/templates/cove_ocds/explore_release.html:409
msgid "Procuring Entity:"
msgstr ""

Expand Down Expand Up @@ -1127,11 +1137,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."
Expand Down
9 changes: 7 additions & 2 deletions cove_ocds/templates/cove_ocds/explore_release.html
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,18 @@ <h4 class="panel-title">{% trans 'Documents' %}</h4>

<div class="row"> <!--Start Row (Detail Table)-->
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel panel-default" id="releases-table-panel">
<div class="panel-heading">
<h4 class="panel-title">
{% trans "Releases Table:" %}
</h4>
</div>
<div class="panel-body">
{% if releases|length > 25 %}
<p>
{% 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 %}
</p>
{% endif %}
<table class="table table-striped">
<thead>
<tr>
Expand All @@ -352,7 +357,7 @@ <h4 class="panel-title">
</tr>
</thead>
<tbody>
{% for release in releases %}
{% for release in releases|slice:":25" %}
<tr>
<td>{{ release.ocid }}</td>
<td>{{ release.date|date:"j M Y, H:i (e)" }}</td>
Expand Down
28 changes: 28 additions & 0 deletions cove_ocds/tests_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 5 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
#
-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
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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit e5d7c33

Please sign in to comment.