Skip to content

Commit

Permalink
- GeoNode Stable and Updated 2.7.x Branch / NO RabbitMQ Notification…
Browse files Browse the repository at this point in the history
…s / integrated with GeoServer 2.10.x
  • Loading branch information
afabiani committed Apr 28, 2017
1 parent 4fb7f7e commit 56550b6
Show file tree
Hide file tree
Showing 28 changed files with 93 additions and 397 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ slave

# virtual env
venv

celerybeat-*
manage.py

geonode/bin/
geonode/djcelery/
geonode/include/
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ MAINTAINER GeoNode development team
COPY requirements.txt /usr/src/app/
RUN pip install -r requirements.txt

RUN pip install .

EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ sync: up
docker-compose exec django django-admin.py loaddata sample_admin
docker-compose exec django django-admin.py loaddata geonode/base/fixtures/default_oauth_apps_docker.json
docker-compose exec django django-admin.py loaddata geonode/base/fixtures/initial_data.json
docker-compose exec django django-admin.py layer_notice_types

migrate:
django-admin.py migrate --noinput
Expand Down
24 changes: 12 additions & 12 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ Or if you want to use the provided Makefile::
**Note:**
For deveployment you need to add `geonode` alias into `/ect/hosts/` file as following:

$ sudo vim /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost geonode
255.255.255.255 broadcasthost
::1 localhost
```
$ sudo vim /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost geonode
255.255.255.255 broadcasthost
::1 localhost
```
To access GeoNode just enter the following url: `http://geonode/` on your web browser.
For GeoServer: `http://geonode/geoserver/web/`

Expand Down
10 changes: 0 additions & 10 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,3 @@ services:
- '.:/usr/src/app'
environment:
- DEBUG=True

consumers:
build: .
# Loading the app is defined here to allow for
# autoreload on changes it is mounted on top of the
# old copy that docker added when creating the image
volumes:
- '.:/usr/src/app'
environment:
- DEBUG=True
13 changes: 1 addition & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,11 @@ services:
command: celery worker --app=geonode.celery_app:app -B -l INFO
env_file:
- ./scripts/docker/env/production/django.env

consumers:
image: geonode/django
links:
- rabbitmq
- postgres
- elasticsearch
command: python manage.py runmessaging
env_file:
- ./scripts/docker/env/production/django.env

geoserver:
image: piensalabs/geoserver:pubsub
image: geonode/geoserver:alias
links:
- postgres
- rabbitmq
ports:
- "8080"
volumes_from:
Expand Down
2 changes: 1 addition & 1 deletion geonode/base/populate_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def create_models(type=None):
from django.contrib.auth.models import Group
map_data, user_data, people_data, layer_data, document_data = create_fixtures()
anonymous_group, created = Group.objects.get_or_create(name='anonymous')
u, _ = get_user_model().objects.get_or_create(username='admin', defaults=dict(is_superuser=True, first_name='admin'))
u, _ = get_user_model().objects.get_or_create(username='admin', is_superuser=True, first_name='admin')
u.set_password('admin')
u.save()
users = []
Expand Down
16 changes: 15 additions & 1 deletion geonode/catalogue/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,21 @@ def catalogue_post_save(instance, sender, **kwargs):


def catalogue_pre_save(instance, sender, **kwargs):
pass
"""Send information to catalogue"""
record = None

# if the layer is in the catalogue, try to get the distribution urls
# that cannot be precalculated.
try:
catalogue = get_catalogue()
record = catalogue.get_record(instance.uuid)
except EnvironmentError, err:
msg = 'Could not connect to catalogue to save information for layer "%s"' % instance.name
LOGGER.warn(msg, err)
raise err

if record is None:
return


if 'geonode.catalogue' in settings.INSTALLED_APPS:
Expand Down
8 changes: 4 additions & 4 deletions geonode/documents/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from geonode.base.populate_test_data import create_models


class DocumentsTest(TestCase):
class LayersTest(TestCase):
fixtures = ['initial_data.json', 'bobby']

perm_spec = {
Expand All @@ -68,7 +68,7 @@ def test_create_document_with_no_rel(self):
self.imgfile.read(),
'image/gif')

superuser = get_user_model().objects.filter(is_superuser=True)[0]
superuser = get_user_model().objects.get(pk=2)
c = Document.objects.create(
doc_file=f,
owner=superuser,
Expand All @@ -83,7 +83,7 @@ def test_create_document_with_rel(self):
self.imgfile.read(),
'image/gif')

superuser = get_user_model().objects.filter(is_superuser=True)[0]
superuser = get_user_model().objects.get(pk=2)

m = Map.objects.all()[0]
ctype = ContentType.objects.get_for_model(m)
Expand All @@ -100,7 +100,7 @@ def test_create_document_with_rel(self):
def test_create_document_url(self):
"""Tests creating an external document instead of a file."""

