Skip to content

Commit

Permalink
Merge branch 'master' of github.com:GeoNode/geonode
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Garcia Silva committed Oct 19, 2021
2 parents ea6eaf7 + 0bf76e1 commit 0b8cbac
Show file tree
Hide file tree
Showing 103 changed files with 8,288 additions and 10,595 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ GEONODE_DB_CONN_MAX_AGE=0
GEONODE_DB_CONN_TOUT=5
DEFAULT_BACKEND_DATASTORE=datastore
BROKER_URL=amqp://guest:guest@rabbitmq:5672/
CELERY_BEAT_SCHEDULER=celery.beat:PersistentScheduler
ASYNC_SIGNALS=True

SITEURL=http://localhost/
Expand Down Expand Up @@ -164,7 +165,6 @@ MEDIA_ROOT=/mnt/volumes/statics/uploaded/
GEOIP_PATH=/mnt/volumes/statics/geoip.db

CACHE_BUSTING_STATIC_ENABLED=False
CACHE_BUSTING_MEDIA_ENABLED=False

MEMCACHED_ENABLED=False
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
Expand Down
2 changes: 1 addition & 1 deletion .env_dev
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ GEONODE_DB_CONN_MAX_AGE=0
GEONODE_DB_CONN_TOUT=5
DEFAULT_BACKEND_DATASTORE=datastore
BROKER_URL=amqp://admin:admin@localhost:5672//
CELERY_BEAT_SCHEDULER=celery.beat:PersistentScheduler
ASYNC_SIGNALS=False

SITEURL=http://localhost:8000/
Expand Down Expand Up @@ -158,7 +159,6 @@ SECRET_KEY='myv-y4#7j-d*p-__@j#*3z@!y24fz8%^z2v6atuy4bo9vqr1_a'
# GEOIP_PATH=/mnt/volumes/statics/geoip.db

CACHE_BUSTING_STATIC_ENABLED=False
CACHE_BUSTING_MEDIA_ENABLED=False

MEMCACHED_ENABLED=False
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
Expand Down
2 changes: 1 addition & 1 deletion .env_local
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ GEONODE_DB_CONN_MAX_AGE=0
GEONODE_DB_CONN_TOUT=5
DEFAULT_BACKEND_DATASTORE=datastore
BROKER_URL=amqp://admin:admin@localhost:5672//
CELERY_BEAT_SCHEDULER=celery.beat:PersistentScheduler
ASYNC_SIGNALS=False

SITEURL=http://localhost/
Expand Down Expand Up @@ -158,7 +159,6 @@ SECRET_KEY='myv-y4#7j-d*p-__@j#*3z@!y24fz8%^z2v6atuy4bo9vqr1_a'
# GEOIP_PATH=/mnt/volumes/statics/geoip.db

CACHE_BUSTING_STATIC_ENABLED=False
CACHE_BUSTING_MEDIA_ENABLED=False

MEMCACHED_ENABLED=False
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
Expand Down
2 changes: 1 addition & 1 deletion .env_test
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ GEONODE_DB_CONN_MAX_AGE=0
GEONODE_DB_CONN_TOUT=5
DEFAULT_BACKEND_DATASTORE=datastore
BROKER_URL=amqp://guest:guest@rabbitmq:5672/
CELERY_BEAT_SCHEDULER=celery.beat:PersistentScheduler
ASYNC_SIGNALS=False

SITEURL=http://localhost:8001/
Expand Down Expand Up @@ -158,7 +159,6 @@ MEDIA_ROOT=/mnt/volumes/statics/uploaded/
GEOIP_PATH=/mnt/volumes/statics/geoip.db

CACHE_BUSTING_STATIC_ENABLED=False
CACHE_BUSTING_MEDIA_ENABLED=False

MEMCACHED_ENABLED=False
MEMCACHED_BACKEND=django.core.cache.backends.memcached.MemcachedCache
Expand Down
6 changes: 3 additions & 3 deletions celery-cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
# Luca Pasquali <[email protected]>
CELERY_BIN=${CELERY_BIN:-"$(which celery||echo celery)"}
CELERY_APP=${CELERY_APP:-"geonode.celery_app:app"}
# CELERY__STATE_DB=${CELERY__STATE_DB:-"/mnt/volumes/statics/worker.state"}
CELERY__STATE_DB=${CELERY__STATE_DB:-"/mnt/volumes/statics/worker.state"}
# expressed in KB
CELERY__MAX_MEMORY_PER_CHILD=${CELERY__MAX_MEMORY_PER_CHILD:-"200000"}
CELERY__AUTOSCALE_VALUES=${CELERY__AUTOSCALE_VALUES:-"2,4"}
CELERY__MAX_TASKS_PER_CHILD=${CELERY__MAX_TASKS_PER_CHILD:-"10"}
CELERY__OPTS=${CELERY__OPTS:-"--without-gossip --without-mingle -Ofair -B -E"}
CELERY__BEAT_SCHEDULE=${CELERY__BEAT_SCHEDULE:-"django_celery_beat.schedulers:DatabaseScheduler"}
CELERY__BEAT_SCHEDULE=${CELERY__BEAT_SCHEDULE:-"celery.beat:PersistentScheduler"}
CELERY__LOG_LEVEL=${CELERY__LOG_LEVEL:-"INFO"}
CELERY__LOG_FILE=${CELERY__LOG_FILE:-"/var/log/celery.log"}
CELERY__WORKER_NAME=${CELERY__WORKER_NAME:-"worker1@%h"}
CELERY__WORKER_CONCURRENCY=${CELERY__WORKER_CONCURRENCY:-"4"}

