Skip to content

Commit

Permalink
Merge tag '4.2.2' into 52n-prepare-4.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ridoo committed Feb 28, 2024
2 parents ccdddc0 + 6128b84 commit 0fd07d2
Show file tree
Hide file tree
Showing 43 changed files with 102 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
python-version: ${{matrix.python-version}}

- name: Install flake8 & black
run: pip install flake8 black
run: pip install --upgrade $(grep 'flake8\|black' requirements.txt)

- name: "Check: flake8"
run: |
Expand Down
6 changes: 2 additions & 4 deletions create-envfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ def _get_vals_to_replace(args):
_vals_to_replace["letsencrypt_mode"] = (
"disabled"
if not _vals_to_replace.get("https_host")
else "staging"
if _jsfile.get("env_type", args.env_type) in ["test"]
else "production"
else "staging" if _jsfile.get("env_type", args.env_type) in ["test"] else "production"
)
_vals_to_replace["debug"] = False if _jsfile.get("env_type", args.env_type) in ["prod", "test"] else True
_vals_to_replace["email"] = _jsfile.get("email", args.email)
Expand Down Expand Up @@ -124,7 +122,7 @@ def _get_vals_to_replace(args):
prog="ENV file builder",
description="Tool for generate environment file automatically. The information can be passed or via CLI or via JSON file ( --file /path/env.json)",
usage="python create-envfile.py localhost -f /path/to/json/file.json",
allow_abbrev=False
allow_abbrev=False,
)
parser.add_argument(
"--noinput",
Expand Down
2 changes: 1 addition & 1 deletion 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.23.3-v1
image: geonode/geoserver:2.23.3-v2
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 Down
2 changes: 1 addition & 1 deletion 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.23.3-v1
image: geonode/geoserver:2.23.3-v2
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 Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ services:

# Geoserver backend
geoserver:
image: geonode/geoserver:2.23.3-v1
image: geonode/geoserver:2.23.3-v2
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 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, 2, 0, "dev", 0)
__version__ = (4, 2, 2, "final", 0)


default_app_config = "geonode.apps.AppConfig"
Expand Down
6 changes: 0 additions & 6 deletions geonode/api/resourcebase_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ def hydrate_title(self, bundle):


class ResourceBaseResource(CommonModelApi):

"""ResourceBase api"""

class Meta(CommonMetaApi):
Expand All @@ -607,7 +606,6 @@ class Meta(CommonMetaApi):


class FeaturedResourceBaseResource(CommonModelApi):

"""Only the featured resourcebases"""

class Meta(CommonMetaApi):
Expand All @@ -620,7 +618,6 @@ class Meta(CommonMetaApi):


class LayerResource(CommonModelApi):

"""Dataset API"""

links = fields.ListField(attribute="links", null=True, use_in="all", default=[])
Expand Down Expand Up @@ -756,7 +753,6 @@ class Meta(CommonMetaApi):


class MapResource(CommonModelApi):

"""Maps API"""

def build_filters(self, filters=None, ignore_bad_filters=False, **kwargs):
Expand Down Expand Up @@ -822,7 +818,6 @@ class Meta(CommonMetaApi):


class GeoAppResource(CommonModelApi):

"""GeoApps API"""

def format_objects(self, objects):
Expand Down Expand Up @@ -874,7 +869,6 @@ class Meta(CommonMetaApi):


class DocumentResource(CommonModelApi):

"""Documents API"""

def build_filters(self, filters=None, ignore_bad_filters=False, **kwargs):
Expand Down
1 change: 0 additions & 1 deletion geonode/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ def test_tags_lockdown(self):


class SearchApiTests(ResourceTestCaseMixin, GeoNodeBaseTestSupport):

"""Test the search"""

# loading test thesausuri and initial data
Expand Down
5 changes: 0 additions & 5 deletions geonode/base/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@


class IsSelf(permissions.BasePermission):

