diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-04-16 17:57:27 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-04-23 15:39:50 +0100 |
commit | 86eae502d494090430f3076f25331df797b9172b (patch) | |
tree | c4011f364c6d3bf7e3f12b616d2b54f6277f4bb1 | |
parent | 0c4e267f43c573f638dd4771e5c39f6b3861dd3d (diff) |
Have only one bodies_to_list variable.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 6 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 1 | ||||
-rw-r--r-- | templates/web/base/report/new/category_extras.html | 3 | ||||
-rw-r--r-- | templates/web/base/report/new/councils_text_all.html | 3 | ||||
-rw-r--r-- | templates/web/fixamingata/report/new/top_message_none.html | 6 |
6 files changed, 11 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 33404cb82..2cd34b7e2 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -1042,7 +1042,7 @@ sub report_edit_location : Private { $c->forward('/council/load_and_check_areas', []); $c->forward('/report/new/setup_categories_and_bodies'); my %allowed_bodies = map { $_ => 1 } @{$problem->bodies_str_ids}; - my @new_bodies = @{$c->stash->{bodies_to_list}}; + my @new_bodies = keys %{$c->stash->{bodies_to_list}}; my $bodies_match = grep { exists( $allowed_bodies{$_} ) } @new_bodies; $c->stash($safe_stash); return unless $bodies_match; diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 312268f65..7b4f1abad 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -695,9 +695,7 @@ sub setup_categories_and_bodies : Private { # put results onto stash for display $c->stash->{bodies} = \%bodies; $c->stash->{contacts} = \@contacts; - $c->stash->{bodies_to_list} = [ keys %bodies_to_list ]; - $c->stash->{bodies_to_list_names} = [ map { $_->name } values %bodies_to_list ]; - $c->stash->{bodies_to_list_urls} = [ map { $_->external_url } values %bodies_to_list ]; + $c->stash->{bodies_to_list} = \%bodies_to_list; $c->stash->{category_options} = \@category_options; $c->stash->{category_extras} = \%category_extras; $c->stash->{category_extras_hidden} = \%category_extras_hidden; @@ -948,7 +946,7 @@ sub process_report : Private { if ( $c->stash->{non_public_categories}->{ $report->category } ) { $report->non_public( 1 ); } - } elsif ( @{ $c->stash->{bodies_to_list} } ) { + } elsif ( %{ $c->stash->{bodies_to_list} } ) { # There was an area with categories, but we've not been given one. Bail. $c->stash->{field_errors}->{category} = _('Please choose a category'); diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 0e7547a85..e12391804 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -1169,6 +1169,7 @@ FixMyStreet::override_config { $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=' . $saved_lat . '&longitude=' . $saved_lon ); }; $mech->content_contains( "Pothol\xc3\xa9s" ); +like $extra_details->{councils_text}, qr/<strong>Cheltenham/; ok !$extra_details->{titles_list}, 'Non Bromley does not send back list of titles'; FixMyStreet::override_config { diff --git a/templates/web/base/report/new/category_extras.html b/templates/web/base/report/new/category_extras.html index e2926901c..f787b9c52 100644 --- a/templates/web/base/report/new/category_extras.html +++ b/templates/web/base/report/new/category_extras.html @@ -1,4 +1,5 @@ -[% DEFAULT list_of_names = bodies_to_list_names %] +[% SET default_list = [] %][% FOR b IN bodies_to_list.values %][% default_list.push(b.name) %][% END %] +[% DEFAULT list_of_names = default_list %] <div id="category_meta"> [%- IF unresponsive.$category %] diff --git a/templates/web/base/report/new/councils_text_all.html b/templates/web/base/report/new/councils_text_all.html index 9a11eaae6..3ea641cbf 100644 --- a/templates/web/base/report/new/councils_text_all.html +++ b/templates/web/base/report/new/councils_text_all.html @@ -1,4 +1,5 @@ -[% DEFAULT list_of_names = bodies_to_list_names %] +[% SET default_list = [] %][% FOR b IN bodies_to_list.values %][% default_list.push(b.name) %][% END %] +[% DEFAULT list_of_names = default_list %] <p> [% diff --git a/templates/web/fixamingata/report/new/top_message_none.html b/templates/web/fixamingata/report/new/top_message_none.html index 9a9141b33..641c08f47 100644 --- a/templates/web/fixamingata/report/new/top_message_none.html +++ b/templates/web/fixamingata/report/new/top_message_none.html @@ -1,15 +1,15 @@ <p> -[% IF bodies_to_list_names.size == 1 %] +[% IF bodies_to_list.size == 1 %] [% tprintf( "%s har valt att inte ta emot rapporter från FixaMinGata, utan hänvisar fel- & synpunktsrapportering till <a href='%s'>kommunens egen webbplats</a>.", - bodies_to_list_names.first, bodies_to_list_urls.first); + bodies_to_list.values.first.name, bodies_to_list.values.first.external_url); %] [% END %] [% loc("If you submit a problem here the problem will <strong>not</strong> be reported to the council."); %] -[% IF bodies_to_list_names.size != 1 %] +[% IF bodies_to_list.size != 1 %] [% tprintf( loc("You can help us by finding a contact email address for local problems for %s and emailing it to us at <a href='mailto:%s'>%s</a>."), |