$CELERY_BIN -A $CELERY_APP worker --autoscale=$CELERY__AUTOSCALE_VALUES \
--max-memory-per-child=$CELERY__MAX_MEMORY_PER_CHILD $CELERY__OPTS \
-s $CELERY__BEAT_SCHEDULE \
--statedb=$CELERY__STATE_DB --scheduler=$CELERY__BEAT_SCHEDULE \
--loglevel=$CELERY__LOG_LEVEL -n $CELERY__WORKER_NAME -f $CELERY__LOG_FILE \
--concurrency=$CELERY__WORKER_CONCURRENCY --max-tasks-per-child=$CELERY__MAX_TASKS_PER_CHILD
2 changes: 1 addition & 1 deletion celery.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
nohup celery -A geonode.celery_app:app beat -l DEBUG -f /var/log/celery.log &>/dev/null &
nohup celery -A geonode.celery_app:app worker --without-gossip --without-mingle -Ofair -B -E -s django_celery_beat.schedulers:DatabaseScheduler --loglevel=INFO --concurrency=2 -n worker1@%h -f /var/log/celery.log &>/dev/null &
nohup celery -A geonode.celery_app:app worker --without-gossip --without-mingle -Ofair -B -E --statedb=worker.state --scheduler=celery.beat:PersistentScheduler --loglevel=INFO --concurrency=2 -n worker1@%h -f /var/log/celery.log &>/dev/null &
nohup celery -A geonode.celery_app:app flower --auto_refresh=True --debug=False --broker=${BROKER_URL} --basic_auth=${ADMIN_USERNAME}:${ADMIN_PASSWORD} --address=0.0.0.0 --port=5555 &>/dev/null &
2 changes: 1 addition & 1 deletion celery_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ set -a
. ./.env_dev
set +a

celery -A geonode.celery_app:app worker --without-gossip --without-mingle -Ofair -B -E -s django_celery_beat.schedulers:DatabaseScheduler --loglevel=DEBUG --concurrency=2 -n worker1@%h
celery -A geonode.celery_app:app worker --without-gossip --without-mingle -Ofair -B -E --statedb=worker.state --scheduler=celery.beat:PersistentScheduler --loglevel=DEBUG --concurrency=2 -n worker1@%h
17 changes: 11 additions & 6 deletions geonode/base/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
from rest_framework import permissions
from rest_framework.filters import BaseFilterBackend

from geonode.security.utils import get_resources_with_perms
from geonode.security.utils import (
get_users_with_perms,
get_resources_with_perms)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -113,14 +115,17 @@ def has_object_permission(self, request, view, obj):
return True

# Instance must have an attribute named `owner`.
_request_matches = False
if isinstance(obj, get_user_model()) and obj == request.user:
return True
_request_matches = True
elif hasattr(obj, 'owner'):
return obj.owner == request.user
_request_matches = obj.owner == request.user
elif hasattr(obj, 'user'):
return obj.user == request.user
else:
return False
_request_matches = obj.user == request.user

if not _request_matches:
_request_matches = request.user in get_users_with_perms(obj)
return _request_matches


class IsOwnerOrReadOnly(IsOwnerOrAdmin):
Expand Down
17 changes: 12 additions & 5 deletions geonode/base/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,9 @@ def to_representation(self, instance):

class HierarchicalKeywordSerializer(BaseResourceCountSerializer):

class Meta(SimpleHierarchicalKeywordSerializer.Meta):
class Meta:
name = 'keywords'
model = HierarchicalKeyword
count_type = 'keywords'
view_name = 'keywords-list'
fields = '__all__'
Expand All @@ -465,25 +466,31 @@ class Meta:

class RegionSerializer(BaseResourceCountSerializer):

class Meta(SimpleRegionSerializer.Meta):
class Meta:
name = 'regions'
model = Region
count_type = 'regions'
view_name = 'regions-list'
fields = '__all__'


class TopicCategorySerializer(BaseResourceCountSerializer):

class Meta(SimpleTopicCategorySerializer.Meta):
class Meta:
name = 'categories'
model = TopicCategory
count_type = 'category'
view_name = 'categories-list'
fields = '__all__'


class OwnerSerializer(BaseResourceCountSerializer, UserSerializer):
class OwnerSerializer(BaseResourceCountSerializer):

class Meta(UserSerializer.Meta):
class Meta:
name = 'owners'
count_type = 'owner'
view_name = 'owners-list'
model = get_user_model()
fields = ('pk', 'username', 'first_name', 'last_name', 'avatar', 'perms')

avatar = AvatarUrlField(240, read_only=True)
Loading

0 comments on commit 0b8cbac

Please sign in to comment.