"""Grant permission only if the current instance is the request user.
Used to allow users to edit their own account, nothing to others (even
superusers).
Expand All @@ -62,7 +61,6 @@ def has_object_permission(self, request, view, obj):


class IsSelfOrReadOnly(IsSelf):

"""Grant permissions if instance *IS* the request user, or read-only.
Used to allow users to edit their own account, and others to read.
"""
Expand All @@ -75,7 +73,6 @@ def has_object_permission(self, request, view, obj):


class IsSelfOrAdmin(IsSelf):

"""Grant R/W to self and superusers/staff members. Deny others."""

def has_permission(self, request, view):
Expand All @@ -94,7 +91,6 @@ def has_object_permission(self, request, view, obj):


class IsSelfOrAdminOrReadOnly(IsSelfOrAdmin):

"""Grant R/W to self and superusers/staff members, R/O to others."""

def has_permission(self, request, view):
Expand All @@ -111,7 +107,6 @@ def has_object_permission(self, request, view, obj):


class IsSelfOrAdminOrAuthenticatedReadOnly(IsSelfOrAdmin):

"""Grant R/W to self and superusers/staff members, R/O to auth."""

def has_object_permission(self, request, view, obj):
Expand Down
2 changes: 1 addition & 1 deletion geonode/base/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ class Meta:
"is_copyable",
"blob",
"metadata",
"executions"
"executions",
# TODO
# csw_typename, csw_schema, csw_mdsource, csw_insert_date, csw_type, csw_anytext, csw_wkt_geometry,
# metadata_uploaded, metadata_uploaded_preserve, metadata_xml,
Expand Down
1 change: 0 additions & 1 deletion geonode/base/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ def build_attrs(self, base_attrs=None, extra_attrs=None, **kwargs):


class ResourceBaseForm(TranslationModelForm, LinkedResourceForm):

"""Base form for metadata, should be inherited by childres classes of ResourceBase"""

abstract = forms.CharField(label=_("Abstract"), required=False, widget=TinyMCE())
Expand Down
1 change: 0 additions & 1 deletion geonode/base/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def test_add_missing_metadata_author_or_poc(self):


class TestCreationOfContactRolesByDifferentInputTypes(ThumbnailTests):

"""
Test that contact roles can be set as people profile
"""
Expand Down
73 changes: 60 additions & 13 deletions geonode/br/management/commands/create_tile_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
</metaWidthHeight>
<mimeFormats>
<string>application/json;type=utfgrid</string>
<string>image/gif</string>
<string>image/jpeg</string>
<string>image/png</string>
<string>image/png8</string>
<string>image/vnd.jpeg-png</string>
<string>image/jpeg</string>
<string>image/vnd.jpeg-png8</string>
<string>image/gif</string>
<string>image/png8</string>
</mimeFormats>
<gridSubsets>
<gridSubset>
Expand All @@ -66,16 +66,48 @@
<gridSetName>EPSG:900913</gridSetName>
</gridSubset>
</gridSubsets>
<expireCache>0</expireCache>
<expireClients>0</expireClients>
<autoCacheStyles>true</autoCacheStyles>
<gutter>0</gutter>
<cacheWarningSkips/>
</GeoServerLayer>"""


class Command(BaseCommand):
help = "Create missing TileLayers in GWC"

def add_arguments(self, parser):
pass
parser.add_argument(
'-f',
'--force',
dest="force",
action='store_true',
help="Force tile layer re-creation also if it already exists in GWC")

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

parser.add_argument(
'-d',
'--dry-run',
dest="dry-run",
action='store_true',
help="Do not actually perform any change on GWC")

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

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

try:
baseurl = settings.OGC_SERVER["default"]["LOCATION"]
user = settings.OGC_SERVER["default"]["USER"]
Expand All @@ -91,24 +123,38 @@ def handle(self, **options):
cnt_old = 0
cnt_new = 0
cnt_bad = 0
cnt_skip = 0
cnt_force = 0
for layer in layers:
i += 1
logger.info(f"- {i}/{tot} Processing layer: {layer.typename}")

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

r = requests.get(f"{baseurl}gwc/rest/layers/{layer.typename}.xml", auth=HTTPBasicAuth(user, passwd))

