Skip to content

Commit

Permalink
Merge branch 'master' into geoip
Browse files Browse the repository at this point in the history
  • Loading branch information
NyakudyaA authored Jul 30, 2023
2 parents ef00ac0 + 2f4e4af commit 9a90a75
Show file tree
Hide file tree
Showing 22 changed files with 283 additions and 70 deletions.
18 changes: 10 additions & 8 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ NGINX_BASE_URL=
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
GEONODE_DATABASE=geonode
GEONODE_DATABASE_USER=geonode
GEONODE_DATABASE_PASSWORD=geonode
GEONODE_GEODATABASE=geonode_data
GEONODE_GEODATABASE_USER=geonode_data
GEONODE_GEODATABASE_PASSWORD=geonode_data
GEONODE_DATABASE_SCHEMA=public
GEONODE_GEODATABASE_SCHEMA=public
Expand All @@ -45,7 +47,7 @@ BROKER_URL=amqp://guest:guest@rabbitmq:5672/
CELERY_BEAT_SCHEDULER=celery.beat:PersistentScheduler
ASYNC_SIGNALS=True

SITEURL=http://localhost/
SITEURL=https://localhost/

ALLOWED_HOSTS=['django', '*']

Expand All @@ -67,8 +69,8 @@ GEONODE_LB_PORT=80

# IP or domain name and port where the server can be reached on HTTPS (leave HOST empty if you want to use HTTP only)
# port where the server can be reached on HTTPS
HTTP_HOST=localhost
HTTPS_HOST=
HTTP_HOST=
HTTPS_HOST=localhost

HTTP_PORT=80
HTTPS_PORT=443
Expand All @@ -78,17 +80,17 @@ HTTPS_PORT=443
# disabled : we do not get a certificate at all (a placeholder certificate will be used)
# staging : we get staging certificates (are invalid, but allow to test the process completely and have much higher limit rates)
# production : we get a normal certificate (default)
LETSENCRYPT_MODE=disabled
# LETSENCRYPT_MODE=staging
# LETSENCRYPT_MODE=disabled
LETSENCRYPT_MODE=staging
# LETSENCRYPT_MODE=production

RESOLVER=127.0.0.11

# #################
# geoserver
# #################
GEOSERVER_WEB_UI_LOCATION=http://localhost/geoserver/
GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/
GEOSERVER_WEB_UI_LOCATION=https://localhost/geoserver/
GEOSERVER_PUBLIC_LOCATION=https://localhost/geoserver/
GEOSERVER_LOCATION=http://geoserver:8080/geoserver/
GEOSERVER_ADMIN_USER=admin
GEOSERVER_ADMIN_PASSWORD=geoserver
Expand Down Expand Up @@ -187,7 +189,7 @@ BING_API_KEY=
GOOGLE_API_KEY=

# Monitoring
MONITORING_ENABLED=True
MONITORING_ENABLED=False
MONITORING_DATA_TTL=365
USER_ANALYTICS_ENABLED=True
USER_ANALYTICS_GZIP=True
Expand Down
2 changes: 2 additions & 0 deletions .env_dev
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ NGINX_BASE_URL=
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
GEONODE_DATABASE=geonode
GEONODE_DATABASE_USER=geonode
GEONODE_DATABASE_PASSWORD=geonode
GEONODE_GEODATABASE=geonode_data
GEONODE_GEODATABASE_USER=geonode
GEONODE_GEODATABASE_PASSWORD=geonode
GEONODE_DATABASE_SCHEMA=public
GEONODE_GEODATABASE_SCHEMA=public
Expand Down
4 changes: 3 additions & 1 deletion .env_local
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ NGINX_BASE_URL=
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
GEONODE_DATABASE=geonode
GEONODE_DATABASE_USER=geonode
GEONODE_DATABASE_PASSWORD=geonode
GEONODE_GEODATABASE=geonode_data
GEONODE_GEODATABASE_USER=geonode
GEONODE_GEODATABASE_PASSWORD=geonode
GEONODE_DATABASE_SCHEMA=public
GEONODE_GEODATABASE_SCHEMA=public
Expand All @@ -45,7 +47,7 @@ BROKER_URL=amqp://admin:admin@localhost:5672//
CELERY_BEAT_SCHEDULER=celery.beat:PersistentScheduler
ASYNC_SIGNALS=False

SITEURL=http://localhost/
SITEURL=http://localhost:8000/

ALLOWED_HOSTS="['django', '*']"

