Skip to content

Commit

Permalink
Merge tag '4.3.1' into datapackage_tabular-data
Browse files Browse the repository at this point in the history
Release 4.3.1
  • Loading branch information
ridoo committed Oct 1, 2024
2 parents 0398af7 + 46f27dc commit 5324e2c
Show file tree
Hide file tree
Showing 20 changed files with 217 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ services:

# Geoserver backend
geoserver:
image: geonode/geoserver:2.24.3-v1
image: geonode/geoserver:2.24.4-v1
container_name: geoserver4${COMPOSE_PROJECT_NAME}
healthcheck:
test: "curl -m 10 --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null http://geoserver:8080/geoserver/ows"
Expand All @@ -105,7 +105,7 @@ services:
condition: service_healthy

data-dir-conf:
image: geonode/geoserver_data:2.24.3-v1
image: geonode/geoserver_data:2.24.4-v1
container_name: gsconf4${COMPOSE_PROJECT_NAME}
entrypoint: sleep infinity
volumes:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ services:

# Geoserver backend
geoserver:
image: geonode/geoserver:2.24.3-v1
image: geonode/geoserver:2.24.4-v1
container_name: geoserver4${COMPOSE_PROJECT_NAME}
healthcheck:
test: "curl -m 10 --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null http://geoserver:8080/geoserver/ows"
Expand All @@ -118,7 +118,7 @@ services:
condition: service_healthy

data-dir-conf:
image: geonode/geoserver_data:2.24.3-v1
image: geonode/geoserver_data:2.24.4-v1
container_name: gsconf4${COMPOSE_PROJECT_NAME}
entrypoint: sleep infinity
volumes:
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.9'
# Common Django template for GeoNode and Celery services below
x-common-django:
&default-common-django
image: geonode/geonode:4.3.0
image: geonode/geonode:4.3.1
#build:
# context: ./
# dockerfile: Dockerfile
Expand Down Expand Up @@ -91,7 +91,7 @@ services:

# Geoserver backend
geoserver:
image: geonode/geoserver:2.24.3-v1
image: geonode/geoserver:2.24.4-v1
container_name: geoserver4${COMPOSE_PROJECT_NAME}
healthcheck:
test: "curl -m 10 --fail --silent --write-out 'HTTP CODE : %{http_code}\n' --output /dev/null http://geoserver:8080/geoserver/ows"
Expand All @@ -117,7 +117,7 @@ services:
condition: service_healthy

data-dir-conf:
image: geonode/geoserver_data:2.24.3-v1
image: geonode/geoserver_data:2.24.4-v1
container_name: gsconf4${COMPOSE_PROJECT_NAME}
entrypoint: sleep infinity
volumes:
Expand Down
2 changes: 1 addition & 1 deletion geonode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import os

__version__ = (4, 3, 0, "post", 1)
__version__ = (4, 3, 1, 'final', 0)


def get_version():
Expand Down
34 changes: 34 additions & 0 deletions geonode/base/management/command_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import logging
from django.conf import settings

DEFAULT_COMMAND_LOGGER_NAME = "geonode.commands"


def setup_logger(logger_name=DEFAULT_COMMAND_LOGGER_NAME, formatter_name="command", handler_name="command"):
if logger_name not in settings.LOGGING["loggers"]:
format = "%(levelname)-7s %(asctime)s %(message)s"

settings.LOGGING["formatters"][formatter_name] = {
"format": format
}
settings.LOGGING["handlers"][handler_name] = {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": formatter_name
}
settings.LOGGING["loggers"][logger_name] = {
"handlers": [handler_name],
"level": "INFO",
"propagate": False
}

handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter(fmt=format))
handler.setLevel(logging.DEBUG)

logger = logging.getLogger(logger_name)
logger.addHandler(handler)
logger.setLevel(logging.INFO)
logger.propagate = False

return logger
1 change: 0 additions & 1 deletion geonode/br/management/commands/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ def execute_restore(self, **options):
self.restore_geoserver_vector_data(config, settings, target_folder, soft_reset)
self.restore_geoserver_externals(config, settings, target_folder)
logger.info("*** Recreate GWC tile layers")
call_command("create_tile_layers")
except Exception as e:
logger.warning(f"*** GeoServer Restore failed: {e}", exc_info=e)
if recovery_file:
Expand Down
Empty file.
Empty file.
126 changes: 126 additions & 0 deletions geonode/catalogue/management/commands/regenerate_xml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# -*- coding: utf-8 -*-
#########################################################################
#
# Copyright (C) 2023 OSGeo
#
# 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 3 of the License, or
# (at your option) any later version.
#
# 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, see <http://www.gnu.org/licenses/>.
#
#########################################################################

import logging

from django.core.management.base import BaseCommand

