Skip to content

Commit

Permalink
Merge pull request #550 from kartoza/develop
Browse files Browse the repository at this point in the history
Upgrading geonode to 4.0.3
  • Loading branch information
meomancer authored May 12, 2023
2 parents fe8f6e4 + eaad5e7 commit 2ba167c
Show file tree
Hide file tree
Showing 44 changed files with 1,558 additions and 930 deletions.
14 changes: 2 additions & 12 deletions deployment/.env
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
##############################################################
# #
# SPCgeonode Settings #
# #
# The defauts settings are suited for testing on localhost. #
# If you're deploying SPCgeonode for production, you need to #
# adapt the following settings #
# #
# DO NOT FORGET to also modify values in _secrets ! #
# #
##############################################################

# Name of the setup (you only need to change this if you run several instances of the stack)
COMPOSE_PROJECT_NAME=igrac

Expand Down Expand Up @@ -69,3 +57,5 @@ S3_ACCESS_KEY=
S3_SECRET_KEY=
S3_REGION=
S3_BUCKET=

VERSION=4.0.0
7 changes: 3 additions & 4 deletions deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.4'
# Common Django template for Geonode, Celery and Celerycam services below
x-common-django:
&default-common-django
image: kartoza/igrac_ggis:2.1.0
image: kartoza/igrac_ggis:${VERSION}
build:
context: ../
dockerfile: deployment/docker/Dockerfile
Expand Down Expand Up @@ -49,13 +49,12 @@ x-common-django:
- GWML_FOLDER=/home/web/gwml2-file/
- SFTP_FOLDER=/home/web/sftp/
- FILE_UPLOAD_TEMP_DIR=/home/web/temp/
- STATIC_URL=/static/
- MEDIA_URL=/uploaded/
- GEOSERVER_LOCATION=http://nginx/geoserver/
- ASYNC_SIGNALS=True
- SESSION_EXPIRED_CONTROL_ENABLED=False
- MONITORING_ENABLED=False
- PYTHONPATH=/home/web/django_project:/spcgeonode
- PYTHONPATH=/home/web/django_project:/geonode
- ADD_TIMESTAMP_IN_THUMBNAIL=True
volumes:
- ../django_project:/home/web/django_project
Expand Down Expand Up @@ -154,7 +153,7 @@ services:
# django application for development
dev:
<<: *default-common-django
image: kartoza/igrac_ggis:2.0.0-dev
image: kartoza/igrac_ggis:${VERSION}-dev
entrypoint: []
build:
context: ../
Expand Down
4 changes: 2 additions & 2 deletions deployment/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ RUN echo "Activate memcached" && \
WORKDIR /

RUN rm -r /usr/src/geonode
RUN git clone --branch 3.3.x --single-branch https://github.com/kartoza/geonode.git spcgeonode
RUN git clone --branch 4.0.3 --single-branch https://github.com/kartoza/geonode.git geonode

WORKDIR /spcgeonode
WORKDIR /geonode
RUN pip install -r requirements.txt
RUN pip uninstall -y django-geonode-mapstore-client

Expand Down
22 changes: 10 additions & 12 deletions deployment/docker/REQUIREMENTS.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
psycopg2-binary==2.8.6
django-admin-sortable==2.1.8
django-braces==1.14.0
django-model-utils==1.4.0
django-pipeline==1.6.14
psycopg2-binary==2.9.5
django-admin-sortable==2.3
django-braces==1.15.0
django-model-utils==4.3.1
django-pipeline==2.1.0
django-preferences==1.0.0
django-role-permissions==2.2.0
django-role-permissions==3.1.1

raven==6.10.0
django-sentry==1.13.5

service_identity

# igrac
wagtail==2.9.3
wagtailmenus==3.1.3
openpyxl==3.0.5
wagtail==4.2.1
wagtailmenus==3.1.5
openpyxl==3.0.10
pyexcel-xls==0.7.0
pyexcel-xlsx==0.6.0

git+https://github.com/kartoza/[email protected]
# git+https://github.com/kartoza/django-mapstore-adapter.git@geonode_latest
# git+https://github.com/kartoza/[email protected]
git+https://github.com/kartoza/[email protected]
2 changes: 1 addition & 1 deletion deployment/docker/uwsgi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ logger = file:/var/log/uwsgi-errors.log
#uid = 1000
#gid = 1000
memory-report = true
harakiri = 1200
harakiri = 3600
# plugin = python36
9 changes: 5 additions & 4 deletions django_project/core/api/layer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.http import Http404
from rest_framework.views import APIView
from rest_framework.response import Response
from geonode.layers.models import Layer
from geonode.layers.models import Dataset
from core.serializer.attribute import AttributeSerializer


