Skip to content

Commit

Permalink
Merge branch 'PATCHES_OCT17_001' of https://github.com/GeoNode/geonode
Browse files Browse the repository at this point in the history
…into monitoring

# Conflicts:
#	geonode/layers/views.py
#	geonode/local_settings.py.geoserver.sample
#	geonode/templates/base.html
#	requirements.txt
#	setup.py
  • Loading branch information
Alessio Fabiani committed Oct 11, 2017
2 parents dc65d11 + 0b3a4cc commit a58a395
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 155 deletions.
38 changes: 19 additions & 19 deletions geonode/geoserver/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,23 +969,22 @@ def _create_db_featurestore(name, data, overwrite=False, charset="UTF-8", worksp
ds_exists = True
except FailedRequestError:
ds = cat.create_datastore(dsname, workspace=workspace)

db = ogc_server_settings.datastore_db
db_engine = 'postgis' if \
'postgis' in db['ENGINE'] else db['ENGINE']
ds.connection_parameters.update(
{'validate connections': 'true',
'max connections': '10',
'min connections': '1',
'fetch size': '1000',
'host': db['HOST'],
'port': db['PORT'] if isinstance(
db['PORT'], basestring) else str(db['PORT']) or '5432',
'database': db['NAME'],
'user': db['USER'],
'passwd': db['PASSWORD'],
'dbtype': db_engine}
)
db = ogc_server_settings.datastore_db
db_engine = 'postgis' if \
'postgis' in db['ENGINE'] else db['ENGINE']
ds.connection_parameters.update(
{'validate connections': 'true',
'max connections': '10',
'min connections': '1',
'fetch size': '1000',
'host': db['HOST'],
'port': db['PORT'] if isinstance(
db['PORT'], basestring) else str(db['PORT']) or '5432',
'database': db['NAME'],
'user': db['USER'],
'passwd': db['PASSWORD'],
'dbtype': db_engine}
)

if ds_exists:
ds.save_method = "PUT"
Expand All @@ -997,7 +996,8 @@ def _create_db_featurestore(name, data, overwrite=False, charset="UTF-8", worksp
cat.add_data_to_store(ds, name, data,
overwrite=overwrite,
charset=charset)
return ds, cat.get_resource(name, store=ds, workspace=workspace)
resource = cat.get_resource(name, store=ds, workspace=workspace)
return ds, resource
except Exception:
msg = _("An exception occurred loading data to PostGIS")
msg += "- %s" % (sys.exc_info()[1])
Expand Down Expand Up @@ -1419,7 +1419,7 @@ def ensure_defaults(self, alias):
server.setdefault('GEOGIG_DATASTORE_DIR', str())

for option in ['MAPFISH_PRINT_ENABLED', 'PRINT_NG_ENABLED', 'GEONODE_SECURITY_ENABLED',
'BACKEND_WRITE_ENABLED']:
'GEOFENCE_SECURITY_ENABLED', 'BACKEND_WRITE_ENABLED']:
server.setdefault(option, True)

for option in ['GEOGIG_ENABLED', 'WMST_ENABLED', 'WPS_ENABLED']:
Expand Down
1 change: 1 addition & 0 deletions geonode/geoserver/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def setUp(self):
'MAPFISH_PRINT_ENABLED': True,
'PRINT_NG_ENABLED': True,
'GEONODE_SECURITY_ENABLED': True,
'GEOFENCE_SECURITY_ENABLED': True,
'GEOGIG_ENABLED': False,
'WMST_ENABLED': False,
'BACKEND_WRITE_ENABLED': True,
Expand Down
7 changes: 7 additions & 0 deletions geonode/layers/templates/layers/layer_geoext_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@

listeners: {
"ready": function() {
app.mapPanel.map.getMaxExtent = function() {
return new OpenLayers.Bounds(-80150033.36,-80150033.36,80150033.36,80150033.36);
}
app.mapPanel.map.getMaxResolution = function() {
return 626172.135625;
}

var map = app.mapPanel.map;
var layer = app.map.layers.slice(-1)[0];

Expand Down
2 changes: 1 addition & 1 deletion geonode/layers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ def layer_upload(request, template='upload/layer_upload.html'):
form.cleaned_data["base_file"].name)
title = slugify(name_base.replace(".", "_"))
name = slugify(name_base.replace(".", "_"))
saved_layer = None

if form.cleaned_data["abstract"] is not None and len(form.cleaned_data["abstract"]) > 0:
abstract = form.cleaned_data["abstract"]
else:
abstract = "No abstract provided."


try:
# Moved this inside the try/except block because it can raise
# exceptions when unicode characters are present.
Expand Down
115 changes: 1 addition & 114 deletions geonode/local_settings.py.geoserver.sample
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ OGC_SERVER = {
'MAPFISH_PRINT_ENABLED': True,
'PRINT_NG_ENABLED': True,
'GEONODE_SECURITY_ENABLED': True,
'GEOFENCE_SECURITY_ENABLED' : True,
'GEOGIG_ENABLED': False,
'WMST_ENABLED': False,
'BACKEND_WRITE_ENABLED': True,
Expand Down Expand Up @@ -247,120 +248,7 @@ LAYER_PREVIEW_LIBRARY = 'geoext'
# 'RESET_VIEW': False
#}

GEONODE_APPS = (
# GeoNode internal apps
'geonode.people',
'geonode.base',
'geonode.layers',
'geonode.maps',
'geonode.proxy',
'geonode.security',
'geonode.social',
'geonode.catalogue',
'geonode.documents',
'geonode.api',
'geonode.groups',
'geonode.services',

# QGIS Server Apps
# 'geonode_qgis_server',

# GeoServer Apps
# Geoserver needs to come last because
# it's signals may rely on other apps' signals.
'geonode.geoserver',
'geonode.upload',
'geonode.tasks',

)

GEONODE_CONTRIB_APPS = (
# GeoNode Contrib Apps
# 'geonode.contrib.dynamic',
# 'geonode.contrib.exif',
# 'geonode.contrib.favorite',
# 'geonode.contrib.geogig',
# 'geonode.contrib.geosites',
# 'geonode.contrib.nlp',
# 'geonode.contrib.slack',
'geonode.contrib.metadataxsl',
)

GEONODE_APPS = GEONODE_APPS + GEONODE_CONTRIB_APPS

INSTALLED_APPS = (

'modeltranslation',

# Boostrap admin theme
# 'django_admin_bootstrapped.bootstrap3',
# 'django_admin_bootstrapped',

# Apps bundled with Django
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'django.contrib.humanize',
'django.contrib.gis',

# Third party apps

# Utility
'pagination',
'taggit',
'treebeard',
'friendlytagloader',
'geoexplorer',
'leaflet',
'django_extensions',
#'geonode-client',
# 'haystack',
'autocomplete_light',
'mptt',
# 'modeltranslation',
# 'djkombu',
'djcelery',
'kombu.transport.django',

'storages',
'floppyforms',

# Theme
"pinax_theme_bootstrap",
'django_forms_bootstrap',

# Social
'account',
'avatar',
'dialogos',
'agon_ratings',
'announcements',
'actstream',
'user_messages',
'tastypie',
'polymorphic',
'guardian',
'oauth2_provider',
'corsheaders',
) + GEONODE_APPS

# default map projection
# Note: If set to EPSG:4326, then only EPSG:4326 basemaps will work.
DEFAULT_MAP_CRS = "EPSG:900913"

# Where should newly created maps be focused?
DEFAULT_MAP_CENTER = (0, 0)

# How tightly zoomed should newly created maps be?
# 0 = entire world;
# maximum zoom is between 12 and 15 (for Google Maps, coverage varies by area)
DEFAULT_MAP_ZOOM = 0

ALT_OSM_BASEMAPS = os.environ.get('ALT_OSM_BASEMAPS', False)
CARTODB_BASEMAPS = os.environ.get('CARTODB_BASEMAPS', False)
STAMEN_BASEMAPS = os.environ.get('STAMEN_BASEMAPS', False)
Expand Down Expand Up @@ -494,7 +382,6 @@ LOGGING = {
},
}

FREETEXT_KEYWORDS_READONLY = True
MIDDLEWARE_CLASSES += (
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
Expand Down
44 changes: 44 additions & 0 deletions geonode/maps/templates/maps/map_include.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,50 @@
portalConfig: {
height: 600,
renderTo: "the_map"
},

listeners: {
"ready": function() {
app.mapPanel.map.getMaxExtent = function() {
return new OpenLayers.Bounds(-80150033.36,-80150033.36,80150033.36,80150033.36);
}
app.mapPanel.map.getMaxResolution = function() {
return 626172.135625;
}

var map = app.mapPanel.map;
var layer = app.map.layers.slice(-1)[0];

// FIXME(Ariel): Zoom to extent until #1795 is fixed.
//map.zoomToExtent(layer.maxExtent, false)

var bbox = layer.bbox;
if (bbox != undefined)
{
if (!Array.isArray(bbox) && Object.keys(layer.srs) in bbox) {
bbox = bbox[Object.keys(layer.srs)].bbox;
}

var extent = OpenLayers.Bounds.fromArray(bbox);
var zoomToData = function()
{
map.zoomToExtent(extent, false);
app.mapPanel.center = map.center;
app.mapPanel.zoom = map.zoom;
map.events.unregister('changebaselayer', null, zoomToData);
};
map.events.register('changebaselayer',null,zoomToData);
if(map.baseLayer){
map.zoomToExtent(extent, false);
}
}
},
"beforeunload": function() {
if (modified) {
styleEditor.show();
return false;
}
}
}
}, {{ config }});
app = new GeoNode.Viewer(config);
Expand Down
18 changes: 11 additions & 7 deletions geonode/security/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
from guardian.utils import get_user_obj_perms_model
from guardian.shortcuts import assign_perm, get_groups_with_perms


logger = logging.getLogger("geonode.security.models")


ADMIN_PERMISSIONS = [
'view_resourcebase',
'download_resourcebase',
Expand All @@ -55,6 +53,12 @@
'change_layer_style'
]

ogc_server_settings = settings.OGC_SERVER['default']

GEOFENCE_SECURITY_ENABLED = False
if 'GEOFENCE_SECURITY_ENABLED' in ogc_server_settings:
GEOFENCE_SECURITY_ENABLED = ogc_server_settings['GEOFENCE_SECURITY_ENABLED']


def get_users_with_perms(obj):
"""
Expand Down Expand Up @@ -267,7 +271,7 @@ def get_geofence_rules_count():

def set_geofence_invalidate_cache():
"""invalidate GeoFence Cache Rules"""
if settings.OGC_SERVER['default']['GEOFENCE_SECURITY_ENABLED']:
if GEOFENCE_SECURITY_ENABLED:
try:
url = settings.OGC_SERVER['default']['LOCATION']
user = settings.OGC_SERVER['default']['USER']
Expand All @@ -290,7 +294,7 @@ def set_geofence_invalidate_cache():

def set_geofence_all(instance):
"""assign access permissions to all users"""
if settings.OGC_SERVER['default']['GEOFENCE_SECURITY_ENABLED']:
if GEOFENCE_SECURITY_ENABLED:
resource = instance.get_self_resource()

if hasattr(resource, "layer"):
Expand Down Expand Up @@ -356,7 +360,7 @@ def set_geofence_all(instance):

def set_geofence_owner(instance, username, view_perms=False, download_perms=False):
"""assign access permissions to owner user"""
if settings.OGC_SERVER['default']['GEOFENCE_SECURITY_ENABLED']:
if GEOFENCE_SECURITY_ENABLED:
resource = instance.get_self_resource()

if hasattr(resource, "layer"):
Expand Down Expand Up @@ -469,7 +473,7 @@ def set_geofence_owner(instance, username, view_perms=False, download_perms=Fals

def set_geofence_group(instance, groupname, view_perms=False, download_perms=False):
"""assign access permissions to owner group"""
if settings.OGC_SERVER['default']['GEOFENCE_SECURITY_ENABLED']:
if GEOFENCE_SECURITY_ENABLED:
resource = instance.get_self_resource()

if groupname and hasattr(resource, "layer"):
Expand Down Expand Up @@ -592,7 +596,7 @@ def remove_object_permissions(instance):

if hasattr(resource, "layer"):
try:
if settings.OGC_SERVER['default']['GEOFENCE_SECURITY_ENABLED']:
if GEOFENCE_SECURITY_ENABLED:
# Scan GeoFence Rules associated to the Layer
"""
curl -u admin:geoserver
Expand Down
Loading

0 comments on commit a58a395

Please sign in to comment.