forked from GeoNode/django-osgeo-importer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeonode_apis.py
31 lines (23 loc) · 1.18 KB
/
geonode_apis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
from .api import * # noqa
from geonode.api.api import ProfileResource
from geonode.geoserver.helpers import ogc_server_settings
from tastypie.fields import ForeignKey
class UploadedDataResource(UploadedDataResource): # noqa
"""
API for accessing UploadedData.
"""
user = ForeignKey(ProfileResource, 'user')
class UploadedLayerResource(UploadedLayerResource): # noqa
def clean_configuration_options(self, request, obj, configuration_options):
if configuration_options.get('geoserver_store'):
store = configuration_options.get('geoserver_store')
if store.get('type', str).lower() == 'geogig':
store.setdefault('branch', 'master')
store.setdefault('create', 'true')
store.setdefault('name', '{0}-storylayers'.format(request.user.username))
store['geogig_repository'] = os.path.join(ogc_server_settings.GEOGIG_DATASTORE_DIR,
store.get('name'))
if not configuration_options.get('layer_owner'):
configuration_options['layer_owner'] = obj.upload.user.username
return configuration_options