from geonode.base.management import command_utils
from geonode.base.models import ResourceBase
from geonode.layers.models import Dataset


logger = logging.getLogger(__name__)


class Command(BaseCommand):
help = "Re-create XML metadata documents"

def add_arguments(self, parser):
parser.add_argument(
'-l',
'--layer',
dest="layers",
action='append',
help="Only process specified layers ")

parser.add_argument(
"--skip-logger-setup",
action="store_false",
dest="setup_logger",
help='Skips setup of the "geonode.br" logger, "br" handler and "br" format if not present in settings',
)
parser.add_argument(
'-d',
'--dry-run',
dest="dry-run",
action='store_true',
help="Do not actually perform any change")

def handle(self, **options):
requested_layers = options.get('layers')
dry_run = options.get('dry-run')

if options.get("setup_logger"):
logger = command_utils.setup_logger()

logger.info(f"==== Running command {__name__}")
logger.info(f"{self.help}")
logger.info("")

logger.debug(f"DRY-RUN is {dry_run}")
logger.debug(f"LAYERS is {requested_layers}")

try:

layers = Dataset.objects.all()
tot = len(layers)
logger.info(f"Total layers in GeoNode: {tot}")
i = 0
cnt_ok = 0
cnt_bad = 0
cnt_skip = 0

instance: ResourceBase
for instance in layers:
i += 1
logger.info(f"- {i}/{tot} Processing layer {instance.id} [{instance.typename}] '{instance.title}'")

if requested_layers and instance.typename not in requested_layers:
logger.info(" - Layer filtered out by args")
cnt_skip += 1
continue

if instance.metadata_uploaded and instance.metadata_uploaded_preserve:
logger.info(" - Layer filtered out since it uses custom XML")
cnt_skip += 1
continue

try:
good = None
if not dry_run:
try:
try:
# the save() method triggers the metadata regeneration
instance.save()
good = True
except Exception as e:
logger.error(f"Error saving instance '{instance.title}': {e}")
raise e

except Exception as e:
logger.exception(f"Error processing '{instance.title}': {e}", e)

if dry_run or good:
logger.info(f" - Done {instance.name}")
cnt_ok += 1
else:
logger.warning(f"Metadata couldn't be regenerated for instance '{instance.title}' ")
cnt_bad += 1

except Exception as e:
raise e
except Exception as e:
raise e

logger.info("Work completed" + (" [DRYRUN]" if dry_run else ""))
logger.info(f"- Metadata regenerated : {cnt_ok}")
logger.info(f"- Metadata in error : {cnt_bad}")
logger.info(f"- Resources skipped : {cnt_skip}")
7 changes: 5 additions & 2 deletions geonode/catalogue/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,14 @@ def catalogue_post_save(instance, sender, **kwargs):
resource=resources.get(), url=metadata_url, extension="xml", link_type="metadata"
).update(**_d)

# generate an XML document (GeoNode's default is ISO)
if instance.metadata_uploaded and instance.metadata_uploaded_preserve:
md_doc = etree.tostring(dlxml.fromstring(instance.metadata_xml))
else:
md_doc = catalogue.catalogue.csw_gen_xml(instance, settings.CATALOG_METADATA_TEMPLATE)
# generate an XML document (GeoNode's default is ISO)
raw_xml = catalogue.catalogue.csw_gen_xml(instance, settings.CATALOG_METADATA_TEMPLATE)
md_obj = dlxml.fromstring(raw_xml, parser=etree.XMLParser(remove_blank_text=True))
md_doc = etree.tostring(md_obj, pretty_print=True, encoding="unicode")

