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 | |
parent | 5ea25c06ade6453297ff30f7656cabdb967cc9c1 (diff) |
Allow us to get councils or councils and wards and control if we remove redundant councils
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Alert.pm | 3 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Council.pm | 27 |
3 files changed, 28 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm index c18ba657f..49a8bce8a 100644 --- a/perllib/FixMyStreet/App/Controller/Alert.pm +++ b/perllib/FixMyStreet/App/Controller/Alert.pm @@ -94,7 +94,8 @@ sub list :Path('list') :Args(0) { # my $errors = ''; # $errors = '<ul class="error"><li>' . join('</li><li>', @errors) . '</li></ul>' if @errors; # - unless ( $c->forward( '/council/load_and_check_councils', 'alert' ) ) { + $c->stash->{council_check_action} = 'alert'; + unless ( $c->forward( '/council/load_and_check_councils_and_wards' ) ) { $c->go( 'index' ); } diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index 92cd1556a..86e2ac001 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -269,7 +269,9 @@ sub check_location_is_acceptable : Private { } # check that there are councils that can accept this location - return $c->forward('/council/load_and_check_councils', 'submit_problem' ); + $c->stash->{council_check_action} = 'submit_problem'; + $c->stash->{remove_redundant_councils} = 1; + return $c->forward('/council/load_and_check_councils'); } =head2 /ajax 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 ) { |