diff --git a/ckanext/datagovtheme/fanstatic_library/styles/datagovtheme.css b/ckanext/datagovtheme/fanstatic_library/styles/datagovtheme.css index d689171c..3e9dc8dd 100644 --- a/ckanext/datagovtheme/fanstatic_library/styles/datagovtheme.css +++ b/ckanext/datagovtheme/fanstatic_library/styles/datagovtheme.css @@ -656,7 +656,7 @@ a { } .label { display: inline; - padding: 0.2em 0.6em 0.3em; + padding: 0.2em 0.6em 0.2em; font-size: 75%; font-weight: 700; line-height: 1; @@ -736,6 +736,8 @@ a.label:focus { .module-narrow #dataset-map-container { height: 200px; + border-bottom: 1px solid #ddd; + border-top: 1px solid #ddd; } .module-content #dataset-map-container { height: 250px; @@ -2120,9 +2122,82 @@ p.module-content { float: left; } -.topic-aapi a i:before { - content: '\e600'; +/* BEGIN of styling NGDA lable using button arrows for bootstrap 3 */ +body .tagged-ngda { + background-color: #3498db; + border-color: #3498db; + color: white; +} +.btn-arrow-right { + padding-left: 14px; + padding-right: 8px; + margin-right: 8px; } +.btn-arrow-left { + padding-left: 8px; + padding-right: 14px; + margin-left: 8px; +} +.btn-arrow-right, +.btn-arrow-left { + position: relative; + font-size: 0.75em; + padding-top: 1px; + padding-bottom:2px; + line-height: 1; + cursor: auto; +} +.btn-arrow-right:before, +.btn-arrow-right:after, +.btn-arrow-left:before, +.btn-arrow-left:after { /* make two squares (before and after), looking similar to the button */ + content:""; + position: absolute; + top: 2px; /* move it down because of rounded corners */ + width: 11px; /* same as height */ + height: 11px; /* button_outer_height / sqrt(2) */ + background: inherit; /* use parent background */ + border: inherit; /* use parent border */ + border-left-color: transparent; /* hide left border */ + border-bottom-color: transparent; /* hide bottom border */ + border-radius: 0px 4px 0px 0px; /* round arrow corner, the shorthand property doesn't accept "inherit" so it is set to 4px */ + -webkit-border-radius: 0px 4px 0px 0px; + -moz-border-radius: 0px 4px 0px 0px; +} +.btn-arrow-right:before, +.btn-arrow-right:after { + transform: rotate(45deg); /* rotate right arrow squares 45 deg to point right */ + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -o-transform: rotate(45deg); + -ms-transform: rotate(45deg); +} +.btn-arrow-left:before, +.btn-arrow-left:after { + transform: rotate(225deg); /* rotate left arrow squares 225 deg to point left */ + -webkit-transform: rotate(225deg); + -moz-transform: rotate(225deg); + -o-transform: rotate(225deg); + -ms-transform: rotate(225deg); +} +.btn-arrow-right:before, +.btn-arrow-left:before { /* align the "before" square to the left */ + left: -5px; +} +.btn-arrow-right:after, +.btn-arrow-left:after { /* align the "after" square to the right */ + right: -5px; +} +.btn-arrow-right:after, +.btn-arrow-left:before { /* bring arrow pointers to front */ + z-index: 1; +} +.btn-arrow-right:before, +.btn-arrow-left:after { /* hide arrow tails background */ + background-color: #f6f6f6; +} +/* END of styling NGDA lable using button arrows for bootstrap 3 */ + .dataset-collection { margin-right: 5px; diff --git a/ckanext/datagovtheme/helpers.py b/ckanext/datagovtheme/helpers.py index e655bb47..c0cd518e 100644 --- a/ckanext/datagovtheme/helpers.py +++ b/ckanext/datagovtheme/helpers.py @@ -647,6 +647,15 @@ def get_bureau_info(bureau_code): } +# returns true if the package contains a tag with the name 'ngda +def is_tagged_ngda(pkg_dict): + if 'tags' in pkg_dict: + for tag in pkg_dict['tags']: + if tag['name'].lower() == 'ngda': + return True + return False + + # TODO can we drop this dependency on ckanext-harvest? Can this be moved to ckanext-harvest? geodatagov? def get_pkg_dict_extra(pkg_dict, key, default=None): '''Override the CKAN core helper to add rolled up extras diff --git a/ckanext/datagovtheme/plugin.py b/ckanext/datagovtheme/plugin.py index a2219de5..c48f659d 100644 --- a/ckanext/datagovtheme/plugin.py +++ b/ckanext/datagovtheme/plugin.py @@ -88,6 +88,7 @@ def get_helpers(self): 'datagovtheme_api_doc_url': datagovtheme_helpers.api_doc_url, 'datagovtheme_get_reference_date': datagovtheme_helpers.get_reference_date, 'datagovtheme_get_responsible_party': datagovtheme_helpers.get_responsible_party, + 'is_tagged_ngda': datagovtheme_helpers.is_tagged_ngda, 'render_datetime_datagov': datagovtheme_helpers.render_datetime_datagov, 'get_harvest_object_formats': datagovtheme_helpers.get_harvest_object_formats, 'get_bureau_info': datagovtheme_helpers.get_bureau_info, diff --git a/ckanext/datagovtheme/public/css/datagovtheme.css b/ckanext/datagovtheme/public/css/datagovtheme.css index edf170ac..0130cf12 100644 --- a/ckanext/datagovtheme/public/css/datagovtheme.css +++ b/ckanext/datagovtheme/public/css/datagovtheme.css @@ -1790,8 +1790,6 @@ p.module-content{padding-left: 18px !important;} float: left; } -.topic-aapi a i:before{content:"\e600";} - .dataset-collection { margin-right: 5px; } diff --git a/ckanext/datagovtheme/templates/snippets/package_item.html b/ckanext/datagovtheme/templates/snippets/package_item.html index 04ab79e5..df07c199 100755 --- a/ckanext/datagovtheme/templates/snippets/package_item.html +++ b/ckanext/datagovtheme/templates/snippets/package_item.html @@ -56,6 +56,13 @@

{% elif package.get('state', '').startswith('deleted') %} {{ _('Deleted') }} {% endif %} + + {% if h.is_tagged_ngda(package) %} + + {{ _('NGDA') }} + + {% endif %} + {{ h.popular('recent views', package.tracking_summary.recent, min=10) if package.tracking_summary }}

diff --git a/ckanext/datagovtheme/tests/test_helpers.py b/ckanext/datagovtheme/tests/test_helpers.py index 5b56bd7b..9d1649e2 100644 --- a/ckanext/datagovtheme/tests/test_helpers.py +++ b/ckanext/datagovtheme/tests/test_helpers.py @@ -6,6 +6,7 @@ import pytest from ckanext.datagovtheme import helpers +import ckan.tests.factories as factories ################ @@ -117,3 +118,21 @@ def test_get_bureau_info_none(): bureau_info = helpers.get_bureau_info(None) assert bureau_info is None + + +################## +# ngda +################## + + +def test_is_tagged_ngda(): + """Assert that package with ngda tag returns true.""" + dataset_ngda = factories.Dataset( + name="dataset-ngda", title="Dataset NGDA", tags=[{"name": "nGda"}] + ) + dataset_non_ngda = factories.Dataset( + name="dataset-non-ngda", title="Dataset Non NGDA", tags=[{"name": "non-ngda"}] + ) + + assert helpers.is_tagged_ngda(dataset_ngda) is True + assert helpers.is_tagged_ngda(dataset_non_ngda) is False diff --git a/setup.py b/setup.py index 1eaad8c8..58fcfe99 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name="ckanext-datagovtheme", - version="0.2.7", + version="0.2.8", description="CKAN Extension to manage data.gov theme", long_description=long_description, classifiers=[