Expand Down
4 changes: 3 additions & 1 deletion .env_test
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ NGINX_BASE_URL=
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
GEONODE_DATABASE=geonode
GEONODE_DATABASE_USER=geonode
GEONODE_DATABASE_PASSWORD=geonode
GEONODE_GEODATABASE=geonode_data
GEONODE_GEODATABASE_USER=geonode_data
GEONODE_GEODATABASE_PASSWORD=geonode_data
GEONODE_DATABASE_SCHEMA=public
GEONODE_GEODATABASE_SCHEMA=public
Expand Down Expand Up @@ -196,7 +198,7 @@ BING_API_KEY=
GOOGLE_API_KEY=

# Monitoring
MONITORING_ENABLED=True
MONITORING_ENABLED=False
MONITORING_DATA_TTL=365
USER_ANALYTICS_ENABLED=True
USER_ANALYTICS_GZIP=True
Expand Down
24 changes: 12 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: '3.9'
x-common-django:
&default-common-django
image: geonode/geonode:latest-ubuntu-22.10
restart: on-failure
restart: unless-stopped
env_file:
- .env
volumes:
Expand Down Expand Up @@ -50,7 +50,7 @@ services:

# Nginx is serving django static and media files and proxies to django and geonode
geonode:
image: geonode/nginx:4.0
image: geonode/nginx:4.1.0
build: ./scripts/docker/nginx/
container_name: nginx4${COMPOSE_PROJECT_NAME}
environment:
Expand All @@ -67,11 +67,11 @@ services:
- nginx-confd:/etc/nginx
- nginx-certificates:/geonode-certificates
- statics:/mnt/volumes/statics
restart: on-failure
restart: unless-stopped

# Gets and installs letsencrypt certificates
letsencrypt:
image: geonode/letsencrypt:4.0
image: geonode/letsencrypt:4.1.0
build: ./scripts/docker/letsencrypt/
container_name: letsencrypt4${COMPOSE_PROJECT_NAME}
environment:
Expand All @@ -81,7 +81,7 @@ services:
- LETSENCRYPT_MODE=${LETSENCRYPT_MODE}
volumes:
- nginx-certificates:/geonode-certificates
restart: on-failure
restart: unless-stopped

# Geoserver backend
geoserver:
Expand All @@ -101,7 +101,7 @@ services:
- backup-restore:/backup_restore
- data:/data
- tmp:/tmp
restart: on-failure
restart: unless-stopped
depends_on:
db:
condition: service_healthy
Expand All @@ -114,22 +114,22 @@ services:
entrypoint: sleep infinity
volumes:
- geoserver-data-dir:/geoserver_data/data
restart: on-failure
restart: unless-stopped
healthcheck:
test: "ls -A '/geoserver_data/data' | wc -l"

# PostGIS database.
db:
# use geonode official postgis 13 image
image: geonode/postgis:13
# use geonode official postgis 15 image
image: geonode/postgis:15
command: postgres -c "max_connections=${POSTGRESQL_MAX_CONNECTIONS}"
container_name: db4${COMPOSE_PROJECT_NAME}
env_file:
- .env
volumes:
- dbdata:/var/lib/postgresql/data
- dbbackups:/pg_backups
restart: on-failure
restart: unless-stopped
healthcheck:
test: "pg_isready -d postgres -U postgres"
# uncomment to enable remote connections to postgres
Expand All @@ -138,11 +138,11 @@ services:

# Vanilla RabbitMQ service. This is needed by celery
rabbitmq:
image: rabbitmq:3.7-alpine
image: rabbitmq:3-alpine
container_name: rabbitmq4${COMPOSE_PROJECT_NAME}
volumes:
- rabbitmq:/var/lib/rabbitmq
restart: on-failure
restart: unless-stopped

volumes:
statics:
Expand Down
10 changes: 9 additions & 1 deletion geonode/facets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ def get_info(self, lang="en", **kwargs) -> dict:
pass

def get_facet_items(
self, queryset, start: int = 0, end: int = DEFAULT_FACET_PAGE_SIZE, lang="en", topic_contains: str = None
self,
queryset,
start: int = 0,
end: int = DEFAULT_FACET_PAGE_SIZE,
lang="en",
topic_contains: str = None,
keys: set = {},
**kwargs,
) -> (int, list):
"""
Return the items of the facets, in a tuple:
Expand All @@ -87,6 +94,7 @@ def get_facet_items(
:param end: int: pagination, the index of the last returned item
:param lang: the preferred language for the labels
:param topic_contains: only returns matching topics
:param keys: only returns topics with given keys, even if their count is 0
:return: a tuple int:total count of record, list of items
"""
pass
Expand Down
4 changes: 4 additions & 0 deletions geonode/facets/providers/baseinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def get_facet_items(
end: int = DEFAULT_FACET_PAGE_SIZE,
lang="en",
topic_contains: str = None,
keys: set = {},
**kwargs,
) -> (int, list):
logger.debug("Retrieving facets for %s", self.name)