try:
csw_anytext = catalogue.catalogue.csw_gen_anytext(md_doc)
except Exception as e:
Expand Down
3 changes: 3 additions & 0 deletions geonode/facets/providers/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def get_facet_items(
logger.debug("Filtering by keys %r", keys)
filters["group__id__in"] = keys

if topic_contains:
filters["group__name__icontains"] = topic_contains

visible_groups = get_user_visible_groups(user=kwargs["user"])

q = (
Expand Down
25 changes: 25 additions & 0 deletions geonode/facets/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,3 +669,28 @@ def test_group_facet_api_call(self):

self.assertDictEqual(expected_response_filtered, response_dict_filtered)
self.assertDictEqual(expected_response_base, response_dict_base)

def test_group_facets_are_filtered_by_words(self):
# there are some groups and the facets return them
url = f"{reverse('get_facet',args=['group'])}"

response = self.client.get(url)
self.assertEqual(200, response.status_code, response.json())

self.assertTrue(response.json().get("topics", {}).get("total", 0) > 0)

# topic_contains with real name should return 1
url = f"{reverse('get_facet',args=['group'])}?topic_contains=UserAdmin"
response = self.client.get(url)

self.assertEqual(200, response.status_code, response.json())

self.assertEqual(1, response.json().get("topics", {}).get("total", 0))

# topic_contains with a random string to be searched for should be 0
url = f"{reverse('get_facet',args=['group'])}?topic_contains=abc123scfuqbrwefbasascgiu"
response = self.client.get(url)

self.assertEqual(200, response.status_code, response.json())

self.assertEqual(0, response.json().get("topics", {}).get("total", 0))
2 changes: 1 addition & 1 deletion geonode/people/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@


class AllauthReCaptchaSignupForm(forms.Form):
captcha = ReCaptchaField()
captcha = ReCaptchaField(label=False)

def signup(self, request, user):
"""Required, or else it thorws deprecation warnings"""
Expand Down
4 changes: 4 additions & 0 deletions geonode/people/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class CustomSignupView(SignupView):
def get_context_data(self, **kwargs):
ret = super().get_context_data(**kwargs)
ret.update({"account_geonode_local_signup": settings.SOCIALACCOUNT_WITH_GEONODE_LOCAL_SINGUP})
# Push captcha field at the end
form = ret["form"]
form.field_order = [f for f in form.fields.keys() if f != "captcha"] + ["captcha"]
form.order_fields(form.field_order)
return ret


Expand Down
4 changes: 2 additions & 2 deletions geonode/proxy/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class Response:
"Vary": "Authorization, Accept-Language, Cookie, origin",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Referrer-Policy": "same-origin",
"Referrer-Policy": "strict-origin-when-cross-origin",
"Cross-Origin-Opener-Policy": "same-origin",
"X-Frame-Options": "SAMEORIGIN",
"Content-Language": "en",
Expand All @@ -236,7 +236,7 @@ class Response:
"Vary": "Authorization, Accept-Language, Cookie, origin",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Referrer-Policy": "same-origin",
"Referrer-Policy": "strict-origin-when-cross-origin",
"X-Frame-Options": "SAMEORIGIN",
"Content-Language": "en-us",
"Content-Length": "119",
Expand Down
1 change: 1 addition & 0 deletions geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@
SECURE_SSL_REDIRECT = ast.literal_eval(os.environ.get("SECURE_SSL_REDIRECT", "False"))
SECURE_HSTS_SECONDS = int(os.getenv("SECURE_HSTS_SECONDS", "3600"))
SECURE_HSTS_INCLUDE_SUBDOMAINS = ast.literal_eval(os.environ.get("SECURE_HSTS_INCLUDE_SUBDOMAINS", "True"))
SECURE_REFERRER_POLICY = os.environ.get("SECURE_REFERRER_POLICY", "strict-origin-when-cross-origin")

# Replacement of the default authentication backend in order to support
# permissions per object.
Expand Down
3 changes: 2 additions & 1 deletion geonode/templates/account/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ <h2>{% trans "Sign up" %}</h2>
<script type="text/javascript">
$(document).ready(function() {
$('#id_username').focus();
});
$('#id_captcha').removeClass('form-control');
});
</script>
{% endblock %}
4 changes: 2 additions & 2 deletions geonode/templates/owner_rights_request.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% load i18n %}
{% load bootstrap_tags %}

{% block title %}{% trans "Request perission" %} {% endblock %}
{% block title %}{% trans "Request permission" %} {% endblock %}
{% block body %}
<h3>{% trans "Request editing for resource: " %} {{ resource.title }}</h3>
<a href="{{ resource.get_absolute_url }}" class="btn btn-primary" type="button">{% trans "Back to resource" %}</a>
Expand All @@ -16,4 +16,4 @@ <h3>{% trans "Request editing for resource: " %} {{ resource.title }}</h3>
<input type="submit" value="{% trans "Send request" %}" class="btn btn-primary" type="button"/>
</div>
</form>
{% endblock %}
{% endblock %}
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ Markdown==3.6
geonode-pinax-notifications==6.0.0.2

# GeoNode org maintained apps.
django-geonode-mapstore-client==4.3.0
geonode-importer==1.0.9
django-geonode-mapstore-client==4.3.1
geonode-importer==1.0.10
django-avatar==8.0.0
geonode-oauth-toolkit==2.2.2.2
geonode-user-messages==2.0.2.2
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ install_requires =
geonode-pinax-notifications==6.0.0.2

# GeoNode org maintained apps.
django-geonode-mapstore-client==4.3.0
geonode-importer==1.0.9
django-geonode-mapstore-client==4.3.1
geonode-importer==1.0.10
django-avatar==8.0.0
geonode-oauth-toolkit==2.2.2.2
geonode-user-messages==2.0.2.2
Expand Down

0 comments on commit 5324e2c

Please sign in to comment.