Skip to content
Snippets Groups Projects
Commit c9e6b598 authored by anonymous's avatar anonymous
Browse files

test autocomplete for spatial uri

parent c715b4bf
Branches
Tags
No related merge requests found
......@@ -12,6 +12,8 @@ from ckan.common import config
import urllib
import hashlib
import re
import csv
import urllib2
from ckan.common import request
get_action = logic.get_action
......@@ -215,3 +217,21 @@ def odsh_has_more_facets(facet, limit=None, exclude_active=False):
def odsh_public_url():
return config.get('ckanext.odsh.public_url')
def spatial_extends_available():
mapping_file = config.get('ckanext.odsh.spatial.mapping')
try:
mapping_file = urllib2.urlopen(mapping_file)
except Exception:
raise Exception("Could not load spatial mapping file!")
spatial_text = str()
spatial = str()
cr = csv.reader(mapping_file, delimiter="\t")
result = []
for row in cr:
spatial_text = row[1]
print(spatial_text)
result.append(spatial_text.decode('UTF-8'))
return result
......@@ -289,7 +289,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
'odsh_tracking_id': odsh_helpers.odsh_tracking_id,
'odsh_tracking_url': odsh_helpers.odsh_tracking_url,
'odsh_has_more_facets': odsh_helpers.odsh_has_more_facets,
'odsh_public_url': odsh_helpers.odsh_public_url
'odsh_public_url': odsh_helpers.odsh_public_url,
'odsh_spatial_extends_available': odsh_helpers.spatial_extends_available
}
def after_map(self, map):
......
......@@ -210,6 +210,22 @@ is_required=true,placeholder=_('Enter title')) }}
</div>
</div>
{% set spatial_extends_available = h.odsh_spatial_extends_available() %}
<div class="control-group">
<label class="control-label" for="field-{{field}}">{{_('Spatial uri')}}: <span title="Dieses Feld ist erforderlich" class="control-required">*</span> </label>
<div class="controls">
<div class="row-fluid">
<div class="span6">
<select id="field-{{field}}" data-module="autocomplete">
{% for extend in spatial_extends_available%}
<option value="{{ extend }}" {% if selected_extend %} selected="selected" {% endif %}>{{extend}}</option>
{% endfor %}
</select>
</div>
</div>
</div>
</div>
<!-- field private -->
<div class="control-group">
<label for="field-private" class="control-label">{{ _('Visibility') }}:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment