diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Oxfordshire.pm | 2 | ||||
-rw-r--r-- | t/app/controller/report_inspect.t | 76 | ||||
-rw-r--r-- | templates/web/base/report/_inspect.html | 3 |
6 files changed, 61 insertions, 30 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 890d25b06..ba754f953 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ - Area summary statistics page in admin #1834 - Bugfixes - Shortlist menu item always remains a link #1855 + - Admin improvements: + - Character length limit can be placed on report detailed information #1848 * v2.2 (13th September 2017) - New features: diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 60f7ac903..ba9fa11b9 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -326,6 +326,8 @@ sub inspect : Private { $c->stash->{has_default_priority} = scalar( grep { $_->is_default } $problem->response_priorities ); } + $c->stash->{max_detailed_info_length} = $c->cobrand->max_detailed_info_length; + if ( $c->get_param('save') ) { $c->forward('/auth/check_csrf_token'); @@ -339,7 +341,9 @@ sub inspect : Private { if ( my $info = $c->get_param('detailed_information') ) { $problem->set_extra_metadata( detailed_information => $info ); - if (length($info) > 172) { + if ($c->cobrand->max_detailed_info_length && + length($info) > $c->cobrand->max_detailed_info_length + ) { $valid = 0; push @{ $c->stash->{errors} }, sprintf( diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 002d8e3da..1258c8bca 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -1090,6 +1090,8 @@ sub state_groups_inspect { ] } +sub max_detailed_info_length { 0 } + =head2 never_confirm_updates If true then we never send an email to confirm an update diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index 44747a16f..cdd186fef 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -217,6 +217,8 @@ sub user_extra_fields { sub display_days_ago_threshold { 28 } +sub max_detailed_info_length { 172 } + sub defect_type_extra_fields { return [ 'activity_code', diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index be8f12cc5..fb18526ac 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -261,38 +261,58 @@ FixMyStreet::override_config { }); }; } +}; - subtest "detailed_information has max length" => sub { - $user->user_body_permissions->delete; - $user->user_body_permissions->create({ body => $oxon, permission_type => 'report_inspect' }); - $mech->get_ok("/report/$report_id"); - $mech->submit_form_ok({ - button => 'save', - with_fields => { - include_update => 0, - detailed_information => 'XXX172XXX' . 'x' x 163, - } - }); +foreach my $test ( + { cobrand => 'fixmystreet', limited => 0, desc => 'detailed_information has no max length' }, + { cobrand => 'oxfordshire', limited => 1, desc => 'detailed_information has max length' }, +) { - $report->discard_changes; - like $report->get_extra_metadata('detailed_information'), qr/XXX172XXX/, 'detailed information saved'; - $mech->content_lacks('limited to 172 characters', "172 charcters of detailed information ok"); - $mech->content_contains('XXX172XXX', "Detailed information field contains submitted text"); - - $mech->submit_form_ok({ - button => 'save', - with_fields => { - include_update => 0, - detailed_information => 'XXX173XXX' . 'x' x 164, - } - }); - $mech->content_contains('limited to 172 characters', "173 charcters of detailed information not ok"); - $mech->content_contains('XXX173XXX', "Detailed information field contains submitted text"); + FixMyStreet::override_config { + ALLOWED_COBRANDS => $test->{cobrand}, + }, sub { + subtest $test->{desc} => sub { + $user->user_body_permissions->delete; + $user->user_body_permissions->create({ body => $oxon, permission_type => 'report_inspect' }); + $mech->get_ok("/report/$report_id"); + $mech->submit_form_ok({ + button => 'save', + with_fields => { + include_update => 0, + detailed_information => 'XXX172XXX' . 'x' x 163, + } + }); - $report->discard_changes; - like $report->get_extra_metadata('detailed_information'), qr/XXX172XXX/, 'detailed information not saved'; + $report->discard_changes; + like $report->get_extra_metadata('detailed_information'), qr/XXX172XXX/, 'detailed information saved'; + $mech->content_lacks('limited to 172 characters', "172 charcters of detailed information ok"); + $mech->content_contains('XXX172XXX', "Detailed information field contains submitted text"); + + $mech->submit_form_ok({ + button => 'save', + with_fields => { + include_update => 0, + detailed_information => 'XXX173XXX' . 'x' x 164, + } + }); + if ($test->{limited}) { + $mech->content_contains('172 characters maximum'); + $mech->content_contains('limited to 172 characters', "173 charcters of detailed information not ok"); + $mech->content_contains('XXX173XXX', "Detailed information field contains submitted text"); + + $report->discard_changes; + like $report->get_extra_metadata('detailed_information'), qr/XXX172XXX/, 'detailed information not saved'; + } else { + $mech->content_lacks(' characters maximum'); + $mech->content_lacks('limited to 172 characters', "173 charcters of detailed information ok"); + $mech->content_contains('XXX173XXX', "Detailed information field contains submitted text"); + + $report->discard_changes; + like $report->get_extra_metadata('detailed_information'), qr/XXX173XXX/, 'detailed information saved'; + } + }; }; -}; +} FixMyStreet::override_config { ALLOWED_COBRANDS => 'oxfordshire', diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html index 436c89e4a..f012d5ae3 100644 --- a/templates/web/base/report/_inspect.html +++ b/templates/web/base/report/_inspect.html @@ -142,7 +142,8 @@ </p> <p> <label for="detailed_information">[% loc('Extra details') %]</label> - <textarea rows="2" name="detailed_information" id="detailed_information" class="form-control">[% problem.get_extra_metadata('detailed_information') | html %]</textarea> + <textarea rows="2" name="detailed_information" id="detailed_information" class="form-control" + [% IF max_detailed_info_length %]placeholder="[% tprintf(loc('%d characters maximum'), max_detailed_info_length) %]"[% END %]>[% problem.get_extra_metadata('detailed_information') | html %]</textarea> </p> [% END %] |