aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Report/New.pm
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2015-04-11 15:27:04 +0000
committerDave Arter <davea@mysociety.org>2015-10-06 09:09:24 +0100
commit2ff36453ebaa86e7f58f17ec63d2f95a88b8be99 (patch)
treee312b2d95f77434829e3e899a6fc6d3893028d52 /perllib/FixMyStreet/App/Controller/Report/New.pm
parent1fd5e4737072c7f6485238826bfbd8ebadaa9d45 (diff)
[Zurich] prevent invalid bodies_str
See issue in mysociety/FixMyStreet-Commercial#663 with problems not appearing in the "Erfasst" filter. It looks like Zurich requires a single id in the `bodies_str` (like '4'), and may rely on the configuration of bodies/contacts in database to be perfect to avoid them becoming something like '4|47,48'.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/New.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm19
1 files changed, 17 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 6a884db7f..246facbee 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -890,8 +890,23 @@ sub process_report : Private {
$report->bodies_str(-1);
} else {
# construct the bodies string:
- # 'x,x' - x are body IDs that have this category
- my $body_string = join( ',', map { $_->body_id } @contacts );
+ my $body_string = do {
+ if ( $c->cobrand->can('singleton_bodies_str') && $c->cobrand->singleton_bodies_str ) {
+ # Cobrands like Zurich can only ever have a single body: 'x', because some functionality
+ # relies on string comparison against bodies_str.
+ if (@contacts) {
+ $contacts[0]->body_id;
+ }
+ else {
+ '';
+ }
+ }
+ else {
+ # 'x,x' - x are body IDs that have this category
+ my $bs = join( ',', map { $_->body_id } @contacts );
+ $bs;
+ };
+ };
$report->bodies_str($body_string);
# Record any body IDs which might have meant to match, but had no contact
if ($body_string && @{ $c->stash->{missing_details_bodies} }) {