diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-11-01 09:53:57 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-11-02 12:56:17 +0000 |
commit | 4efc9d1bbea97c07c950f81773a03ff97c0755ff (patch) | |
tree | c59384bdbb44e99d21e7905c3827b91e492a5dad | |
parent | 64a24f1d9bf251cc57d363e7bf57d4218a5e2cb8 (diff) |
Remove shortlist form from inspect duplicate list.
This functionality isn't needed here, and causes an issue with the main
form submitting due to a form inside a form.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 3 | ||||
-rw-r--r-- | t/app/controller/report_inspect.t | 13 | ||||
-rw-r--r-- | templates/web/base/report/_item.html | 13 |
4 files changed, 21 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 419dff1d2..64d3af0b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - Redirect inspectors correctly on creation in two-tier. - Report status filter All option works for body users #1845 - Always allow reports to be removed from shortlist #1882 + - Remove shortlist form from inspect duplicate list. - Admin improvements: - Character length limit can be placed on report detailed information #1848 - Inspector panel shows nearest address if available #1850 diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 138098d5f..4c7931420 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -520,6 +520,9 @@ sub nearby_json : Private { my $p = $c->stash->{problem}; my $dist = 1; + # This is for the list template, this is a list on that page. + $c->stash->{page} = 'report'; + my $nearby = $c->model('DB::Nearby')->nearby( $c, $dist, [ $p->id ], 5, $p->latitude, $p->longitude, undef, [ $p->category ], undef ); diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index 74d99c0a9..239cc408b 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -124,7 +124,6 @@ FixMyStreet::override_config { $mech->content_contains('Invalid location'); $mech->submit_form_ok({ button => 'save', with_fields => { latitude => 51.754926, longitude => -1.256179, include_update => undef } }); $mech->content_lacks('Invalid location'); - $user->user_body_permissions->search({ body_id => $oxon->id, permission_type => 'planned_reports' })->delete; }; subtest "test duplicate reports are shown" => sub { @@ -203,6 +202,10 @@ FixMyStreet::override_config { is $report->get_extra_metadata('duplicate_of'), $report2->id; is_deeply $report2->get_extra_metadata('duplicates'), [ $report->id ]; + # Check that duplicate does not include shortlist add button (no form in form) + $mech->get_ok("/report/$report_id"); + $mech->content_lacks('item-list__item__shortlist-add'); + $report->set_extra_metadata('duplicate_of', undef); $report->update({ state => $old_state }); $report2->set_extra_metadata('duplicates', undef); @@ -241,6 +244,9 @@ FixMyStreet::override_config { my $old_state = $report->state; $report->comments->delete_all; + $mech->get_ok("/report/$report2_id/nearby.json"); + $mech->content_lacks('Add to shortlist'); + $mech->get_ok("/report/$report_id"); my $update_text = "This text was entered as an update by the user."; $mech->submit_form_ok({ button => 'save', with_fields => { @@ -253,6 +259,7 @@ FixMyStreet::override_config { is $report->state, 'duplicate', 'report marked as duplicate'; is $report->comments->search({ problem_state => 'duplicate' })->count, 1, 'update marked report as duplicate'; + $mech->get_ok("/report/$report_id"); # Get again as planned_reports permission means redirect to referer... $mech->content_contains($update_text); $mech->content_lacks("Thank you for your report. This problem has already been reported."); @@ -260,7 +267,6 @@ FixMyStreet::override_config { }; subtest "post-inspect redirect is to the right place if URL set" => sub { - $user->user_body_permissions->create({ body => $oxon, permission_type => 'planned_reports' }); $mech->get_ok("/report/$report_id"); my $update_text = "This text was entered as an update by the user."; $mech->submit_form_ok({ button => 'save', with_fields => { @@ -271,11 +277,9 @@ FixMyStreet::override_config { is $mech->res->code, 200, "got 200"; is $mech->res->previous->code, 302, "got 302 for redirect"; is $mech->uri->path, '/', 'redirected to front page'; - $user->user_body_permissions->search({ body_id => $oxon->id, permission_type => 'planned_reports' })->delete; }; subtest "post-inspect redirect is to the right place if URL not set" => sub { - $user->user_body_permissions->create({ body => $oxon, permission_type => 'planned_reports' }); $user->set_extra_metadata(categories => [ $contact->id ]); $user->update; $mech->get_ok("/report/$report_id"); @@ -292,7 +296,6 @@ FixMyStreet::override_config { is $params{lat}, $report->latitude, "latitude param is correct"; is $params{lon}, $report->longitude, "longitude param is correct"; is $params{filter_category}, $contact->category, "categories param is correct"; - $user->user_body_permissions->search({ body_id => $oxon->id, permission_type => 'planned_reports' })->delete; }; subtest "default response priorities display correctly" => sub { diff --git a/templates/web/base/report/_item.html b/templates/web/base/report/_item.html index 576f2b30f..8179139ca 100644 --- a/templates/web/base/report/_item.html +++ b/templates/web/base/report/_item.html @@ -121,13 +121,18 @@ </a> -[% IF item_action AND page != 'around' %] +[% IF item_action ~%] + [% IF page == 'report' ~%] + [%# We don't want to output shortlist on report page (in duplicate list) %] + [% ELSIF page == 'around' ~%] + [%# The around page list is already contained within the new report form %] + [% item_action.replace('("shortlist-[^"]*)', '$1-' _ problem.id) %] + [% ELSE ~%] <form method="post" action="/my/planned/change"> <input type="hidden" name="id" value="[% problem.id %]"> <input type="hidden" name="token" value="[% csrf_token %]"> [% item_action %] </form> -[% ELSIF item_action ~%] - [% item_action.replace('("shortlist-[^"]*)', '$1-' _ problem.id) %] -[% END ~%] + [% END ~%] +[% END %] </li> |