def test_params(request): from arp.models import WatershedPrioritization from django.contrib.auth.models import User from django.utils import simplejson as json if request.method == 'POST': user = User.objects.get(username='******') wp = WatershedPrioritization(input_targets = request.POST['input_targets'], input_penalties = request.POST['input_penalties'], input_relativecosts='[]', name="Test", user=user) wp.save() t = wp.process_dict(wp.input_targets) p = wp.process_dict(wp.input_penalties) a = json.dumps([t,p]) res = HttpResponse(a, 200) res['Content-Type'] = 'application/json' return res else: return HttpResponse('POST required', status=404)
def test_params(request): from arp.models import WatershedPrioritization from django.contrib.auth.models import User from django.utils import simplejson as json if request.method == 'POST': user = User.objects.get(username='******') wp = WatershedPrioritization( input_targets=request.POST['input_targets'], input_penalties=request.POST['input_penalties'], input_relativecosts='[]', name="Test", user=user) wp.save() t = wp.process_dict(wp.input_targets) p = wp.process_dict(wp.input_penalties) a = json.dumps([t, p]) res = HttpResponse(a, 200) res['Content-Type'] = 'application/json' return res else: return HttpResponse('POST required', status=404)
from django.utils import simplejson as json user = User.objects.get(username='******') wp = WatershedPrioritization(input_targets = json.dumps( { 'widespread---trout': 0.5, 'widespread---lamprey': 0.4, 'widespread---salmon': 0.3, 'widespread---steelhead': 0.2, 'locally endemic': 0.1, } ), input_penalties = json.dumps( { 'widespread---trout': 50, 'widespread---lamprey': 40, 'widespread---salmon': 30, 'widespread---steelhead': 20, 'locally endemic': 10, } ), input_relativecosts='[]', name="Test", user=user) wp.save() print "--------------" print wp.outdir print "--------------"