def test_location_widget_returns_two_levels_in_the_location_hierarchy_given_two_levels( self): village = LocationType.objects.create(name='Village', parent=self.city, slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) Location.objects.create(name='Bukoto', parent=self.kampala_city, type=village) some_type = LocationType.objects.create(name='Sometype', parent=village, slug='sometype') LocationTypeDetails.objects.create(location_type=some_type, country=self.uganda) location_widget = LocationWidget(selected_location=self.kampala_city, level=3) widget_data = location_widget.get_widget_data() self.assertEqual(2, len(widget_data.keys())) self.assertNotIn('country', widget_data.keys()) self.assertNotIn('sometype', widget_data.keys()) self.assertIn('village', widget_data.keys()) self.assertIn(self.kampala_city, widget_data['city'])
def test_location_widget_appends_ea_data_in_place_of_the_lowest_location_level( self): village = LocationType.objects.create(name='Village', parent=self.city, slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) bukoto = Location.objects.create(name='Bukoto123', parent=self.kampala_city, type=village) some_type = LocationType.objects.create(name='Sometype', parent=village, slug='sometype') LocationTypeDetails.objects.create(location_type=some_type, country=self.uganda) kisasi = Location.objects.create(name='Kisaasi', parent=bukoto, type=some_type) ea1 = EnumerationArea.objects.create(name="EA Kisasi1") ea2 = EnumerationArea.objects.create(name="EA Kisasi2") ea1.locations.add(kisasi) ea2.locations.add(kisasi) location_widget = LocationWidget(selected_location=bukoto, ea=ea1, level=3) widget_data = location_widget.get_ea_data()
def test_location_widget_appends_siblings_ea_if_ea_is_directly_under_parish( self): village = LocationType.objects.create(name='Village', parent=self.city, slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) bukoto = Location.objects.create(name='Bukoto', parent=self.kampala_city, type=village) some_type = LocationType.objects.create(name='Sometype', parent=village, slug='sometype') LocationTypeDetails.objects.create(location_type=some_type, country=self.uganda) kisasi = Location.objects.create(name='Kisaasi', parent=bukoto, type=some_type) kisasi_2 = Location.objects.create(name='Kisaasi 2', parent=bukoto, type=some_type) ea1 = EnumerationArea.objects.create(name="EA Kisasi1") ea1.locations.add(kisasi) ea1.locations.add(kisasi_2) location_widget = LocationWidget(selected_location=bukoto, ea=ea1, level=2) widget_data = location_widget.get_ea_data()
def test_location_widget_does_not_append_ea_data_of_other_parishes(self): village = LocationType.objects.create(name='Village', slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) bukoto = Location.objects.create(name='Bukoto', tree_parent=self.kampala_city, type=village) some_type = LocationType.objects.create(name='Sometype', slug='sometype') LocationTypeDetails.objects.create(location_type=some_type, country=self.uganda) kisasi = Location.objects.create(name='Kisaasi', tree_parent=bukoto, type=some_type) kisasi_2 = Location.objects.create(name='Kisaasi 2', tree_parent=bukoto, type=some_type) kisasi_3 = Location.objects.create(name='Kisaasi 2', tree_parent=bukoto, type=some_type) ea1 = EnumerationArea.objects.create(name="EA Kisasi1") ea2 = EnumerationArea.objects.create(name="EA Kisasi2") ea1.locations.add(kisasi) ea1.locations.add(kisasi_2) ea2.locations.add(kisasi_3) bukoto_2 = Location.objects.create(name='Bukoto 2', tree_parent=self.kampala_city, type=village) kisasi_of_bukoto_2 = Location.objects.create(name='Kisaasi', tree_parent=bukoto_2, type=some_type) ea3 = EnumerationArea.objects.create(name="EA Kisasi of Bukoto 2") ea3.locations.add(kisasi_of_bukoto_2) location_widget = LocationWidget(selected_location=bukoto) widget_data = location_widget.get_ea_data() self.assertEqual(2, len(widget_data)) self.assertIn(ea1, widget_data) self.assertIn(ea2, widget_data) self.assertNotIn(ea3, widget_data)
def test_location_widget_appends_ea_data_if_selected_location_is_parish_even_if_no_selected_ea( self): village = LocationType.objects.create(name='Village', slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) bukoto = Location.objects.create(name='Bukoto', tree_parent=self.kampala_city, type=village) some_type = LocationType.objects.create(name='Sometype', slug='sometype') LocationTypeDetails.objects.create(location_type=some_type, country=self.uganda) kisasi = Location.objects.create(name='Kisaasi', tree_parent=bukoto, type=some_type) kisasi_2 = Location.objects.create(name='Kisaasi 2', tree_parent=bukoto, type=some_type) kisasi_3 = Location.objects.create(name='Kisaasi 2', tree_parent=bukoto, type=some_type) ea1 = EnumerationArea.objects.create(name="EA Kisasi1") ea2 = EnumerationArea.objects.create(name="EA Kisasi2") ea1.locations.add(kisasi) ea1.locations.add(kisasi_2) ea2.locations.add(kisasi_3) location_widget = LocationWidget(selected_location=bukoto) widget_data = location_widget.get_ea_data() self.assertEqual(2, len(widget_data)) self.assertIn(ea1, widget_data) self.assertIn(ea2, widget_data)
def test_location_widget_knows_next_location_in_hierarchy(self): village = LocationType.objects.create(name='Village', slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) bukoto = Location.objects.create(name='Bukoto', tree_parent=self.kampala_city, type=village) location_widget = LocationWidget(selected_location=self.kampala_city) self.assertEqual(village, location_widget.next_type_in_hierarchy()) location_widget = LocationWidget(selected_location=bukoto) self.assertIsNone(location_widget.next_type_in_hierarchy())
def test_sorted_by_hierachy_removes_country_types(self): slugs = list(LocationType.objects.all().values_list('slug', flat=True)) old_data = {} for slug in slugs: old_data[slug] = 'dummy haha' + str(randint) location_widget = LocationWidget(selected_location=self.kampala_city) new_data = location_widget.sorted_by_hierarchy(old_data) self.assertNotIn('country', new_data.keys()) [self.assertEqual(old_data[key], new_data[key]) for key in new_data.keys()]
def test_gets_second_level_location_ie_below_country_if_no_selected_location_given_excluding_the_lowest_level(self): village = LocationType.objects.create(name='Village', slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) Location.objects.create(name="Kyanja", tree_parent=self.kampala_city, type=village) location_widget = LocationWidget(None) widget_data = location_widget.get_widget_data() self.assertEqual(2, len(widget_data.keys())) self.assertNotIn('country', widget_data.keys()) self.assertNotIn("village", widget_data.keys()) self.assertIn(self.kampala, widget_data['district']) self.assertEqual([], widget_data['city'])
def test_gets_location_sorted_by_hierarchy_given_a_location_with_parents(self): village = LocationType.objects.create(name='Village', slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) kyanja = Location.objects.create(name="Kyanja", tree_parent=self.kampala_city, type=village) Location.objects.create(name="Kyanja child", tree_parent=kyanja, type=village) location_widget = LocationWidget(selected_location=self.kampala_city) widget_data = location_widget.get_widget_data() self.assertEqual(2, len(widget_data.keys())) self.assertIn(self.kampala_city, widget_data['city']) self.assertIn(self.kampala, widget_data['district']) self.assertNotIn("village", widget_data.keys()) self.assertNotIn('country', widget_data.keys())
def test_sorted_by_hierachy_removes_country_types(self): slugs = list(LocationType.objects.all().values_list('slug', flat=True)) old_data = {} for slug in slugs: old_data[slug] = 'dummy haha' + str(randint) location_widget = LocationWidget(selected_location=self.kampala_city) new_data = location_widget.sorted_by_hierarchy(old_data) self.assertNotIn('country', new_data.keys()) [ self.assertEqual(old_data[key], new_data[key]) for key in new_data.keys() ]
def test_location_widget_appends_empty_ea_data_if_level_is_set(self): village = LocationType.objects.create(name='Village', slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) bukoto = Location.objects.create(name='Bukoto', tree_parent=self.kampala_city, type=village) some_type = LocationType.objects.create(name='Sometype', slug='sometype') LocationTypeDetails.objects.create(location_type=some_type, country=self.uganda) kisasi = Location.objects.create(name='Kisaasi', tree_parent=bukoto, type=some_type) ea1 = EnumerationArea.objects.create(name="EA Kisasi1") ea2 = EnumerationArea.objects.create(name="EA Kisasi2") ea1.locations.add(kisasi) ea2.locations.add(kisasi) location_widget = LocationWidget(selected_location=bukoto, ea=ea1, level=3) self.failIf(location_widget.get_ea_data())
def simple_indicator(request, indicator_id): hierarchy_limit = 2 selected_location = None first_level_location_analyzed = Location.objects.filter( type__name__iexact="country")[0] indicator = Indicator.objects.get(id=indicator_id) formula = indicator.formula.all() if not formula: messages.error(request, "No formula was found in this indicator") return HttpResponseRedirect(reverse("list_indicator_page")) params = request.GET if contains_key(params, 'location'): first_level_location_analyzed = Location.objects.get( id=params['location']) selected_location = first_level_location_analyzed formula = formula[0] indicator_service = SimpleIndicatorService(formula, first_level_location_analyzed) data_series, locations = indicator_service.get_location_names_and_data_series( ) context = { 'request': request, 'data_series': data_series, 'tabulated_data': indicator_service.tabulated_data_series(), 'location_names': locations, 'indicator': indicator, 'locations': LocationWidget(selected_location, level=hierarchy_limit) } return render(request, 'formula/simple_indicator.html', context)
def list_investigators(request): params = request.GET selected_location = None selected_ea = None investigators = Investigator.objects.order_by('id') if params.has_key('location') and params['location'].isdigit(): selected_location = Location.objects.get(id=int(params['location'])) corresponding_locations = selected_location.get_descendants( include_self=True) investigators = investigators.filter( ea__locations__in=corresponding_locations) if params.has_key('ea') and params['ea'].isdigit(): selected_ea = EnumerationArea.objects.get(id=int(params['ea'])) investigators = investigators.filter(ea=selected_ea) if not investigators: location_type = selected_location.type.name.lower( ) if selected_location and selected_location.type else 'location' messages.error( request, "There are no investigators currently registered for this %s." % location_type) location_widget = LocationWidget(selected_location, ea=selected_ea) return render( request, 'investigators/index.html', { 'investigators': investigators, 'location_data': location_widget, 'request': request })
def new_investigator(request): investigator = InvestigatorForm(label_suffix='') selected_location = None selected_ea = None response = None if request.method == 'POST': investigator = InvestigatorForm(data=request.POST, label_suffix='') selected_location = Location.objects.get( id=request.POST['location']) if contains_key( request.POST, 'location') else None selected_ea = EnumerationArea.objects.get( id=request.POST['ea']) if contains_key(request.POST, 'ea') else None action_text = "registered." redirect_url = "/investigators/" response = _process_form(investigator, request, action_text, redirect_url) return response or render( request, 'investigators/investigator_form.html', { 'country_phone_code': COUNTRY_PHONE_CODE, 'locations': LocationWidget(selected_location, ea=selected_ea), 'form': investigator, 'action': "/investigators/new/", 'title': 'New Investigator', 'id': "create-investigator-form", 'class': 'investigator-form', 'button_label': "Create", 'cancel_url': '/investigators/', 'loading_text': "Creating..." })
def test_location_widget_returns_two_levels_in_the_location_hierarchy_given_two_levels(self): village = LocationType.objects.create(name='Village', slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) Location.objects.create(name='Bukoto', tree_parent=self.kampala_city, type=village) some_type = LocationType.objects.create(name='Sometype', slug='sometype') LocationTypeDetails.objects.create(location_type=some_type, country=self.uganda) location_widget = LocationWidget(selected_location=self.kampala_city, level=3) widget_data = location_widget.get_widget_data() self.assertEqual(2, len(widget_data.keys())) self.assertNotIn('country', widget_data.keys()) self.assertNotIn('sometype', widget_data.keys()) self.assertNotIn('village', widget_data.keys()) self.assertIn(self.kampala, widget_data['district']) self.assertIn(self.kampala_city, widget_data['city'])
def edit_household(request, household_id): household_selected = Household.objects.get(id=household_id) selected_location = household_selected.location selected_ea = household_selected.ea response = None uid = household_selected.uid household_form = set_household_form(is_edit=True, instance=household_selected) investigators = Investigator.objects.filter(ea=selected_ea, is_blocked=False) investigator_form = {'value': '', 'text': '', 'options': investigators, 'error': ''} if request.method == 'POST': uid = request.POST.get('uid', None) selected_location = Location.objects.get(id=request.POST['location']) if contains_key(request.POST, 'location') else None selected_ea = EnumerationArea.objects.get(id=request.POST['ea']) if contains_key(request.POST, 'ea') else None response, household_form, investigator, investigator_form = create(request, selected_location, instance=household_selected, is_edit=True, uid=uid) return response or render(request, 'households/new.html', {'selected_location': selected_location, 'locations': LocationWidget(selected_location, ea=selected_ea), 'investigator_form': investigator_form, 'householdform': household_form, 'action': "/households/%s/edit/" % household_id, 'id': "add-household-form", 'button_label': "Save", 'heading': "Edit Household", 'uid': uid, 'loading_text': "Updating...", 'is_edit': True})
def test_location_widget_truncate_lowest_level_location_type(self): village = LocationType.objects.create(name='Village', slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) bukoto = Location.objects.create(name='Bukoto', tree_parent=self.kampala_city, type=village) some_type = LocationType.objects.create(name='Sometype', slug='sometype') LocationTypeDetails.objects.create(location_type=some_type, country=self.uganda) location_widget = LocationWidget(selected_location=self.kampala_city) widget_data = location_widget.get_widget_data() self.assertEqual(3, len(widget_data.keys())) self.assertNotIn('country', widget_data.keys()) self.assertNotIn('sometype', widget_data.keys()) self.assertIn(self.kampala, widget_data['district']) self.assertIn(self.kampala_city, widget_data['city']) self.assertIn(bukoto, widget_data['village'])
def test_gets_second_level_location_ie_below_country_if_no_selected_location_given_excluding_the_lowest_level( self): village = LocationType.objects.create(name='Village', slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) Location.objects.create(name="Kyanja", tree_parent=self.kampala_city, type=village) location_widget = LocationWidget(None) widget_data = location_widget.get_widget_data() self.assertEqual(2, len(widget_data.keys())) self.assertNotIn('country', widget_data.keys()) self.assertNotIn("village", widget_data.keys()) self.assertIn(self.kampala, widget_data['district']) self.assertEqual([], widget_data['city'])
def test_location_widget_appends_siblings_ea_if_ea_is_directly_under_parish(self): village = LocationType.objects.create(name='Village', slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) bukoto = Location.objects.create(name='Bukoto', tree_parent=self.kampala_city, type=village) some_type = LocationType.objects.create(name='Sometype', slug='sometype') LocationTypeDetails.objects.create(location_type=some_type, country=self.uganda) kisasi = Location.objects.create(name='Kisaasi', tree_parent=bukoto, type=some_type) kisasi_2 = Location.objects.create(name='Kisaasi 2', tree_parent=bukoto, type=some_type) ea1 = EnumerationArea.objects.create(name="EA Kisasi1") ea1.locations.add(kisasi) ea1.locations.add(kisasi_2) location_widget = LocationWidget(selected_location=bukoto, ea=ea1) widget_data = location_widget.get_ea_data() self.assertEqual(1, len(widget_data)) self.assertIn(ea1, widget_data)
def test_location_widget_appends_ea_data_in_place_of_the_lowest_location_level(self): village = LocationType.objects.create(name='Village', slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) bukoto = Location.objects.create(name='Bukoto', tree_parent=self.kampala_city, type=village) some_type = LocationType.objects.create(name='Sometype', slug='sometype') LocationTypeDetails.objects.create(location_type=some_type, country=self.uganda) kisasi = Location.objects.create(name='Kisaasi', tree_parent=bukoto, type=some_type) ea1 = EnumerationArea.objects.create(name="EA Kisasi1") ea2 = EnumerationArea.objects.create(name="EA Kisasi2") ea1.locations.add(kisasi) ea2.locations.add(kisasi) location_widget = LocationWidget(selected_location=bukoto, ea=ea1) widget_data = location_widget.get_ea_data() self.assertEqual(2, len(widget_data)) self.assertIn(ea1, widget_data) self.assertIn(ea2, widget_data)
def test_gets_location_sorted_by_hierarchy_given_a_location_with_parents( self): village = LocationType.objects.create(name='Village', slug='village') LocationTypeDetails.objects.create(location_type=village, country=self.uganda) kyanja = Location.objects.create(name="Kyanja", tree_parent=self.kampala_city, type=village) Location.objects.create(name="Kyanja child", tree_parent=kyanja, type=village) location_widget = LocationWidget(selected_location=self.kampala_city) widget_data = location_widget.get_widget_data() self.assertEqual(2, len(widget_data.keys())) self.assertIn(self.kampala_city, widget_data['city']) self.assertIn(self.kampala, widget_data['district']) self.assertNotIn("village", widget_data.keys()) self.assertNotIn('country', widget_data.keys())
def test_knows_ea_is_selected_given_location_data(self): kisasi = Location.objects.create(name='Kisaasi') ea1 = EnumerationArea.objects.create(name="EA Kisasi1") ea2 = EnumerationArea.objects.create(name="EA Kisasi2") ea1.locations.add(kisasi) ea2.locations.add(kisasi) location_widget = LocationWidget(selected_location=kisasi, ea=ea1) self.assertEqual("selected='selected'", is_ea_selected(location_widget, ea1)) self.assertIsNone(is_ea_selected(location_widget, ea2))
def test_is_location_selected(self): country = LocationType.objects.create(name="Country1", slug='country') district = LocationType.objects.create(name="District1", parent=country,slug='district') uganda = Location.objects.create(name="Uganda1", type=country) kisasi = Location.objects.create(name='Kisaasi1',type=district,parent=uganda) ea1 = EnumerationArea.objects.create(name="EA Kisasi11") ea2 = EnumerationArea.objects.create(name="EA Kisasi12") ea1.locations.add(kisasi) ea2.locations.add(kisasi) location_widget = LocationWidget(selected_location=kisasi, ea=ea1) self.assertIsNone(is_location_selected(location_widget,ea1))
def test_knows_ea_is_selected_given_location_data(self): country = LocationType.objects.create(name="Country", slug='country') district = LocationType.objects.create(name="District", parent=country,slug='district') uganda = Location.objects.create(name="Uganda", type=country) kisasi = Location.objects.create(name='Kisaasi',type=district,parent=uganda) ea1 = EnumerationArea.objects.create(name="EA Kisasi1") ea2 = EnumerationArea.objects.create(name="EA Kisasi2") ea1.locations.add(kisasi) ea2.locations.add(kisasi) location_widget = LocationWidget(selected_location=kisasi, ea=ea1) self.assertEqual("selected='selected'", is_ea_selected(location_widget, ea1)) self.assertIsNone(is_ea_selected(location_widget, ea2))
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 new(request): selected_location = None selected_ea = None response = None householdform = set_household_form(data=None) investigator_form = {'value': '', 'text': '', 'options': '', 'error': ''} month_choices = {'selected_text': '', 'selected_value': ''} year_choices = {'selected_text': '', 'selected_value': ''} if request.method == 'POST': selected_ea = EnumerationArea.objects.get(id=request.POST['ea']) if contains_key(request.POST, 'ea') else None if selected_ea: selected_location = selected_ea.locations.all() if selected_location: selected_location = selected_location[0] response, householdform, investigator, investigator_form = create(request, selected_ea) month_choices = {'selected_text': MONTHS[int(request.POST['resident_since_month'])][1], 'selected_value': request.POST['resident_since_month']} year_choices = {'selected_text': request.POST['resident_since_year'], 'selected_value': request.POST['resident_since_year']} household_head = householdform['householdHead'] del householdform['householdHead'] context = {'selected_location': selected_location, 'locations': LocationWidget(selected_location, ea=selected_ea), 'investigator_form': investigator_form, 'headform': household_head, 'householdform': householdform, 'months_choices': household_head.resident_since_month_choices(month_choices), 'years_choices': household_head.resident_since_year_choices(year_choices), 'action': "/households/new/", 'heading': "New Household", 'id': "create-household-form", 'button_label': "Create", 'loading_text': "Creating..."} return response or render(request, 'households/new.html', context)
def list_households(request): selected_location = None selected_ea = None all_households = Household.objects.order_by('household_member__householdhead__surname') params = request.GET if params.has_key('location') and params['location'].isdigit(): selected_location = Location.objects.get(id=int(params['location'])) corresponding_locations = selected_location.get_descendants(include_self=True) all_households = all_households.filter(ea__locations__in=corresponding_locations) if params.has_key('ea') and params['ea'].isdigit(): selected_ea = EnumerationArea.objects.get(id=int(params['ea'])) all_households = all_households.filter(ea=selected_ea) households = _remove_duplicates(all_households) households = Household.set_related_locations(households) if not households: location_type = selected_location.type.name.lower() if selected_location and selected_location.type else 'location' messages.error(request, "There are no households currently registered for this %s." % location_type) return render(request, 'households/index.html', {'households': households, 'location_data': LocationWidget(selected_location, ea=selected_ea), 'request': request})
def edit_investigator(request, investigator_id): response = None investigator = Investigator.objects.get(id=investigator_id) selected_location = investigator.location selected_ea = investigator.ea investigator_form = InvestigatorForm( instance=investigator, initial={'confirm_mobile_number': investigator.mobile_number}) if request.method == 'POST': investigator_form = InvestigatorForm(data=request.POST, instance=investigator) action_text = "edited." redirect_url = "/investigators/" selected_location = Location.objects.get( id=request.POST['location']) if contains_key( request.POST, 'location') else None selected_ea = EnumerationArea.objects.get( id=request.POST['ea']) if contains_key(request.POST, 'ea') else None response = _process_form(investigator_form, request, action_text, redirect_url) context = { 'action': '/investigators/%s/edit/' % investigator_id, 'country_phone_code': COUNTRY_PHONE_CODE, 'title': 'Edit Investigator', 'id': 'edit-investigator-form', 'class': 'investigator-form', 'button_label': 'Save', 'cancel_url': '/investigators/', 'loading_text': 'Saving...', 'form': investigator_form, 'locations': LocationWidget(selected_location, ea=selected_ea) } return response or render(request, 'investigators/investigator_form.html', context)
def show(request): selected_location = None location_filter_form = LocationFilterForm() content = {'action': 'survey_completion_rates', 'request': request} if request.method == 'POST': location_filter_form = LocationFilterForm(request.POST) if location_filter_form.is_valid(): batch = location_filter_form.cleaned_data.get('batch', None) selected_location = location_filter_form.cleaned_data.get( 'location', None) selected_ea = location_filter_form.cleaned_data.get('ea', None) if selected_ea: return render_household_details(request, selected_ea, batch) if selected_location: high_level_locations = selected_location.get_children( ).order_by('name') else: high_level_locations = __get_parent_level_locations() content[ 'completion_rates'] = BatchHighLevelLocationsCompletionRates( batch, high_level_locations) content['locations'] = LocationWidget(selected_location) content['filter'] = location_filter_form return render(request, 'aggregates/completion_status.html', content)