aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/My.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2017-10-26 10:26:36 +0100
committerStruan Donald <struan@exo.org.uk>2017-10-27 12:25:07 +0100
commit8eadf44dd462fd3016f9b70b79bfeacd6147ef12 (patch)
tree49cd729f08a95d9a65186f153d4b34f1358831bb /perllib/FixMyStreet/App/Controller/My.pm
parent27cab90573fb1c68076adf252a161687fa981b9c (diff)
always allow problems to be removed from shortlist
If a user is trying to remove a problem from their shortlist we should always allow it regardless of the state of the problem. Previously if a problem wasn't displayed on the site then it could not be removed from the shortlist which was an issue with council cobrands and reports that had changed body. Fixes mysociety/fixmystreetforcouncils#243
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/My.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/My.pm18
1 files changed, 11 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm
index 9647fae9a..1693766ba 100644
--- a/perllib/FixMyStreet/App/Controller/My.pm
+++ b/perllib/FixMyStreet/App/Controller/My.pm
@@ -189,17 +189,21 @@ sub planned_change : Path('planned/change') {
$c->go('planned') if grep { /^shortlist-(up|down|\d+)$/ } keys %{$c->req->params};
my $id = $c->get_param('id');
- $c->forward( '/report/load_problem_or_display_error', [ $id ] );
-
my $add = $c->get_param('shortlist-add');
my $remove = $c->get_param('shortlist-remove');
- $c->detach('/page_error_403_access_denied', [])
- unless $add || $remove;
- if ($add) {
+ # we can't lookup the report for removing via load_problem_or_display_error
+ # as then there is no way to remove a report that has been hidden or moved
+ # to another body by a category change from the shortlist.
+ if ($remove) {
+ my $report = $c->model('DB::Problem')->find({ id => $id })
+ or $c->detach( '/page_error_404_not_found', [ _('Unknown problem ID') ] );
+ $c->user->remove_from_planned_reports($report);
+ } elsif ($add) {
+ $c->forward( '/report/load_problem_or_display_error', [ $id ] );
$c->user->add_to_planned_reports($c->stash->{problem});
- } elsif ($remove) {
- $c->user->remove_from_planned_reports($c->stash->{problem});
+ } else {
+ $c->detach('/page_error_403_access_denied', []);
}
if ($c->get_param('ajax')) {