diff --git a/VIPSWeb/settings.py b/VIPSWeb/settings.py index 444d8bc08d910c49867c849dbd2886cf4ded25ee..d753f5184e5701556601e5dcad74180653d5a681 100755 --- a/VIPSWeb/settings.py +++ b/VIPSWeb/settings.py @@ -128,6 +128,7 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: 'django.contrib.admin', + 'django_extensions', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'tinymce', diff --git a/VIPSWeb/views.py b/VIPSWeb/views.py index e4cb71dd4e64da3d4cfa2a52ae8ec5c33f84c03b..e12e45b25066cae1066a71173493185478c80e2a 100755 --- a/VIPSWeb/views.py +++ b/VIPSWeb/views.py @@ -83,6 +83,7 @@ def maintenance(request): @cache_page(60 * 10) @gzip_page def vipslogicproxy(request, path): + """ Proxy to use cross domain Ajax GET and POST requests request: Django request object @@ -96,6 +97,8 @@ def vipslogicproxy(request, path): else: return HttpResponseNotAllowed("Permitted methods are POST and GET") params = request.urlencode() + + #print "Params:" + params try: url = "%s://%s/%s" % (settings.VIPSLOGIC_PROTOCOL, settings.VIPSLOGIC_SERVER_NAME,path) diff --git a/observations/static/observations/js/observationList.js b/observations/static/observations/js/observationList.js index 054a89e2e7fb8c2ecfe8f82218f70451ca8c2a37..4e849cf834915f95cf027c65cb7026262227691b 100644 --- a/observations/static/observations/js/observationList.js +++ b/observations/static/observations/js/observationList.js @@ -134,6 +134,10 @@ var initMap = function( { params.push("cropCategoryId=" + cropCategoryId); } + if(settings.userUuid != null) + { + params.push("userUUID=" + settings.userUuid); + } // Get observations from backend $.getJSON( "/vipslogicproxy/rest/observation/list/filter/" + organizationId + (params.length > 0 ? "?" + params.join("&") : ""), function( data ) { @@ -211,24 +215,40 @@ var displayFeatureDetails = function(pixel, coordinate) { var renderObservationFeatures = function() { var geoJSON = {"type":"FeatureCollection","features":[]}; + for(var i=0;i<allObservations.length;i++) { var observation = allObservations[i]; var obsFeatures = null; // Showing only publicly shared observations with geolocation information - if(!observation.locationIsPrivate && observation.geoInfo !== null && observation.geoInfo.trim() !== "") - { - obsFeatures = JSON.parse(observation.geoInfo).features; - } - else + if(observation.locationIsPrivate) { - continue; + continue; } - for(var j=0; j<obsFeatures.length; j++) + // Have we got geoInfo to show? + if(observation.geoInfo !== null && observation.geoInfo.trim() !== "") { - geoJSON.features.push(obsFeatures[j]); + obsFeatures = JSON.parse(observation.geoInfo).features; + if(obsFeatures !== null) + { + // We have parsed geoinfo successfully. + // If the observation has registered a polygonService, + // that means that the location should be masked by this + // service (for privacy reasons). Otherwise: Add as-is + //if(observation.polygonService !== undefined && observation.polygonService !== null) + //{ + // maskedFeatures.push(obsFeatures[0]); // Using only first feature for simplicity + //} + //else + //{ + for(var j=0; j<obsFeatures.length; j++) + { + geoJSON.features.push(obsFeatures[j]); + } + //} + } } } @@ -239,6 +259,7 @@ var renderObservationFeatures = function() }); observationLayer.getSource().clear(); observationLayer.getSource().addFeatures(drawnfeatures); + //console.info(maskedFeatures); } /** diff --git a/observations/templates/observations/detail.html b/observations/templates/observations/detail.html index 40f4aa9b46d2026571e490c8a2486c3d990ca685..49015d4e5a22fa480407e6adec557dec6ef04ec2 100755 --- a/observations/templates/observations/detail.html +++ b/observations/templates/observations/detail.html @@ -60,7 +60,8 @@ <script type="text/javascript" src="{% static "observations/js/observationViewMap.js" %}"></script> <script type="text/javascript"> $(document).ready(function() { - $.getJSON( "/vipslogicproxy/rest/observation/{{observation_id}}/" , function( observation ) { + var uuidParam = settings.userUuid != null ? "?userUUID=" + settings.userUuid : ""; + $.getJSON( "/vipslogicproxy/rest/observation/{{observation_id}}/" + uuidParam , function( observation ) { //console.log(observation); document.getElementById("organismName").innerHTML = getLocalizedOrganismName(observation.organism) + " <i>(" + observation.organism.latinName + ")</i>"; document.getElementById("cropOrganismName").innerHTML = getLocalizedOrganismName(observation.cropOrganism) + " <i>(" + observation.cropOrganism.latinName + ")</i>"; diff --git a/requirements.txt b/requirements.txt index b937bd70cb49aa881324a92c309a9b16fe4f9e52..c231a49cb1dac1e18c42deee4a70160926608c34 100755 --- a/requirements.txt +++ b/requirements.txt @@ -23,4 +23,5 @@ Pillow requests==2.6.0 django-tinymce==2.8.0 python-dateutil==1.5 -selenium +django-extensions +selenium \ No newline at end of file