Skip to content
Snippets Groups Projects
Commit b2eb9540 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Merge branch 'Observation_masking' into 'develop'

Observation masking

See merge request !5
parents 9cc6a346 71fa2a7a
No related branches found
No related tags found
1 merge request!5Observation masking
......@@ -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',
......
......@@ -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)
......
......@@ -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);
}
/**
......
......@@ -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>";
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment