diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-12-14 14:31:41 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-12-15 00:11:06 +0000 |
commit | ac71de34b015176b44d35c83cf5e4a838ed75723 (patch) | |
tree | b5b1fcc1fc6932ddc8551818c3d00bef79f8e855 | |
parent | 2d16a64009e3bd512bfe69dbf58f6091ab826049 (diff) |
Remove some linkages between area and body IDs.
-rwxr-xr-x | bin/send-comments | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/LichfieldDC.pm | 5 |
3 files changed, 9 insertions, 8 deletions
diff --git a/bin/send-comments b/bin/send-comments index 7520af17d..ed13f10ba 100755 --- a/bin/send-comments +++ b/bin/send-comments @@ -49,7 +49,7 @@ while ( my $body = $bodies->next ) { 'me.confirmed' => { '!=' => undef }, 'problem.whensent' => { '!=' => undef }, 'problem.external_id' => { '!=' => undef }, - 'problem.bodies_str' => { -like => '%' . $body->area_id .'%' }, + 'problem.bodies_str' => { -like => '%' . $body->id . '%' }, 'problem.send_method_used' => 'Open311', }, { diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 0cb56d67a..09e46ccef 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -582,6 +582,7 @@ sub setup_categories_and_bodies : Private { my @bodies = $c->model('DB::Body')->search( { area_id => [ keys %$all_areas ] } )->all; my %bodies = map { $_->id => $_ } @bodies; + my $first_body = ( values %bodies )[0]; my @contacts # = $c # @@ -620,8 +621,7 @@ sub setup_categories_and_bodies : Private { } elsif ($first_area->{id} != COUNCIL_ID_BROMLEY && $first_area->{type} eq 'LBO') { - # Assumes body ID and area ID match here - $bodies_to_list{ $first_area->{id} } = 1; + $bodies_to_list{ $first_body->id } = 1; my @local_categories; if ($first_area->{id} == COUNCIL_ID_BARNET) { @local_categories = sort keys %{ Utils::barnet_categories() } @@ -812,6 +812,7 @@ sub process_report : Private { $areas = $c->stash->{all_areas}; my $bodies = $c->stash->{bodies}; my $first_area = ( values %$areas )[0]; + my $first_body = ( values %$bodies )[0]; if ( $c->cobrand->moniker eq 'emptyhomes' ) { @@ -820,18 +821,17 @@ sub process_report : Private { } elsif ( $first_area->{id} == COUNCIL_ID_BARNET ) { - # As in setup, assumes body ID == area ID for London unless ( exists Utils::barnet_categories()->{ $report->category } ) { $c->stash->{field_errors}->{category} = _('Please choose a category'); } - $report->bodies_str( $first_area->{id} ); + $report->bodies_str( $first_body->id ); } elsif ( $first_area->{id} != COUNCIL_ID_BROMLEY && $first_area->{type} eq 'LBO') { unless ( Utils::london_categories()->{ $report->category } ) { $c->stash->{field_errors}->{category} = _('Please choose a category'); } - $report->bodies_str( $first_area->{id} ); + $report->bodies_str( $first_body->id ); } elsif ( $report->category ) { diff --git a/perllib/FixMyStreet/Cobrand/LichfieldDC.pm b/perllib/FixMyStreet/Cobrand/LichfieldDC.pm index 51f368957..f9d5e3632 100644 --- a/perllib/FixMyStreet/Cobrand/LichfieldDC.pm +++ b/perllib/FixMyStreet/Cobrand/LichfieldDC.pm @@ -27,10 +27,11 @@ sub disambiguate_location { } # If we ever link to a county problem report, needs to be to main FixMyStreet -# XXX Assumes body ID equals mapit area ID sub base_url_for_report { my ( $self, $report ) = @_; - if ( $report->bodies->{2434} ) { + my $bodies = $report->bodies; + my %areas = map { $_->area_id => 1 } values %$bodies; + if ( $areas{2434} ) { return $self->base_url; } else { return FixMyStreet->config('BASE_URL'); |