Skip to content

Commit 56550b6

Browse files
author
afabiani
committed
- GeoNode Stable and Updated 2.7.x Branch / NO RabbitMQ Notifications / integrated with GeoServer 2.10.x
1 parent 4fb7f7e commit 56550b6

28 files changed

+93
-397
lines changed

.gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ slave
9696

9797
# virtual env
9898
venv
99-
100-
celerybeat-*
101-
manage.py
102-
10399
geonode/bin/
104100
geonode/djcelery/
105101
geonode/include/

Dockerfile

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ MAINTAINER GeoNode development team
44
COPY requirements.txt /usr/src/app/
55
RUN pip install -r requirements.txt
66

7-
RUN pip install .
8-
97
EXPOSE 8000
108
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ sync: up
1212
docker-compose exec django django-admin.py loaddata sample_admin
1313
docker-compose exec django django-admin.py loaddata geonode/base/fixtures/default_oauth_apps_docker.json
1414
docker-compose exec django django-admin.py loaddata geonode/base/fixtures/initial_data.json
15-
docker-compose exec django django-admin.py layer_notice_types
1615

1716
migrate:
1817
django-admin.py migrate --noinput

README

+12-12
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ Or if you want to use the provided Makefile::
6060
**Note:**
6161
For deveployment you need to add `geonode` alias into `/ect/hosts/` file as following:
6262

63-
64-
$ sudo vim /etc/hosts
65-
##
66-
# Host Database
67-
#
68-
# localhost is used to configure the loopback interface
69-
# when the system is booting. Do not change this entry.
70-
##
71-
127.0.0.1 localhost geonode
72-
255.255.255.255 broadcasthost
73-
::1 localhost
74-
63+
```
64+
$ sudo vim /etc/hosts
65+
##
66+
# Host Database
67+
#
68+
# localhost is used to configure the loopback interface
69+
# when the system is booting. Do not change this entry.
70+
##
71+
127.0.0.1 localhost geonode
72+
255.255.255.255 broadcasthost
73+
::1 localhost
74+
```
7575
To access GeoNode just enter the following url: `http://geonode/` on your web browser.
7676
For GeoServer: `http://geonode/geoserver/web/`
7777

docker-compose.override.yml

-10
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,3 @@ services:
2020
- '.:/usr/src/app'
2121
environment:
2222
- DEBUG=True
23-
24-
consumers:
25-
build: .
26-
# Loading the app is defined here to allow for
27-
# autoreload on changes it is mounted on top of the
28-
# old copy that docker added when creating the image
29-
volumes:
30-
- '.:/usr/src/app'
31-
environment:
32-
- DEBUG=True

docker-compose.yml

+1-12
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,11 @@ services:
2929
command: celery worker --app=geonode.celery_app:app -B -l INFO
3030
env_file:
3131
- ./scripts/docker/env/production/django.env
32-
33-
consumers:
34-
image: geonode/django
35-
links:
36-
- rabbitmq
37-
- postgres
38-
- elasticsearch
39-
command: python manage.py runmessaging
40-
env_file:
41-
- ./scripts/docker/env/production/django.env
4232

4333
geoserver:
44-
image: piensalabs/geoserver:pubsub
34+
image: geonode/geoserver:alias
4535
links:
4636
- postgres
47-
- rabbitmq
4837
ports:
4938
- "8080"
5039
volumes_from:

geonode/base/populate_test_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def create_models(type=None):
126126
from django.contrib.auth.models import Group
127127
map_data, user_data, people_data, layer_data, document_data = create_fixtures()
128128
anonymous_group, created = Group.objects.get_or_create(name='anonymous')
129-
u, _ = get_user_model().objects.get_or_create(username='admin', defaults=dict(is_superuser=True, first_name='admin'))
129+
u, _ = get_user_model().objects.get_or_create(username='admin', is_superuser=True, first_name='admin')
130130
u.set_password('admin')
131131
u.save()
132132
users = []

geonode/catalogue/models.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,21 @@ def catalogue_post_save(instance, sender, **kwargs):
100100

101101

102102
def catalogue_pre_save(instance, sender, **kwargs):
103-
pass
103+
"""Send information to catalogue"""
104+
record = None
105+
106+
# if the layer is in the catalogue, try to get the distribution urls
107+
# that cannot be precalculated.
108+
try:
109+
catalogue = get_catalogue()
110+
record = catalogue.get_record(instance.uuid)
111+
except EnvironmentError, err:
112+
msg = 'Could not connect to catalogue to save information for layer "%s"' % instance.name
113+
LOGGER.warn(msg, err)
114+
raise err
115+
116+
if record is None:
117+
return
104118

105119

106120
if 'geonode.catalogue' in settings.INSTALLED_APPS:

geonode/documents/tests.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from geonode.base.populate_test_data import create_models
4242

4343

44-
class DocumentsTest(TestCase):
44+
class LayersTest(TestCase):
4545
fixtures = ['initial_data.json', 'bobby']
4646

4747
perm_spec = {
@@ -68,7 +68,7 @@ def test_create_document_with_no_rel(self):
6868
self.imgfile.read(),
6969
'image/gif')
7070

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

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

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