superuser = get_user_model().objects.filter(is_superuser=True)[0]
superuser = get_user_model().objects.get(pk=2)
c = Document.objects.create(doc_url="http://geonode.org/map.pdf",
owner=superuser,
title="GeoNode Map",
Expand Down
88 changes: 29 additions & 59 deletions geonode/geoserver/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

from django.utils.translation import ugettext
from django.conf import settings
from django.forms.models import model_to_dict

from geonode.geoserver.ows import wcs_links, wfs_links, wms_links
from geonode.geoserver.helpers import cascading_delete, set_attributes_from_geoserver
Expand All @@ -38,19 +37,12 @@
from geonode.base.models import ResourceBase
from geonode.base.models import Link
from geonode.people.models import Profile

from geoserver.layer import Layer as GsLayer
from geonode.social.signals import json_serializer_producer

logger = logging.getLogger("geonode.geoserver.signals")


def geoserver_delete(typename):
# cascading_delete should only be called if
# ogc_server_settings.BACKEND_WRITE_ENABLED == True
if getattr(ogc_server_settings, "BACKEND_WRITE_ENABLED", True):
cascading_delete(gs_catalog, typename)


def geoserver_pre_delete(instance, sender, **kwargs):
"""Removes the layer from GeoServer
"""
Expand All @@ -63,46 +55,21 @@ def geoserver_pre_delete(instance, sender, **kwargs):


def geoserver_pre_save(instance, sender, **kwargs):
"""
move the content of this task to post save signal
:param instance:
:param sender:
:param kwargs:
:return:
"""
pass


def geoserver_post_save(instance, sender, **kwargs):
from geonode.messaging import producer
instance_dict = model_to_dict(instance)
payload = json_serializer_producer(instance_dict)
producer.geoserver_upload_layer(payload)


def geoserver_post_save2(layer_id):
"""Save keywords to GeoServer
The way keywords are implemented requires the layer
to be saved to the database before accessing them.
"""
"""Send information to geoserver.
The attributes sent include:
The attributes sent include:
* Title
* Abstract
* Name
* Keywords
* Metadata Links,
* Point of Contact name and url
"""
* Title
* Abstract
* Name
* Keywords
* Metadata Links,
* Point of Contact name and url
"""

from geonode.layers.models import Layer
instance = Layer.objects.get(id=layer_id)
# Don't run this signal if is a Layer from a remote service
if getattr(instance, "service", None) is not None:
return instance
return

# Don't run this signal handler if it is a tile layer or a remote store (Service)
# Currently only gpkg files containing tiles will have this type & will be served via MapProxy.
Expand All @@ -118,8 +85,7 @@ def geoserver_post_save2(layer_id):

# There is no need to process it if there is not file.
if base_file is None:
return instance

return
gs_name, workspace, values, gs_resource = geoserver_upload(instance,
base_file.file.path,
instance.owner,
Expand All @@ -129,17 +95,13 @@ def geoserver_post_save2(layer_id):
abstract=instance.abstract,
# keywords=instance.keywords,
charset=instance.charset)

# Set fields obtained via the geoserver upload.
instance.name = gs_name
instance.workspace = workspace
instance.store = values['store']
# Iterate over values from geoserver.
for key in ['typename', 'store', 'storeType']:
setattr(instance, key, values[key])

instance.save()

if not gs_resource:
gs_resource = gs_catalog.get_resource(
instance.name,
Expand All @@ -160,8 +122,7 @@ def geoserver_post_save2(layer_id):
gs_resource.metadata_links = metadata_links
# gs_resource should only be called if
# ogc_server_settings.BACKEND_WRITE_ENABLED == True
if gs_resource and getattr(ogc_server_settings, "BACKEND_WRITE_ENABLED",
True):
if gs_resource and getattr(ogc_server_settings, "BACKEND_WRITE_ENABLED", True):
gs_catalog.save(gs_resource)

gs_layer = gs_catalog.get_layer(instance.name)
Expand All @@ -176,7 +137,7 @@ def geoserver_post_save2(layer_id):
'type': None}
profile = Profile.objects.get(username=instance.poc.username)
gs_layer.attribution_link = settings.SITEURL[
:-1] + profile.get_absolute_url()
:-1] + profile.get_absolute_url()
# gs_layer should only be called if
# ogc_server_settings.BACKEND_WRITE_ENABLED == True
if getattr(ogc_server_settings, "BACKEND_WRITE_ENABLED", True):
Expand All @@ -199,7 +160,7 @@ def geoserver_post_save2(layer_id):
# self.srid = gs_resource.src

instance.srid_url = "http://www.spatialreference.org/ref/" + \
instance.srid.replace(':', '/').lower() + "/"
instance.srid.replace(':', '/').lower() + "/"

# Set bounding box values
instance.bbox_x0 = bbox[0]
Expand All @@ -210,18 +171,28 @@ def geoserver_post_save2(layer_id):
# store the resource to avoid another geoserver call in the post_save
instance.gs_resource = gs_resource

instance.save()

def geoserver_post_save(instance, sender, **kwargs):
"""Save keywords to GeoServer
The way keywords are implemented requires the layer
to be saved to the database before accessing them.
"""
# Don't run this signal handler if it is a tile layer
# Currently only gpkg files containing tiles will have this type & will be served via MapProxy.
if hasattr(instance, 'storeType') and getattr(instance, 'storeType') == 'tileStore':
return

if type(instance) is ResourceBase:
if hasattr(instance, 'layer'):
instance = instance.layer
else:
return instance
return

if instance.storeType == "remoteStore":
# Save layer attributes
set_attributes_from_geoserver(instance)
return instance
return

if not getattr(instance, 'gs_resource', None):
try:
Expand All @@ -234,12 +205,12 @@ def geoserver_post_save2(layer_id):
# Not the error we are looking for, re-raise
raise serr
# If the connection is refused, take it easy.
return instance
return
else:
gs_resource = instance.gs_resource

if gs_resource is None:
return instance
return

if settings.RESOURCE_PUBLISHING:
if instance.is_published != gs_resource.advertised:
Expand Down Expand Up @@ -498,7 +469,6 @@ def command_url(command):
from geonode.catalogue.models import catalogue_post_save
from geonode.layers.models import Layer
catalogue_post_save(instance, Layer)
return instance


def geoserver_pre_save_maplayer(instance, sender, **kwargs):
Expand Down
Loading

0 comments on commit 56550b6

Please sign in to comment.