Skip to content

Commit

Permalink
Merge pull request #176 from GSA/ngda
Browse files Browse the repository at this point in the history
Ngda
  • Loading branch information
jbrown-xentity authored Nov 30, 2023
2 parents 0449c3f + 4a11a2c commit 7df2949
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 6 deletions.
81 changes: 78 additions & 3 deletions ckanext/datagovtheme/fanstatic_library/styles/datagovtheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions ckanext/datagovtheme/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions ckanext/datagovtheme/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions ckanext/datagovtheme/public/css/datagovtheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions ckanext/datagovtheme/templates/snippets/package_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ <h3 class="dataset-heading">
{% elif package.get('state', '').startswith('deleted') %}
<span class="label {{ 'label-danger' }}">{{ _('Deleted') }}</span>
{% endif %}

{% if h.is_tagged_ngda(package) %}
<span class="tagged-ngda btn btn-arrow-left">
{{ _('NGDA') }}
</span>
{% endif %}

{{ h.popular('recent views', package.tracking_summary.recent, min=10) if package.tracking_summary }}
</h3>
<div class="notes">
Expand Down
19 changes: 19 additions & 0 deletions ckanext/datagovtheme/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

from ckanext.datagovtheme import helpers
import ckan.tests.factories as factories


################
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down

0 comments on commit 7df2949

Please sign in to comment.