Skip to content

Commit

Permalink
Merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiagiupponi committed May 3, 2021
2 parents 333125a + 5546ef3 commit fa000dc
Show file tree
Hide file tree
Showing 23 changed files with 275 additions and 151 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change Log

## [3.2.0](https://github.com/GeoNode/geonode/tree/3.2.0) (2021-04)
## [3.2.0](https://github.com/GeoNode/geonode/tree/3.2.0) (2021-04-29)
### Breaking Changes

- Bump to postgresql-13; *do not upgrade the docker image or be prepared to do a dump/restore of the DB*
Expand Down Expand Up @@ -117,6 +117,7 @@
- **[Full list of Fixed Minor Issues](https://github.com/GeoNode/geonode/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aclosed+milestone%3A3.2+label%3Aminor)**
- **[Full list of Updated Translations](https://github.com/GeoNode/geonode/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aclosed+milestone%3A3.2+label%3Atranslations)**
- **[All Closed Issues](https://github.com/GeoNode/geonode/issues?q=is%3Aissue+is%3Aclosed+milestone%3A3.2)**

### Full Changelog

[https://github.com/GeoNode/geonode/compare/3.1...3.2.0](https://github.com/GeoNode/geonode/compare/3.1...3.2.x)
Expand Down
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
GeoNode is distributed under the GNU General Public License Version 2.0 license:

GeoNode, open geospatial information server
Copyright (C) 2014-2020 Open Source Geospatial Foundation.
Copyright (C) 2001-2014 OpenPlans

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version (collectively, "GPL").

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA

For latest contact information of Open Source Geospatial Foundation see the website at
http://www.osgeo.org. Current email is [email protected] and address is OSGeo, 14525 SW Millikan #42523, Beaverton, Oregon, United States, 97005-2343.

The full GPL license is available in this directory in the file GPL.txt
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include README README.rst LICENSE requirements.txt
include README README.rst README.md LICENSE requirements.txt
recursive-exclude geonode/static/.components
recursive-include geonode *.css *.eot *.gif *.html *.ico *.ini *.jpg *.js *.json *.less *.md *.mo *.po *.otf *.png *.rst *.sample *.svg *.swf *.ttf *.txt *.woff *.woff2 *.xml *.xsl README
recursive-include geonode/contrib/geosites gunicorn nginx
26 changes: 13 additions & 13 deletions geonode/base/management/commands/dump_thesaurus.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,42 +96,42 @@ def dump_thesaurus(self, name):
'dcterms': DCTERMS_URI
}

root = etree.Element(RDF_NS + 'RDF', nsmap=ns)
concept_scheme = etree.SubElement(root, SKOS_NS + 'ConceptScheme')
concept_scheme.set(RDF_NS + 'about', thesaurus.about)
root = etree.Element(f"{RDF_NS}RDF", nsmap=ns)
concept_scheme = etree.SubElement(root, f"{SKOS_NS}ConceptScheme")
concept_scheme.set(f"{RDF_NS}about", thesaurus.about)

# Default title
# <dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">GEMET - INSPIRE themes, version 1.0</dc:title>
title = etree.SubElement(concept_scheme, DC_NS + 'title')
title = etree.SubElement(concept_scheme, f"{DC_NS}title")
title.text = thesaurus.title

# Localized titles
# <dc:title xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">Limitations on public access</dc:title>
for ltitle in ThesaurusLabel.objects.filter(thesaurus=thesaurus).all():
title = etree.SubElement(concept_scheme, DC_NS + 'title')
title.set(XML_NS + "lang", ltitle.lang)
title = etree.SubElement(concept_scheme, f"{DC_NS}title")
title.set(f"{XML_NS}lang", ltitle.lang)
title.text = ltitle.label

d = etree.SubElement(concept_scheme, DCTERMS_NS + 'issued')
d = etree.SubElement(concept_scheme, f"{DCTERMS_NS}issued")
d.text = thesaurus.date
d = etree.SubElement(concept_scheme, DCTERMS_NS + 'modified')
d = etree.SubElement(concept_scheme, f"{DCTERMS_NS}modified")
d.text = thesaurus.date

# Concepts
for keyword in ThesaurusKeyword.objects.filter(thesaurus=thesaurus).all():
concept = etree.SubElement(concept_scheme, SKOS_NS + 'Concept')
concept = etree.SubElement(concept_scheme, f"{SKOS_NS}Concept")
if keyword.about:
concept.set(RDF_NS + 'about', keyword.about)
concept.set(f"{RDF_NS}about", keyword.about)

if keyword.alt_label:
# <skos:altLabel>cp</skos:altLabel>
label = etree.SubElement(concept, SKOS_NS + 'altLabel')
label = etree.SubElement(concept, f"{SKOS_NS}altLabel")
label.text = keyword.alt_label

for label in ThesaurusKeywordLabel.objects.filter(keyword=keyword).all():
# <skos:prefLabel xml:lang="en">Geographical grid systems</skos:prefLabel>
pref_label = etree.SubElement(concept, SKOS_NS + 'prefLabel')
pref_label.set(XML_NS + 'lang', label.lang)
pref_label = etree.SubElement(concept, f"{SKOS_NS}prefLabel")
pref_label.set(f"{XML_NS}lang", label.lang)
pref_label.text = label.label

etree.dump(root, pretty_print=True)
54 changes: 27 additions & 27 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,11 +604,15 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
VALID_DATE_TYPES = [(x.lower(), _(x))
for x in ['Creation', 'Publication', 'Revision']]

abstract_help_text = _(
'brief narrative summary of the content of the resource(s)')
date_help_text = _('reference date for the cited resource')
date_type_help_text = _('identification of when a given event occurred')
edition_help_text = _('version of the cited resource')
abstract_help_text = _(
'brief narrative summary of the content of the resource(s)')
attribution_help_text = _(
'authority or function assigned, as to a ruler, legislative assembly, delegate, or the like.')
doi_help_text = _(
'a DOI will be added by Admin before publication.')
purpose_help_text = _(
'summary of the intentions with which the resource(s) was developed')
maintenance_frequency_help_text = _(
Expand Down Expand Up @@ -640,24 +644,21 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
data_quality_statement_help_text = _(
'general explanation of the data producer\'s knowledge about the lineage of a'
' dataset')
doi_help_text = _(
'a DOI will be added by Admin before publication.')
doi = models.CharField(
_('DOI'),
max_length=255,
# internal fields
uuid = models.CharField(max_length=36)
title = models.CharField(_('title'), max_length=255, help_text=_(
'name by which the cited resource is known'))
abstract = models.TextField(
_('abstract'),
max_length=2000,
blank=True,
help_text=abstract_help_text)
purpose = models.TextField(
_('purpose'),
max_length=500,
null=True,
help_text=doi_help_text)
attribution_help_text = _(
'authority or function assigned, as to a ruler, legislative assembly, delegate, or the like.')
attribution = models.CharField(
_('Attribution'),
max_length=2048,
blank=True,
null=True,
help_text=attribution_help_text)
# internal fields
uuid = models.CharField(max_length=36)
help_text=purpose_help_text)
owner = models.ForeignKey(
settings.AUTH_USER_MODEL,
blank=True,
Expand All @@ -668,8 +669,6 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
contacts = models.ManyToManyField(
settings.AUTH_USER_MODEL,
through='ContactRole')
title = models.CharField(_('title'), max_length=255, help_text=_(
'name by which the cited resource is known'))
alternate = models.CharField(max_length=128, null=True, blank=True)
date = models.DateTimeField(
_('date'),
Expand All @@ -687,17 +686,18 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
blank=True,
null=True,
help_text=edition_help_text)
abstract = models.TextField(
_('abstract'),
max_length=2000,
attribution = models.CharField(
_('Attribution'),
max_length=2048,
blank=True,
help_text=abstract_help_text)
purpose = models.TextField(
_('purpose'),
max_length=500,
null=True,
help_text=attribution_help_text)
doi = models.CharField(
_('DOI'),
max_length=255,
blank=True,
help_text=purpose_help_text)
null=True,
help_text=doi_help_text)
maintenance_frequency = models.CharField(
_('maintenance frequency'),
max_length=255,
Expand Down
44 changes: 22 additions & 22 deletions geonode/base/templates/base/_resourcebase_info_panel.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% load i18n %}
{% block content %}
{% load thesaurus %}

<dl class="dl-horizontal">
{% if resource.title %}
Expand Down Expand Up @@ -54,30 +55,29 @@
<dd>{{ resource.display_type }}</dd>
{% endif %}

{% if resource.keywords.count > 0 or resource.tkeywords.count > 0 %}
{% if resource.keywords.count > 0 or resource.tkeywords.count > 0 %}
<dt>{% trans "Keywords" %}</dt>
<dd itemprop="keywords">
{% for keyword in resource.keywords.all %}
<a itemscope itemtype="http://schema.org/Text" href="{% url "search" %}?keywords__slug__in={{ keyword.slug }}" >
{{ keyword.name }}
</a>
{% if not forloop.last %},{% endif %}
{% endfor %}
{% if THESAURI_FILTERS %}
{% if resource.tkeywords.count > 0 %}
{% get_current_language as LANGUAGE_CODE %}
{% for keyword in resource.tkeywords.all %}
<a itemscope itemtype="http://schema.org/Text" href="{% url "search" %}?tkeywords__id__in={{ keyword.id }}">
{% for label in keyword.labels %}
{% if forloop.first %},{% endif %}
{% if label.lang == LANGUAGE_CODE %}
{{ label }}
{% endif %}
{% endfor %}
</a>
{% endfor %}
{% endif %}
{% endif %}
<ul>
{% for keyword in resource.keywords.all %}
<li>
<a itemscope itemtype="http://schema.org/Text" href="{% url "search" %}?keywords__slug__in={{ keyword.slug }}" >
{{ keyword.name }}
</a>
</li>
{% endfor %}
{% for tid in resource.tkeywords.all|get_unique_thesaurus_set %}
<li>{{ tid|get_thesaurus_translation_by_id }}
{% for tkeywords in resource.tkeywords.all %}
<ul>
{% if tid == tkeywords.thesaurus.id %}
<li><a itemscope itemtype="http://schema.org/Text" href="{% url "search" %}?tkeywords__id__in={{ tkeywords.id }}">{{tkeywords|get_thesaurus_localized_label}}</a></li>
{% endif %}
</ul>
{% endfor %}
</li>
{% endfor %}
</ul>
</dd>
{% endif %}

Expand Down
23 changes: 22 additions & 1 deletion geonode/base/templatetags/thesaurus.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.core.exceptions import ObjectDoesNotExist
from django import template
from django.utils.translation import get_language
from geonode.base.models import Thesaurus, ThesaurusLabel
from geonode.base.models import Thesaurus, ThesaurusKeywordLabel, ThesaurusLabel

register = template.Library()

Expand Down Expand Up @@ -35,3 +35,24 @@ def get_name_translation(tidentifier):
if not lname:
return available.first().title
return lname.first()


@register.filter
def get_thesaurus_translation_by_id(id):
available = Thesaurus.objects.filter(id=id)
if not available.exists():
raise ObjectDoesNotExist("Selected idenfifier does not exists")
return get_name_translation(available.first().identifier)


@register.filter
def get_thesaurus_localized_label(tkeyword):
lang = get_language()
translation = (
ThesaurusKeywordLabel.objects.values_list("label", flat=True)
.filter(keyword__id=tkeyword.id)
.filter(lang=lang)
)
if not translation:
return tkeyword.alt_label
return translation.first()
17 changes: 16 additions & 1 deletion geonode/base/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
from geonode.base.models import CuratedThumbnail
from geonode.base.templatetags.base_tags import get_visibile_resources, facets
from geonode.base.templatetags.thesaurus import (
get_name_translation, get_unique_thesaurus_set,
get_name_translation, get_thesaurus_localized_label, get_thesaurus_translation_by_id, get_unique_thesaurus_set,
get_thesaurus_title,
get_thesaurus_date,
)
Expand Down Expand Up @@ -898,6 +898,21 @@ def test_get_name_translation_return_thesauro_title_if_label_for_selected_langua
expected = "GEMET - INSPIRE themes, version 1.0"
self.assertEqual(expected, actual)

@patch('geonode.base.templatetags.thesaurus.get_language')
def test_get_thesaurus_translation_by_id(self, lang):
lang.return_value = 'it'
actual = get_thesaurus_translation_by_id(1)
expected = "Tema GEMET - INSPIRE, versione 1.0"
self.assertEqual(expected, actual)

@patch('geonode.base.templatetags.thesaurus.get_language')
def test_get_thesaurus_localized_label(self, lang):
lang.return_value = 'de'
keyword = ThesaurusKeyword.objects.get(id=1)
actual = get_thesaurus_localized_label(keyword)
expected = "Adressen"
self.assertEqual(expected, actual)

@patch('geonode.base.templatetags.thesaurus.get_language')
def test_get_name_translation_return_label_title_if_label_for_selected_language_exists(self, lang):
lang.return_value = 'it'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ <h2 class="page-title">{% trans "Edit Metadata" %}</h2>
{% for field in document_form %}
{% if field.name != 'use_featureinfo_custom_template' and field.name != 'featureinfo_custom_template' and field.name not in ADVANCED_EDIT_EXCLUDE_FIELD %}
<div class="form_item_spacing">
<div {% if field.name in UI_MANDATORY_FIELDS %} id='adv_req' {% else %}{% endif %} >
<span><label for="{{ field.id }}">{{ field.label }}</label></span>
<div {% if field.auto_id in UI_MANDATORY_FIELDS %} id='adv_req' {% else %}{% endif %} >
<span><label for="{{ field.auto_id }}">{{ field.label }}</label></span>
{{ field }}
</div>
</div>
Expand Down
32 changes: 21 additions & 11 deletions geonode/documents/templates/layouts/doc_panels.html
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,15 @@
<div class="advanced-hint progress-bar" role="progressbar" style="width:34%">
{% trans "Mandatory" %}
</div>
<div class="progress-bar" role="progressbar" style="width:33%">
{% trans "Optional" %}
</div>
{% if UI_REQUIRED_FIELDS %}
<div class="metadata-hint progress-bar" role="progressbar" style="width:33%">
{% trans "Mandatory" %}
</div>
{% else %}
<div class="progress-bar" role="progressbar" style="width:33%">
{% trans "Optional" %}
</div>
{% endif %}
</div>
<ul class="wizard--progress wizard--progress--medium">
<li data-step="1" id="first" class="is-active" data-toggle="tab" href="#mandatory">
Expand All @@ -249,7 +255,11 @@
<a>{% trans "Location and Licenses" %}</a>
</li>
<li data-step="3" data-toggle="tab" href="#ownership">
<a>{% trans "Optional Metadata" %}</a>
{% if UI_REQUIRED_FIELDS %}
<a>{% trans "Required Metadata" %}</a>
{% else %}
<a>{% trans "Optional Metadata" %}</a>
{% endif %}
</li>
</ul>
{% block mandatory %}
Expand Down Expand Up @@ -414,12 +424,6 @@
{{ document_form.license }}
</div>
{% endblock doc_license %}
{% block doc_doi %}
<div>
<span><label for="{{ document_form.doi|id }}">{{ document_form.doi.label }}</label></span>
{{ document_form.doi }}
</div>
{% endblock doc_doi %}
{% block doc_attribution %}
<div>
<span><label for="{{ document_form.attribution|id }}">{{ document_form.attribution.label }}</label></span>
Expand Down Expand Up @@ -471,7 +475,7 @@
{% block ownership %}
<div id="ownership" class="tab-pane fade">
<div class="panel-group"><div class="panel panel-default"><div class="panel-body">
<div>
<div id="mdinfo">
<div class="col-xs-12 col-lg-4">
<p>{% trans "Other, Optional, Metadata" %}</p>
{% block doc_edition %}
Expand All @@ -481,6 +485,12 @@
{{ document_form.edition }}
</div>
{% endblock doc_edition %}
{% block doc_doi %}
<div>
<span><label for="{{ document_form.doi|id }}">{{ document_form.doi.label }}</label></span>
{{ document_form.doi }}
</div>
{% endblock doc_doi %}
{% block doc_purpose %}
<div>
<span><label for="{{ document_form.purpose|id }}">{{ document_form.purpose.label }}</label></span>
Expand Down
Loading

0 comments on commit fa000dc

Please sign in to comment.