Expand Down Expand Up @@ -120,6 +122,8 @@ def get_facet_items(
end: int = DEFAULT_FACET_PAGE_SIZE,
lang="en",
topic_contains: str = None,
keys: set = {},
**kwargs,
) -> (int, list):
logger.debug("Retrieving facets for %s", self.name)

Expand Down
21 changes: 16 additions & 5 deletions geonode/facets/providers/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,26 @@ def get_facet_items(
end: int = DEFAULT_FACET_PAGE_SIZE,
lang="en",
topic_contains: str = None,
keys: set = {},
**kwargs,
) -> (int, list):
logger.debug("Retrieving facets for %s", self.name)

q = queryset.values("category__identifier", "category__gn_description", "category__fa_class").filter(
category__isnull=False
)
filters = {"category__isnull": False}

if topic_contains:
q = q.filter(category__gn_description=topic_contains)
q = q.annotate(count=Count("owner")).order_by("-count")
filters["category__gn_description"] = topic_contains

if keys:
logger.debug("Filtering by keys %r", keys)
filters["category__identifier__in"] = keys

q = (
queryset.values("category__identifier", "category__gn_description", "category__fa_class")
.filter(**filters)
.annotate(count=Count("owner"))
.order_by("-count")
)

cnt = q.count()

Expand Down
6 changes: 6 additions & 0 deletions geonode/facets/providers/keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@ def get_facet_items(
end: int = DEFAULT_FACET_PAGE_SIZE,
lang="en",
topic_contains: str = None,
keys: set = {},
**kwargs,
) -> (int, list):
logger.debug("Retrieving facets for %s", self.name)

filters = {"keywords__isnull": False}
if topic_contains:
filters["keywords__name__icontains"] = topic_contains

if keys:
logger.debug("Filtering by keys %r", keys)
filters["keywords__slug__in"] = keys

q = (
queryset.filter(**filters)
.values("keywords__slug", "keywords__name")
Expand Down
19 changes: 16 additions & 3 deletions geonode/facets/providers/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,26 @@ def get_facet_items(
end: int = DEFAULT_FACET_PAGE_SIZE,
lang="en",
topic_contains: str = None,
keys: set = {},
**kwargs,
) -> (int, list):
logger.debug("Retrieving facets for %s", self.name)

q = queryset.filter(regions__isnull=False).values("regions__code", "regions__name")
filters = {"regions__isnull": False}

if topic_contains:
q = q.filter(regions__name=topic_contains)
q = q.annotate(count=Count("regions__code")).order_by("-count")
filters["regions__name"] = topic_contains

if keys:
logger.debug("Filtering by keys %r", keys)
filters["regions__code__in"] = keys

q = (
queryset.filter(**filters)
.values("regions__code", "regions__name")
.annotate(count=Count("regions__code"))
.order_by("-count")
)

cnt = q.count()

Expand Down
5 changes: 5 additions & 0 deletions geonode/facets/providers/thesaurus.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def get_facet_items(
end: int = DEFAULT_FACET_PAGE_SIZE,
lang="en",
topic_contains: str = None,
keys: set = {},
**kwargs,
) -> (int, list):
logger.debug("Retrieving facets for %s", self._name)
Expand All @@ -73,6 +74,10 @@ def get_facet_items(
if topic_contains:
filter["tkeywords__keyword__label__icontains"] = topic_contains

if keys:
logger.debug("Filtering by keys %r\n", keys)
filter["tkeywords__in"] = keys

q = (
queryset.filter(**filter)
.values("tkeywords", "tkeywords__alt_label")
Expand Down
19 changes: 16 additions & 3 deletions geonode/facets/providers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,26 @@ def get_facet_items(
end: int = DEFAULT_FACET_PAGE_SIZE,
lang="en",
topic_contains: str = None,
keys: set = {},
**kwargs,
) -> (int, list):
logger.debug("Retrieving facets for OWNER")

q = queryset.values("owner", "owner__username")
filters = dict()

if topic_contains:
q = q.filter(owner__username__icontains=topic_contains)
q = q.annotate(count=Count("owner")).order_by("-count")
filters["owner__username__icontains"] = topic_contains

if keys:
logger.debug("Filtering by keys %r", keys)
filters["owner__in"] = keys

q = (
queryset.values("owner", "owner__username")
.filter(**filters)
.annotate(count=Count("owner"))
.order_by("-count")
)

cnt = q.count()

Expand Down
Loading

0 comments on commit 9a90a75

Please sign in to comment.