103-
superuser = get_user_model().objects.filter(is_superuser=True)[0]
103+
superuser = get_user_model().objects.get(pk=2)
104104
c = Document.objects.create(doc_url="http://geonode.org/map.pdf",
105105
owner=superuser,
106106
title="GeoNode Map",

geonode/geoserver/signals.py

+29-59
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
from django.utils.translation import ugettext
2929
from django.conf import settings
30-
from django.forms.models import model_to_dict
3130

3231
from geonode.geoserver.ows import wcs_links, wfs_links, wms_links
3332
from geonode.geoserver.helpers import cascading_delete, set_attributes_from_geoserver
@@ -38,19 +37,12 @@
3837
from geonode.base.models import ResourceBase
3938
from geonode.base.models import Link
4039
from geonode.people.models import Profile
40+
4141
from geoserver.layer import Layer as GsLayer
42-
from geonode.social.signals import json_serializer_producer
4342

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

4645

47-
def geoserver_delete(typename):
48-
# cascading_delete should only be called if
49-
# ogc_server_settings.BACKEND_WRITE_ENABLED == True
50-
if getattr(ogc_server_settings, "BACKEND_WRITE_ENABLED", True):
51-
cascading_delete(gs_catalog, typename)
52-
53-
5446
def geoserver_pre_delete(instance, sender, **kwargs):
5547
"""Removes the layer from GeoServer
5648
"""
@@ -63,46 +55,21 @@ def geoserver_pre_delete(instance, sender, **kwargs):
6355

6456

6557
def geoserver_pre_save(instance, sender, **kwargs):
66-
"""
67-
move the content of this task to post save signal
68-
:param instance:
69-
:param sender:
70-
:param kwargs:
71-
:return:
72-
"""
73-
pass
74-
75-
76-
def geoserver_post_save(instance, sender, **kwargs):
77-
from geonode.messaging import producer
78-
instance_dict = model_to_dict(instance)
79-
payload = json_serializer_producer(instance_dict)
80-
producer.geoserver_upload_layer(payload)
81-
82-
83-
def geoserver_post_save2(layer_id):
84-
"""Save keywords to GeoServer
85-
86-
The way keywords are implemented requires the layer
87-
to be saved to the database before accessing them.
88-
"""
8958
"""Send information to geoserver.
9059
91-
The attributes sent include:
60+
The attributes sent include:
9261
93-
* Title
94-
* Abstract
95-
* Name
96-
* Keywords
97-
* Metadata Links,
98-
* Point of Contact name and url
99-
"""
62+
* Title
63+
* Abstract
64+
* Name
65+
* Keywords
66+
* Metadata Links,
67+
* Point of Contact name and url
68+
"""
10069

101-
from geonode.layers.models import Layer
102-
instance = Layer.objects.get(id=layer_id)
10370
# Don't run this signal if is a Layer from a remote service
10471
if getattr(instance, "service", None) is not None:
105-
return instance
72+
return
10673

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

11986
# There is no need to process it if there is not file.
12087
if base_file is None:
121-
return instance
122-
88+
return
12389
gs_name, workspace, values, gs_resource = geoserver_upload(instance,
12490
base_file.file.path,
12591
instance.owner,
@@ -129,17 +95,13 @@ def geoserver_post_save2(layer_id):
12995
abstract=instance.abstract,
13096
# keywords=instance.keywords,
13197
charset=instance.charset)
132-
13398
# Set fields obtained via the geoserver upload.
13499
instance.name = gs_name
135100
instance.workspace = workspace
136-
instance.store = values['store']
137101
# Iterate over values from geoserver.
138102
for key in ['typename', 'store', 'storeType']:
139103
setattr(instance, key, values[key])
140104

141-
instance.save()
142-
143105
if not gs_resource:
144106
gs_resource = gs_catalog.get_resource(
145107
instance.name,
@@ -160,8 +122,7 @@ def geoserver_post_save2(layer_id):
160122
gs_resource.metadata_links = metadata_links
161123
# gs_resource should only be called if
162124
# ogc_server_settings.BACKEND_WRITE_ENABLED == True
163-
if gs_resource and getattr(ogc_server_settings, "BACKEND_WRITE_ENABLED",
164-
True):
125+
if gs_resource and getattr(ogc_server_settings, "BACKEND_WRITE_ENABLED", True):
165126
gs_catalog.save(gs_resource)
166127

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

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

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

213-
instance.save()
174+
175+
def geoserver_post_save(instance, sender, **kwargs):
176+
"""Save keywords to GeoServer
177+
178+
The way keywords are implemented requires the layer
179+
to be saved to the database before accessing them.
180+
"""
181+
# Don't run this signal handler if it is a tile layer
182+
# Currently only gpkg files containing tiles will have this type & will be served via MapProxy.
183+
if hasattr(instance, 'storeType') and getattr(instance, 'storeType') == 'tileStore':
184+
return
214185

215186
if type(instance) is ResourceBase:
216187
if hasattr(instance, 'layer'):
217188
instance = instance.layer
218189
else:
219-
return instance
190+
return
220191

221192
if instance.storeType == "remoteStore":
222193
# Save layer attributes
223194
set_attributes_from_geoserver(instance)
224-
return instance
195+
return
225196

226197
if not getattr(instance, 'gs_resource', None):
227198
try:
@@ -234,12 +205,12 @@ def geoserver_post_save2(layer_id):
234205
# Not the error we are looking for, re-raise
235206
raise serr
236207
# If the connection is refused, take it easy.
237-
return instance
208+
return
238209
else:
239210
gs_resource = instance.gs_resource
240211

241212
if gs_resource is None:
242-
return instance
213+
return
243214

244215
if settings.RESOURCE_PUBLISHING:
245216
if instance.is_published != gs_resource.advertised:
@@ -498,7 +469,6 @@ def command_url(command):
498469
from geonode.catalogue.models import catalogue_post_save
499470
from geonode.layers.models import Layer
500471
catalogue_post_save(instance, Layer)
501-
return instance
502472

503473

504474
def geoserver_pre_save_maplayer(instance, sender, **kwargs):

0 commit comments

Comments
 (0)