diff options
Diffstat (limited to 'perllib/FixMyStreet/DB/Result')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 12 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 15 |
2 files changed, 19 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index d59245c15..1218d2f76 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -128,9 +128,10 @@ sub check_for_errors { unless $self->text =~ m/\S/; # Bromley Council custom character limit - if ( $self->text && $self->problem && $self->problem->bodies_str - && $self->problem->bodies_str eq '2482' && length($self->text) > 1750 ) { - $errors{update} = sprintf( _('Updates are limited to %s characters in length. Please shorten your update'), 1750 ); + if ( $self->text && $self->problem && $self->problem->bodies_str) { + if ($self->problem->to_body_named('Bromley') && length($self->text) > 1750) { + $errors{update} = sprintf( _('Updates are limited to %s characters in length. Please shorten your update'), 1750 ); + } } return \%errors; @@ -281,10 +282,7 @@ sub meta_line { $update_state = _( 'marked as an internal referral' ) } - if ($c->cobrand->moniker eq 'bromley' || ( - $self->problem->bodies_str && - $self->problem->bodies_str eq '2482' - )) { + if ($c->cobrand->moniker eq 'bromley' || $self->problem->to_body_named('Bromley')) { if ($state eq 'not responsible') { $update_state = 'marked as third party responsibility' } diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 6703a5102..f62ed6d47 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -510,6 +510,19 @@ sub bodies($) { return { map { $_->id => $_ } @bodies }; } +sub body_names($) { + my $self = shift; + my $bodies = $self->bodies; + my @names = map { $_->name } values %$bodies; + return \@names; +} + +sub to_body_named($$) { + my ($self, $re) = @_; + my $names = join(',,', @{$self->body_names}); + $names =~ /$re/; +} + =head2 url Returns a URL for this problem report. @@ -774,7 +787,7 @@ sub defect_types { # Note: this only makes sense when called on a problem that has been sent! sub can_display_external_id { my $self = shift; - if ($self->external_id && $self->send_method_used && $self->bodies_str =~ /(2237|2550)/) { + if ($self->external_id && $self->send_method_used && $self->to_body_named('Oxfordshire|Angus')) { return 1; } return 0; |