mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-30 11:19:44 -04:00
add counties page
What was previously ward -> local authority is now a ward -> local authority -> county. County only covers rural counties and not metropolitan boroughs and other unitary authorities. Previously, there was a page full of local authorities (unitary authorities and districts), and each one of those would have a list of electoral wards. However, now there are counties that contain a list of districts - so this needs a new page - a checkbox for "select the county" and then a list of links to district pages. If you want to select multiple districts, you'll need to go into each one of those sub-sections in turn and click select all. Needed to tweak the query to retrieve the list of areas in a list for a library. Previously, it just returned anything at top level (ie: didn't have a parent). However, rural districts now have parents (the rural counties themselves). So the query now returns "everything that isn't a leaf node", or in more specific terms, everything that has at least other row referring to it as a parent. So no electoral wards, since they dont have any children, but yes to districts and counties.
This commit is contained in:
@@ -160,8 +160,10 @@ def choose_broadcast_sub_area(service_id, broadcast_message_id, library_slug, ar
|
||||
)
|
||||
area = BroadcastMessage.libraries.get_areas(area_slug)[0]
|
||||
|
||||
is_county = any(sub_area.sub_areas for sub_area in area.sub_areas)
|
||||
|
||||
form = BroadcastAreaFormWithSelectAll.from_library(
|
||||
area.sub_areas,
|
||||
[] if is_county else area.sub_areas,
|
||||
select_all_choice=(area.id, f'All of {area.name}'),
|
||||
)
|
||||
if form.validate_on_submit():
|
||||
@@ -171,6 +173,20 @@ def choose_broadcast_sub_area(service_id, broadcast_message_id, library_slug, ar
|
||||
service_id=current_service.id,
|
||||
broadcast_message_id=broadcast_message.id,
|
||||
))
|
||||
|
||||
if is_county:
|
||||
# area = county. sub_areas = districts. they have wards, so link to individual district pages
|
||||
return render_template(
|
||||
'views/broadcast/counties.html',
|
||||
form=form,
|
||||
search_form=SearchByNameForm(),
|
||||
show_search_form=(len(area.sub_areas) > 7),
|
||||
library_slug=library_slug,
|
||||
page_title=f'Choose an area of {area.name}',
|
||||
broadcast_message=broadcast_message,
|
||||
county=area,
|
||||
)
|
||||
|
||||
return render_template(
|
||||
'views/broadcast/sub-areas.html',
|
||||
form=form,
|
||||
|
||||
Reference in New Issue
Block a user