Beispiel #1
0
def mapindex(req):
    points = SamplingPoint.objects.all().order_by('wqmarea__name','name')
    samples = Sample.objects.all()
    
    if req.method == 'POST':
            form = DateForm(req.POST)
            if form.is_valid():
                start = form.cleaned_data["startdate"]
                end = form.cleaned_data["enddate"]
                failure = form.cleaned_data["failure"]
                                              
                samples = samples.filter(date_taken__range =(start, end))
                points = []
                for sample in samples:
                    if sample.sampling_point in points:
                        # skip point that is already stored.
                        pass
                    else:
                        if failure:
                            if fails_normal_range(sample):
                                points.append(sample.sampling_point)
                        else:
                            points.append(sample.sampling_point)    
    else:
        form = DateForm()
        samples = Sample.objects.filter(sampling_point__in = points)
    
#    for point in samplingpoints:
#        counts.append({"count": Sample.objects.filter(sampling_point = point).count()})             
    
    return render_to_response(req,'wqm/index.html', {
        'samplingpoints': points,
        'form': form,
        'content': render_to_string('wqm/samplepoints.html', {'samplingpoints': points}),
    })
Beispiel #2
0
def mapindex(req):
    samplingpoints = SamplingPoint.objects.all().order_by('wqmarea__name','name')
#    counting the number of abnormal range values..
#    Get the abnormal values from the sample submitted.
    counts = []
    if req.method == 'POST':
            form = DateForm(req.POST)
            if form.is_valid():
                start = form.cleaned_data["startdate"]
                end = form.cleaned_data["enddate"]
#                failure = req.POST.get("failure","")

                samples = Sample.objects.filter(sampling_point__in = samplingpoints)
                samples = samples.filter(date_received__range =(start, end))
#                points = samplingpoints
    else:
        form = DateForm()
        for samplingpoint in samplingpoints:
            samples = Sample.objects.filter(sampling_point__in = samplingpoints)
#        points = samplingpoints

    for point in samplingpoints:
        counts.append({"count": Sample.objects.filter(sampling_point = point).count()})             
    
    return render_to_response(req,'wqm/index.html', {
        'samplingpoints': samplingpoints,
        'form': form,
        'counts': counts,
        'content': render_to_string('wqm/samplepoints.html', {'samplingpoints': samplingpoints}),
    })