if r.status_code == 200:
logger.info(" - Layer already configured")
cnt_old += 1
continue
if force:
logger.info(" - Forcing layer configuration in GWC")
cnt_force += 1
else:
logger.info(" - Layer already configured in GWC")
cnt_old += 1
continue
try:
data = REQ_TEMPLATE.format(layer.name)
url = f"{baseurl}gwc/rest/layers/{layer.typename}.xml"
logger.info(" - Configuring...")
response = requests.put(
url, data=data, headers={"Content-Type": "text/xml"}, auth=HTTPBasicAuth(user, passwd)
)

if response.status_code == 200:
if not dry_run:
response = requests.put(
url, data=data, headers={"Content-Type": "text/xml"}, auth=HTTPBasicAuth(user, passwd)
)

if dry_run or response.status_code == 200:
logger.info(f" - Done {layer.name}")
cnt_new += 1
else:
Expand All @@ -121,6 +167,7 @@ def handle(self, **options):
raise e

logger.info("Work completed")
logger.info(f"- TileLayers configured: {cnt_new}")
logger.info(f"- TileLayers configured: {cnt_new}" + (f" (forced {cnt_force})" if cnt_force else ""))
logger.info(f"- TileLayers in error : {cnt_bad}")
logger.info(f"- TileLayers found : {cnt_old}")
logger.info(f"- TileLayers untouched : {cnt_old}")
logger.info(f"- TileLayers skipped : {cnt_skip}")
1 change: 0 additions & 1 deletion geonode/catalogue/metadataxsl/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


class MetadataXSLTest(GeoNodeBaseTestSupport):

"""
Tests geonode.catalogue.metadataxsl app/module
"""
Expand Down
18 changes: 10 additions & 8 deletions geonode/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,17 @@ def resource_urls(request):
EXIF_ENABLED=getattr(settings, "EXIF_ENABLED", False),
FAVORITE_ENABLED=getattr(settings, "FAVORITE_ENABLED", False),
SEARCH_FILTERS=getattr(settings, "SEARCH_FILTERS", False),
THESAURI_FILTERS=[
t["name"]
for t in [
settings.THESAURUS,
THESAURI_FILTERS=(
[
t["name"]
for t in [
settings.THESAURUS,
]
if t.get("filter")
]
if t.get("filter")
]
if hasattr(settings, "THESAURUS")
else [t.identifier for t in thesaurus],
if hasattr(settings, "THESAURUS")
else [t.identifier for t in thesaurus]
),
MAP_CLIENT_USE_CROSS_ORIGIN_CREDENTIALS=getattr(settings, "MAP_CLIENT_USE_CROSS_ORIGIN_CREDENTIALS", False),
SHOW_PROFILE_EMAIL=getattr(settings, "SHOW_PROFILE_EMAIL", False),
OGC_SERVER=getattr(settings, "OGC_SERVER", None),
Expand Down
1 change: 0 additions & 1 deletion geonode/documents/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ class DocumentDescriptionForm(forms.Form):


class DocumentCreateForm(TranslationModelForm):

"""
The document upload form.
"""
Expand Down
1 change: 0 additions & 1 deletion geonode/documents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@


class Document(ResourceBase):

"""
A document is any kind of information that can be attached to a map such as pdf, images, videos, xls...
"""
Expand Down
8 changes: 5 additions & 3 deletions geonode/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,11 @@ def document_metadata(
category_form = CategoryForm(
request.POST,
prefix="category_choice_field",
initial=int(request.POST["category_choice_field"])
if "category_choice_field" in request.POST and request.POST["category_choice_field"]
else None,
initial=(
int(request.POST["category_choice_field"])
if "category_choice_field" in request.POST and request.POST["category_choice_field"]
else None
),
)

if hasattr(settings, "THESAURUS"):
Expand Down
1 change: 0 additions & 1 deletion geonode/geoapps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@


class GeoApp(ResourceBase):

"""
A GeoApp it is a generic container for every client applications the
user might want to create or define.
Expand Down
1 change: 0 additions & 1 deletion geonode/geoapps/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@


class GeoAppTests(GeoNodeBaseTestSupport):

"""Tests geonode.geoapps module"""

fixtures = ["initial_data.json", "group_test_data.json", "default_oauth_apps.json"]
Expand Down
Loading

0 comments on commit 0fd07d2

Please sign in to comment.