def getInteractionGroups(request, theStudyID): """ Shows the interaction groups and allows for exportation of that interaction group shape files via zip file """ siteDictionary = getDictionary(request) if request.method == "POST": form_interaction_to_be_exported = InteractionToBeExportedForm( request.POST, error_class=DivErrorList, auto_id="id_%s" ) if form_interaction_to_be_exported.is_valid(): interaction_group_pk = form_interaction_to_be_exported.cleaned_data["interaction_to_be_exported"] interactionGroup = get_object_or_404(AnimalInteractionGroup, pk=interaction_group_pk) return HttpResponseRedirect("/media/" + str(interactionGroup.zip_file)) else: theStudy = get_object_or_404(Study, pk=theStudyID) interactionGroups = AnimalInteractionGroup.objects.all() studyInteractionGroups = [] for group in interactionGroups: if theStudy == group.study: studyInteractionGroups.append(group) siteDictionary["studyInteractionGroups"] = studyInteractionGroups siteDictionary["study"] = theStudy form_interaction_to_be_exported = InteractionToBeExportedForm() siteDictionary["form_interaction_to_be_exported"] = form_interaction_to_be_exported return render_to_response( "export_interaction_groups.html", siteDictionary, context_instance=RequestContext(request) )
def getKMLForAllCollarPoints(request, theCollarID): theCollar = get_object_or_404(Collar, collarID=theCollarID) dataPoints = CollarData.objects.filter(collar=theCollar) siteDictionary = getDictionary(request) siteDictionary['dataPoints'] = dataPoints siteDictionary['theCollar'] = theCollar return render_to_kml('dataPoints.kml', siteDictionary, context_instance=RequestContext(request))
def interactions(request): """ View for export_interactions """ siteDictionary = getDictionary(request) siteDictionary["studies"] = Study.objects.all() return render_to_response("export_interactions.html", siteDictionary, context_instance=RequestContext(request))
def getCollarData(request, theCollarID): """ Returns a specific collars Collar Data """ siteDictionary = getDictionary(request) siteDictionary['collar'] = get_object_or_404(Collar, collarID=theCollarID) siteDictionary['collarDatas']=CollarData.objects.filter(collar=theCollar) return render_to_response('collar_data.html', siteDictionary, context_instance=RequestContext(request))
def getGroupInteractions(request, theGroupID): """ Shows the interaction groups specific interactions in view """ siteDictionary = getDictionary(request) theGroup = get_object_or_404(AnimalInteractionGroup, pk=theGroupID) interactions = AnimalInteraction.objects.all() groupInteractions = [] for i in interactions: if theGroup == i.interaction_group: groupInteractions.append(i) siteDictionary["groupInteractions"] = groupInteractions siteDictionary["group"] = theGroup return render_to_response( "export_interaction_groupInteractions.html", siteDictionary, context_instance=RequestContext(request) )
def export(request): """ Exports collar CSV data including collar and weather data. Checks to see if it is a multiple export or a single collar export. Currently does NOT support SHAPE exports """ siteDictionary = getDictionary(request) if request.method == 'POST': form_collars = ExportCollarDataForm(request.POST, error_class=DivErrorList, auto_id='%id_s') form_collars_filter = ExportCollarDataFilterForm(request.POST, error_class=DivErrorList, auto_id='id_%s') form_weather_filter = ExportWeatherDataFilterForm(request.POST, error_class=DivErrorList, auto_id='id_%s') form_export_type = ExportTypeForm(request.POST, error_class=DivErrorList, auto_id='id_%s') if form_collars.is_valid() and form_collars_filter.is_valid() and form_weather_filter.is_valid() and form_export_type.is_valid(): is_multi_csv = form_export_type.cleaned_data['is_multi_csv'] #is_multi_shape = form_export_type.cleaned_data['is_multi_shape'] is_single_csv = form_export_type.cleaned_data['is_single_csv'] #is_single_shape = form_export_type.cleaned_data['is_single_shape'] single_collar = form_export_type.cleaned_data['single_export'] if is_multi_csv: print "Is Multiple CSV Export" return getMultiCollarCSV(request, form_collars, form_collars_filter, form_weather_filter) if is_single_csv: print "Is Single CSV Export" return getSingleCollarCSV(request, single_collar, form_collars_filter, form_weather_filter) """ if is_multi_shape: print "Is Multipe SHAPE Export" return getSingleCollarCSV(request, single_collar, form_collars_filter, form_weather_filter) if is_single_shape: print "Is Single SHAPE Export" return getSingleCollarCSV(request, single_collar, form_collars_filter, form_weather_filter) """ else: form_collars = ExportCollarDataForm() form_collars_filter = ExportCollarDataFilterForm(auto_id='id_collar_filter_%s') form_weather_filter = ExportWeatherDataFilterForm(auto_id='id_weather_filter_%s') form_export_type = ExportTypeForm() siteDictionary['form_collars'] = form_collars siteDictionary['form_collars_filter'] = form_collars_filter siteDictionary['form_weather_filter'] = form_weather_filter siteDictionary['form_export_type'] = form_export_type return render_to_response('export_collar.html', siteDictionary, context_instance=RequestContext(request))
def uploadCollarDataFile_Success(request): siteDictionary = getDictionary(request) return render_to_response('upload_collar_success.html', siteDictionary, context_instance=RequestContext(request))