diff options
author | Struan Donald <struan@exo.org.uk> | 2011-05-06 16:14:16 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-05-06 16:14:16 +0100 |
commit | f8ee12145969b2e176504ed66a666269331159f7 (patch) | |
tree | 1e29fd64826c9d93bc565494a1f2c2c545374a26 /perllib/FixMyStreet/App/Controller/Council.pm | |
parent | 5ea25c06ade6453297ff30f7656cabdb967cc9c1 (diff) |
Allow us to get councils or councils and wards and control if we remove redundant councils
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Council.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Council.pm | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Council.pm b/perllib/FixMyStreet/App/Controller/Council.pm index 61692f17a..843a25499 100644 --- a/perllib/FixMyStreet/App/Controller/Council.pm +++ b/perllib/FixMyStreet/App/Controller/Council.pm @@ -14,6 +14,20 @@ Catalyst Controller. =head1 METHODS +=head2 load_and_check_councils_and_wards + +Try to load councils and wards for this location and check that we have at least one. If +there are no councils then return false. + +=cut + +sub load_and_check_councils_and_wards : Private { + my ( $self, $c ) = @_; + my @area_types = ( $c->cobrand->area_types(), @$mySociety::VotingArea::council_child_types ); + $c->stash->{area_types} = \@area_types; + $c->forward('load_and_check_councils'); +} + =head2 load_and_check_councils Try to load councils for this location and check that we have at least one. If @@ -22,12 +36,17 @@ there are no councils then return false. =cut sub load_and_check_councils : Private { - my ( $self, $c, $action ) = @_; + my ( $self, $c ) = @_; my $latitude = $c->stash->{latitude}; my $longitude = $c->stash->{longitude}; # Look up councils and do checks for the point we've got - my @area_types = $c->cobrand->area_types(); + my @area_types; + if ( $c->stash->{area_types} and scalar @{ $c->stash->{area_types} } ) { + @area_types = @{ $c->stash->{area_types} }; + } else { + @area_types = $c->cobrand->area_types(); + } # TODO: I think we want in_gb_locale around the next line, needs testing my $all_councils = @@ -37,14 +56,14 @@ sub load_and_check_councils : Private { # Let cobrand do a check my ( $success, $error_msg ) = $c->cobrand->council_check( { all_councils => $all_councils }, - $action ); + $c->stash->{council_check_action} ); if ( !$success ) { $c->stash->{location_error} = $error_msg; return; } # edit hash in-place - _remove_redundant_councils($all_councils); + _remove_redundant_councils($all_councils) if $c->stash->{remove_redundant_councils}; # If we don't have any councils we can't accept the report if ( !scalar keys %$all_councils ) { |