Expand All @@ -13,7 +13,8 @@ class LayerAttributeAPI(APIView):

def get(self, request, alternate, *args):
try:
layer = Layer.objects.get(alternate=alternate)
return Response(AttributeSerializer(layer.attribute_set.all(), many=True).data)
except Layer.DoesNotExist:
dataset = Dataset.objects.get(alternate=alternate)
return Response(AttributeSerializer(
dataset.attribute_set.all(), many=True).data)
except Dataset.DoesNotExist:
raise Http404('Layer not found')
5 changes: 3 additions & 2 deletions django_project/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'wagtail',
'wagtail.contrib.modeladmin',
'wagtailmenus',
'modelcluster',
Expand All @@ -47,12 +47,13 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'oauth2_provider.middleware.OAuth2TokenMiddleware',
'django_user_agents.middleware.UserAgentMiddleware',
'geonode.base.middleware.MaintenanceMiddleware',
'geonode.base.middleware.ReadOnlyMiddleware', # a Middleware enabling Read Only mode of Geonode

# Wagtail moddleware
'wagtail.core.middleware.SiteMiddleware',
'wagtail.contrib.redirects.middleware.RedirectMiddleware',
)

Expand Down
1 change: 1 addition & 0 deletions django_project/core/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
)

DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
STATIC_URL = '/static/'
2 changes: 1 addition & 1 deletion django_project/gwml2
Submodule gwml2 updated from 7f2999 to ab6ab2
4 changes: 2 additions & 2 deletions django_project/igrac/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from adminsortable.admin import SortableAdmin
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from geonode.base.admin import set_user_and_group_layer_permission
from geonode.base.admin import set_user_and_group_dataset_permission
from geonode.people.admin import ProfileAdmin
from geonode.people.models import Profile
from preferences.admin import PreferencesAdmin
Expand Down Expand Up @@ -37,7 +37,7 @@ class IgracProfileAdmin(ProfileAdmin):
'username', 'organization', 'profile',
'first_name', 'last_name', 'email'
)
actions = [set_user_and_group_layer_permission, make_active]
actions = [set_user_and_group_dataset_permission, make_active]
fieldsets = (
(None, {'fields': ('username', 'password')}),
(_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
Expand Down
Empty file.
67 changes: 67 additions & 0 deletions django_project/igrac/api_views/featured.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from geonode.base.api.serializers import ResourceBaseSerializer
from geonode.base.models import (
ResourceBase,
)
from geonode.geoapps.models import GeoApp
from geonode.maps.models import Map
from rest_framework import serializers
from rest_framework.response import Response
from rest_framework.views import APIView

from igrac.models.map_slug import MapSlugMapping


class MapFeaturedSerializer(ResourceBaseSerializer):
slug = serializers.SerializerMethodField()
detail_url = serializers.SerializerMethodField()

def get_slug(self, obj: ResourceBase):
map_slug = MapSlugMapping.objects.filter(map=obj).first()
if map_slug:
return map_slug.slug
return ''

def get_detail_url(self, obj: ResourceBase):
map_slug = MapSlugMapping.objects.filter(map=obj).first()
if map_slug:
return map_slug.slug
return ''

class Meta:
model = ResourceBase
name = ResourceBaseSerializer.Meta.name
view_name = ResourceBaseSerializer.Meta.view_name
fields = ResourceBaseSerializer.Meta.fields + ('slug',)


class FeaturedMaps(APIView):
def get(self, request, *args):
featured_map = Map.objects.filter(
featured=True
).order_by(
'mapslugmapping__order', 'id'
)
serializer = MapFeaturedSerializer(
featured_map,
many=True
)
resources = serializer.data
resources += ResourceBaseSerializer(
GeoApp.objects.filter(featured=True, resource_type='dashboard'),
many=True
).data
resources += ResourceBaseSerializer(
GeoApp.objects.filter(featured=True, resource_type='geostory'),
many=True
).data

return Response({
"links": {
"next": None,
"previous": None
},
"total": featured_map.count(),
"page": 1,
"page_size": 99,
"resources": resources
})
11 changes: 11 additions & 0 deletions django_project/igrac/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ class IgracConfig(AppConfig):
def ready(self):
import igrac.signals
import igrac.monkeypatch
from django.conf import settings
geonode_mapstore_client_template_dir = ''
for template_dir in settings.TEMPLATES[0]['DIRS']:
if 'geonode_mapstore_client' in template_dir:
geonode_mapstore_client_template_dir = template_dir
settings.TEMPLATES[0]['DIRS'].remove(template_dir)
break
if geonode_mapstore_client_template_dir:
settings.TEMPLATES[0]['DIRS'].append(
geonode_mapstore_client_template_dir
)
Loading

0 comments on commit 2ba167c

Please sign in to comment.