aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB')
-rw-r--r--perllib/FixMyStreet/DB/Factories.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm12
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm15
3 files changed, 19 insertions, 14 deletions
diff --git a/perllib/FixMyStreet/DB/Factories.pm b/perllib/FixMyStreet/DB/Factories.pm
index e877ffd9f..c3060507e 100644
--- a/perllib/FixMyStreet/DB/Factories.pm
+++ b/perllib/FixMyStreet/DB/Factories.pm
@@ -44,8 +44,6 @@ __PACKAGE__->fields({
#######################
-# This currently creates special 'UK' bodies, with ID == MapIt area_id.
-# We should try and end this, it is just confusing.
package FixMyStreet::DB::Factory::Body;
use parent -norequire, "FixMyStreet::DB::Factory::Base";
@@ -56,10 +54,6 @@ __PACKAGE__->resultset(FixMyStreet::DB->resultset("Body"));
__PACKAGE__->exclude(['area_id', 'categories']);
__PACKAGE__->fields({
- id => __PACKAGE__->callback(sub {
- my $area_id = shift->get('area_id');
- $area_id;
- }),
name => __PACKAGE__->callback(sub {
my $area_id = shift->get('area_id');
my $area = mySociety::MaPit::call('area', $area_id);
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;