diff options
Diffstat (limited to 'perllib/FixMyStreet/Roles')
-rw-r--r-- | perllib/FixMyStreet/Roles/ConfirmOpen311.pm | 39 | ||||
-rw-r--r-- | perllib/FixMyStreet/Roles/ConfirmValidation.pm | 2 |
2 files changed, 40 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Roles/ConfirmOpen311.pm b/perllib/FixMyStreet/Roles/ConfirmOpen311.pm new file mode 100644 index 000000000..b9e424d4f --- /dev/null +++ b/perllib/FixMyStreet/Roles/ConfirmOpen311.pm @@ -0,0 +1,39 @@ +package FixMyStreet::Roles::ConfirmOpen311; +use Moo::Role; + +=head1 NAME + +FixMyStreet::Roles::ConfirmOpen311 - role for adding various Open311 things specific to Confirm + +=cut + +sub open311_config { + my ($self, $row, $h, $params) = @_; + + $params->{multi_photos} = 1; + + my $extra = $row->get_extra_fields; + push @$extra, + { name => 'report_url', + value => $h->{url} }, + { name => 'title', + value => $row->title }, + { name => 'description', + value => $row->detail }; + + # Reports made via FMS.com or the app probably won't have a USRN + # value because we don't display the adopted highways layer on those + # frontends. Instead we'll look up the closest asset from the WFS + # service at the point we're sending the report over Open311. + if (!$row->get_extra_field_value('site_code')) { + if (my $site_code = $self->lookup_site_code($row)) { + push @$extra, + { name => 'site_code', + value => $site_code }; + } + } + + $row->set_extra_fields(@$extra); +} + +1; diff --git a/perllib/FixMyStreet/Roles/ConfirmValidation.pm b/perllib/FixMyStreet/Roles/ConfirmValidation.pm index 776230287..6474c94d1 100644 --- a/perllib/FixMyStreet/Roles/ConfirmValidation.pm +++ b/perllib/FixMyStreet/Roles/ConfirmValidation.pm @@ -24,7 +24,7 @@ sub report_validation { $errors->{name} = sprintf( _('Names are limited to %d characters in length.'), 50 ); } - if ( length( $report->user->phone ) > 20 ) { + if ( $report->user->phone && length( $report->user->phone ) > 20 ) { $errors->{phone} = sprintf( _('Phone numbers are limited to %s characters in length.'), 20 ); } |