aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/Cobrand/UK.pm33
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm20
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm2
3 files changed, 34 insertions, 21 deletions
diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm
index b293c3568..2473f386f 100644
--- a/perllib/FixMyStreet/Cobrand/UK.pm
+++ b/perllib/FixMyStreet/Cobrand/UK.pm
@@ -302,5 +302,38 @@ sub council_rss_alert_options {
return ( \@options, @reported_to_options ? \@reported_to_options : undef );
}
+sub report_check_for_errors {
+ my $self = shift;
+ my $c = shift;
+
+ my %errors = $self->next::method($c);
+
+ my $report = $c->stash->{report};
+
+ if (!$errors{name} && (length($report->name) < 5
+ || $report->name !~ m/\s/
+ || $report->name =~ m/\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i))
+ {
+ $errors{name} = _(
+'Please enter your full name, councils need this information – if you do not wish your name to be shown on the site, untick the box below'
+ );
+ }
+
+ # XXX Hardcoded body ID matching mapit area ID
+ if ( $report->bodies_str && $report->detail ) {
+ # Custom character limit:
+ # Bromley Council
+ if ( $report->bodies_str eq '2482' && length($report->detail) > 1750 ) {
+ $errors{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), 1750 );
+ }
+ # Oxfordshire
+ if ( $report->bodies_str eq '2237' && length($report->detail) > 1700 ) {
+ $errors{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), 1700 );
+ }
+ }
+
+ return %errors;
+}
+
1;
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index e55c26cd8..bed2f160a 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -405,14 +405,6 @@ sub check_for_errors {
if ( !$self->name || $self->name !~ m/\S/ ) {
$errors{name} = _('Please enter your name');
}
- elsif (length( $self->name ) < 5
- || $self->name !~ m/\s/
- || $self->name =~ m/\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i )
- {
- $errors{name} = _(
-'Please enter your full name, councils need this information – if you do not wish your name to be shown on the site, untick the box below'
- ) unless $self->cobrand eq 'emptyhomes';
- }
if ( $self->category
&& $self->category eq _('-- Pick a category --') )
@@ -427,18 +419,6 @@ sub check_for_errors {
$self->category(undef);
}
- if ( $self->bodies_str && $self->detail ) {
- # Custom character limit:
- # Bromley Council
- if ( $self->bodies_str eq '2482' && length($self->detail) > 1750 ) {
- $errors{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), 1750 );
- }
- # Oxfordshire
- if ( $self->bodies_str eq '2237' && length($self->detail) > 1700 ) {
- $errors{detail} = sprintf( _('Reports are limited to %s characters in length. Please shorten your report'), 1700 );
- }
- }
-
return \%errors;
}
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index 6a93f97ec..f08b666c8 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -100,7 +100,7 @@ use mySociety::EmailUtil;
=head2 check_for_errors
- $error_hashref = $problem->check_for_errors();
+ $error_hashref = $user->check_for_errors();
Look at all the fields and return a hashref with all errors found, keyed on the
field name. This is intended to be passed back to the form to display the