Skip to content

Commit

Permalink
[Resolves #7366] Upgrade from Django 2.2 to 3.2 (#7373)
Browse files Browse the repository at this point in the history
* [Resolves #7366] Upgrade to Django 3.2

* [Resolves #7366] Upgrade to Django 3.2, fix static function for thumbnail and requirements

* [Resolves #7366] Upgrade to Django 3.2, fix static function for thumbnail and requirements

* [Resolves #7366] Upgrade to Django 3.2, remove unused libraries

* [Resolves #7366] Upgrade to Django 3.2, remove unused libraries

* [Resolves #7366] Upgrade to Django 3.2, fix unwanted change

* [Resolves #7366] Upgrade to Django 3.2, flake8 syntax

* [Resolves #7366] Upgrade to Django 3.2, fix setup.cfg

* [Resolves #7366] Upgrade to Django 3.2, fix requirements

* [Resolves #7366] Upgrade to Django 3.2, fix requirements and PR comments

* [Resolves #7366] Upgrade to Django 3.2, fix requirements forcing auth-ldap lib

* [Resolves #7366] Upgrade to Django 3.2, fix requirements forcing auth-ldap lib

* [Resolves #7366] Upgrade to Django 3.2, fix requirements forcing libs

* [Fixes #7366] change dep for contrib

* merge with master

* [Fixes #7366] Extraction of TimeKeeper and NullTimeKeeper

* [Fixes #7366] Fix render function

* [Resolves #7366] Rollback dockerfile

* [Resolves #7366] Change default AUTO_FIELD

* Bump dynamic-rest to version 2.0.1

* - Fixes upload issues with decorator

* Bump django-geonode-mapstore-client to version >=2.1.5

Co-authored-by: afabiani <[email protected]>
  • Loading branch information
mattiagiupponi and afabiani authored May 17, 2021
1 parent d3bfda5 commit 16bce71
Show file tree
Hide file tree
Showing 85 changed files with 209 additions and 126 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ HAYSTACK_ENGINE_URL=http://elasticsearch:9200/
HAYSTACK_ENGINE_INDEX_NAME=haystack
HAYSTACK_SEARCH_RESULTS_PER_PAGE=200


# #################
# nginx
# HTTPD Server
Expand Down
2 changes: 1 addition & 1 deletion .env_dev
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CACHE_BUSTING_STATIC_ENABLED=False
CACHE_BUSTING_MEDIA_ENABLED=False

MEMCACHED_ENABLED=False
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
MEMCACHED_BACKEND=django.core.cache.backends.memcached.PyMemcacheCache
MEMCACHED_LOCATION=127.0.0.1:11211
MEMCACHED_LOCK_EXPIRE=3600
MEMCACHED_LOCK_TIMEOUT=10
Expand Down
2 changes: 1 addition & 1 deletion .env_test
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CACHE_BUSTING_STATIC_ENABLED=False
CACHE_BUSTING_MEDIA_ENABLED=False

MEMCACHED_ENABLED=False
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
MEMCACHED_BACKEND=django.core.cache.backends.memcached.PyMemcacheCache
MEMCACHED_LOCATION=127.0.0.1:11211
MEMCACHED_LOCK_EXPIRE=3600
MEMCACHED_LOCK_TIMEOUT=10
Expand Down
4 changes: 2 additions & 2 deletions geonode/api/resourcebase_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from django.db.models import Q
from django.http import HttpResponse
from django.conf import settings
from django.contrib.staticfiles.templatetags import staticfiles
from django.templatetags.static import static
from tastypie.authentication import MultiAuthentication, SessionAuthentication
from tastypie.bundle import Bundle

Expand Down Expand Up @@ -574,7 +574,7 @@ def format_objects(self, objects):
formatted_obj['site_url'] = settings.SITEURL

if formatted_obj['thumbnail_url'] and len(formatted_obj['thumbnail_url']) == 0:
formatted_obj['thumbnail_url'] = staticfiles.static(settings.MISSING_THUMBNAIL)
formatted_obj['thumbnail_url'] = static(settings.MISSING_THUMBNAIL)

formatted_obj['owner__username'] = obj.owner.username
formatted_obj['owner_name'] = obj.owner.get_full_name() or obj.owner.username
Expand Down
3 changes: 0 additions & 3 deletions geonode/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,3 @@ class BaseAppConfig(NotificationsAppConfigBase):
("request_resource_edit", _("Request resource change"),
_("Owner has requested permissions to modify a resource")),
)


default_app_config = 'geonode.base.BaseAppConfig'
2 changes: 1 addition & 1 deletion geonode/base/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def to_representation(self, instance):
filter_options = {
'type_filter': request.query_params.get('type'),
'title_filter': request.query_params.get('title__icontains')
}
}
data = super(BaseResourceCountSerializer, self).to_representation(instance)
count_filter = {self.Meta.count_type: instance}
data['count'] = get_resources_with_perms(
Expand Down
2 changes: 1 addition & 1 deletion geonode/base/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
ResourceBase,
TopicCategory,
ThesaurusKeyword,
)
)

from geonode import geoserver
from geonode.utils import check_ogc_backend
Expand Down
6 changes: 3 additions & 3 deletions geonode/base/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ def get_queryset(self):
filter_options = {
'type_filter': self.request.query_params.get('type'),
'title_filter': self.request.query_params.get('title__icontains')
}
}
queryset = queryset.filter(id__in=Subquery(
get_resources_with_perms(self.request.user, filter_options).values('owner'))
)
)
return queryset


Expand Down Expand Up @@ -310,7 +310,7 @@ def resource_types(self, request):
resource_types.append({
"name": _type,
"count": get_resources_with_perms(request.user).filter(resource_type=_type).count()
})
})
return Response({"resource_types": resource_types})

@extend_schema(methods=['get'], responses={200: PermSpecSerialiazer()},
Expand Down
2 changes: 1 addition & 1 deletion geonode/base/management/commands/load_thesaurus.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#########################################################################

from typing import List
from defusedxml import lxml as dlxml
from owslib.etree import etree as dlxml
from django.conf import settings

from django.core.management.base import BaseCommand, CommandError
Expand Down
2 changes: 1 addition & 1 deletion geonode/base/migrations/0032_auto_20200115_1121.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='curatedthumbnail',
name='resource',
field=models.OneToOneField(on_delete='CASCASE', to='base.ResourceBase'),
field=models.OneToOneField(on_delete=models.CASCADE, to='base.ResourceBase'),
),
migrations.AlterField(
model_name='resourcebase',
Expand Down
6 changes: 3 additions & 3 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.contrib.contenttypes.models import ContentType
from django.contrib.staticfiles.templatetags import staticfiles
from django.templatetags.static import static
from django.core.files.storage import default_storage as storage
from django.utils.html import strip_tags
from mptt.models import MPTTModel, TreeForeignKey
Expand Down Expand Up @@ -1485,7 +1485,7 @@ def get_thumbnail_url(self):
It could be a local one if it exists, a remote one (WMS GetImage) for example
or a 'Missing Thumbnail' one.
"""
_thumbnail_url = self.thumbnail_url or staticfiles.static(settings.MISSING_THUMBNAIL)
_thumbnail_url = self.thumbnail_url or static(settings.MISSING_THUMBNAIL)
local_thumbnails = self.link_set.filter(name='Thumbnail')
remote_thumbnails = self.link_set.filter(name='Remote Thumbnail')
if local_thumbnails.count() > 0:
Expand Down Expand Up @@ -1580,7 +1580,7 @@ def save_thumbnail(self, filename, image):
logger.error(f'Check permissions for file {upload_path}.')
try:
Link.objects.filter(resource=self, name='Thumbnail').delete()
_thumbnail_url = staticfiles.static(settings.MISSING_THUMBNAIL)
_thumbnail_url = static(settings.MISSING_THUMBNAIL)
obj, _created = Link.objects.get_or_create(
resource=self,
name='Thumbnail',
Expand Down
2 changes: 1 addition & 1 deletion geonode/base/templates/base/batch_edit.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "geonode_base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}
{% load bootstrap_tags %}

{% block title %} {% trans "Batch Edit" %} - {{ block.super }} {% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion geonode/base/templates/base/batch_permissions.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "geonode_base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}
{% load bootstrap_tags %}

{% block title %} {% trans "Set Permissions" %} - {{ block.super }} {% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion geonode/base/templates/base/maintenance.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load static from staticfiles %}
{% load static %}

<!DOCTYPE html>
<html>
Expand Down
2 changes: 1 addition & 1 deletion geonode/base/templates/base/read_only_violation.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load static from staticfiles %}
{% load static %}

<!DOCTYPE html>
<html>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "geonode_base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}
{% load bootstrap_tags %}

{% block title %} {% trans "Batch Edit" %} - {{ block.super }} {% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion geonode/catalogue/backends/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from django.template.loader import get_template
from owslib.csw import CatalogueServiceWeb, namespaces
from owslib.util import http_post
from defusedxml import lxml as dlxml
from owslib.etree import etree as dlxml
from geonode.catalogue.backends.base import BaseCatalogueBackend

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion geonode/catalogue/backends/pycsw_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#########################################################################

import os
from defusedxml import lxml as dlxml
from owslib.etree import etree as dlxml
from django.conf import settings
from owslib.iso import MD_Metadata
from pycsw import server
Expand Down
2 changes: 1 addition & 1 deletion geonode/catalogue/metadataxsl/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import logging

from lxml import etree
from defusedxml import lxml as dlxml
from owslib.etree import etree as dlxml

from django.shortcuts import get_object_or_404
from django.http import HttpResponse
Expand Down
2 changes: 1 addition & 1 deletion geonode/catalogue/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from django.conf import settings
from django.db.models import signals
from lxml import etree
from defusedxml import lxml as dlxml
from owslib.etree import etree as dlxml
from geonode.layers.models import Layer
from geonode.documents.models import Document
from geonode.catalogue import get_catalogue
Expand Down
2 changes: 1 addition & 1 deletion geonode/catalogue/templates/geonode_metadata_full.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% load static from staticfiles %}
{% load static %}

<html>
<head>
Expand Down
2 changes: 1 addition & 1 deletion geonode/client/templates/ol/layers/layer_ol2_map.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

{% load static from staticfiles %}
{% load static %}
<!-- script src="{% static "geonode/js/proj4js/proj4.js" %}" type="text/javascript"></script -->
<script src="{% static "geonode/js/ol-2.13/OpenLayers.js" %}" type="text/javascript"></script>
<script src="{% static "geonode/js/ol-2.13/lib/OpenLayers/Layer/ArcGISCache.js" %}" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion geonode/client/templates/ol/maps/map_ol2.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load static from staticfiles %}
{% load static %}
<!-- script src="{% static "geonode/js/proj4js/proj4.js" %}" type="text/javascript"></script -->
<script src="{% static "geonode/js/ol-2.13/OpenLayers.js" %}" type="text/javascript"></script>
<script src="{% static "geonode/js/ol-2.13/lib/OpenLayers/Layer/ArcGISCache.js" %}" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion geonode/documents/templates/documents/document_list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "documents/document_base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}

{% block title %} {% trans "Explore Documents" %} - {{ block.super }} {% endblock %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "documents/document_upload_base.html" %}
{% load staticfiles %}
{% load static %}
{% load bootstrap_tags %}
{% load i18n %}

Expand Down
2 changes: 1 addition & 1 deletion geonode/geoapps/templates/apps/app_detail.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "apps/app_base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}
{% load dialogos_tags %}
{% load pinax_ratings_tags %}
{% load bootstrap_tags %}
Expand Down
2 changes: 1 addition & 1 deletion geonode/geoapps/templates/apps/app_list_default.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "apps/app_base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}

{% block body_class %}apps explore{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "geonode_base.html" %}
{% load i18n %}
{% load base_tags %}
{% load staticfiles %}
{% load static %}
{% load bootstrap_tags %}

{% block title %} {% trans "Create Layer" %} - {{ block.super }} {% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion geonode/geoserver/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from geoserver.workspace import Workspace
from gsimporter import Client
from lxml import etree
from defusedxml import lxml as dlxml
from owslib.etree import etree as dlxml
from owslib.wcs import WebCoverageService
from owslib.wms import WebMapService
from geonode import GeoNodeException
Expand Down
7 changes: 4 additions & 3 deletions geonode/geoserver/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from django.conf import settings
from django.dispatch import receiver, Signal
from django.forms.models import model_to_dict
from django.contrib.staticfiles.templatetags import staticfiles
from django.templatetags.static import static


# use different name to avoid module clash
from geonode.utils import (
Expand Down Expand Up @@ -130,7 +131,7 @@ def geoserver_post_save_map(instance, sender, created, **kwargs):
instance.set_missing_info()
if not created:
if not instance.thumbnail_url or \
instance.thumbnail_url == staticfiles.static(settings.MISSING_THUMBNAIL):
instance.thumbnail_url == static(settings.MISSING_THUMBNAIL):
logger.debug(f"... Creating Thumbnail for Map [{instance.title}]")
# create_gs_thumbnail(instance, overwrite=False, check_bbox=True)
geoserver_create_thumbnail.apply_async(((instance.id, False, True, )))
Expand All @@ -149,7 +150,7 @@ def geoserver_post_save_thumbnail(sender, instance, **kwargs):
'thumbnail_url' in kwargs['update_fields']:
_recreate_thumbnail = True
if not instance.thumbnail_url or \
instance.thumbnail_url == staticfiles.static(settings.MISSING_THUMBNAIL) or \
instance.thumbnail_url == static(settings.MISSING_THUMBNAIL) or \
is_monochromatic_image(instance.thumbnail_url):
_recreate_thumbnail = True
if _recreate_thumbnail:
Expand Down
5 changes: 3 additions & 2 deletions geonode/geoserver/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from django.contrib.auth import get_user_model
from django.core.management import call_command
from django.utils.translation import ugettext_lazy as _
from django.contrib.staticfiles.templatetags import staticfiles
from django.templatetags.static import static


from celery.utils.log import get_task_logger

Expand Down Expand Up @@ -485,7 +486,7 @@ def geoserver_post_save_layers(
}

if is_monochromatic_image(instance.thumbnail_url):
to_update['thumbnail_url'] = staticfiles.static(settings.MISSING_THUMBNAIL)
to_update['thumbnail_url'] = static(settings.MISSING_THUMBNAIL)

# Save all the modified information in the instance without triggering signals.
try:
Expand Down
2 changes: 1 addition & 1 deletion geonode/geoserver/tests/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import gisdata
import logging
from lxml import etree
from defusedxml import lxml as dlxml
from owslib.etree import etree as dlxml
from urllib.request import urlopen, Request
from urllib.parse import urljoin

Expand Down
2 changes: 1 addition & 1 deletion geonode/geoserver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import logging
import traceback
from lxml import etree
from defusedxml import lxml as dlxml
from owslib.etree import etree as dlxml
from os.path import isfile

from urllib.parse import (
Expand Down
2 changes: 1 addition & 1 deletion geonode/groups/migrations/0029_auto_20200115_1121.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='groupprofile',
name='group',
field=models.OneToOneField(on_delete='CASCASE', to='auth.Group'),
field=models.OneToOneField(on_delete=models.CASCADE, to='auth.Group'),
),
]
6 changes: 4 additions & 2 deletions geonode/groups/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
from django.utils.text import slugify
from django.db.models import signals
from django.utils.timezone import now
from django.contrib.staticfiles.templatetags import staticfiles

from django.templatetags.static import static


from taggit.managers import TaggableManager

Expand Down Expand Up @@ -226,7 +228,7 @@ def class_name(self):

@property
def logo_url(self):
_missing_thumbnail_url = staticfiles.static(settings.MISSING_THUMBNAIL)
_missing_thumbnail_url = static(settings.MISSING_THUMBNAIL)
try:
_base_path = os.path.split(self.logo.path)[0]
_upload_path = os.path.split(self.logo.url)[1]
Expand Down
2 changes: 1 addition & 1 deletion geonode/groups/templates/groups/category_list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "groups/group_base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}

{% block title %} {% trans "Explore Group Categories" %} - {{ block.super }} {% endblock %}

Expand Down
2 changes: 1 addition & 1 deletion geonode/groups/templates/groups/group_list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "groups/group_base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load static %}

{% block title %} {% trans "Explore Groups" %} - {{ block.super }} {% endblock %}

Expand Down
2 changes: 1 addition & 1 deletion geonode/layers/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import uuid
import logging
import datetime
from defusedxml import lxml as dlxml
from owslib.etree import etree as dlxml
from django.conf import settings

# Geonode functionality
Expand Down
Loading

0 comments on commit 16bce71

Please sign in to comment.