def set_report_headers(self): header = list(LocationTypeDetails.get_ordered_types().exclude( name__iexact="country").values_list('name', flat=True)) other_headers = [ 'Household ID', 'Name', 'Age', 'Month of Birth', 'Year of Birth', 'Gender' ] header.extend(other_headers) header.extend(self.question_headers()) return header
def clean_headers_location_type_order(self, headers): headers = UploadService.remove_trailing('Name', in_array=headers, exclude='Code') ordered_types = [ type.name for type in LocationTypeDetails.get_ordered_types().exclude( name__iexact='country') ] if not ordered_types == headers: raise ValidationError( 'Location types not in order. Please refer to input file format.' )
def list_weights(request): location_weights = LocationWeight.objects.all() surveys = Survey.objects.all() survey = None selected_location = None params = request.GET if contains_key(params, 'survey'): survey = Survey.objects.get(id=params['survey']) location_weights = location_weights.filter(survey=survey) if contains_key(params, 'location'): selected_location = Location.objects.get(id=params['location']) location_weights = location_weights.filter(location=selected_location) location_types = LocationTypeDetails.get_ordered_types().exclude(name__iexact="country") context = {'location_weights': location_weights, 'location_types': location_types, 'location_data': LocationWidget(selected_location), 'surveys': surveys, 'selected_survey': survey, 'action': 'list_weights_page', 'request': request} return render(request, 'locations/weights/index.html', context)
def clean_headers_location_type_order(self, headers): headers = UploadService.remove_trailing('Name', in_array=headers, exclude='Code') ordered_types = [type.name for type in LocationTypeDetails.get_ordered_types().exclude(name__iexact='country')] if not ordered_types == headers: raise ValidationError('Location types not in order. Please refer to input file format.')
def set_report_headers(self): header = list(LocationTypeDetails.get_ordered_types().exclude(name__iexact="country").values_list('name', flat=True)) other_headers = ['Household ID', 'Name', 'Age', 'Month of Birth', 'Year of Birth', 'Gender'] header.extend(other_headers) header.extend(self.question_headers()) return header