aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-12-15 17:25:05 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-12-15 17:25:05 +0000
commit2fd63afc46db7a3a33e608bf1f4b5c0b52c18728 (patch)
treeff9ed0f73cf0979acacb9f03fffeb62623be475a /perllib/FixMyStreet/App
parentb8aa0d6da9009dc3182093165df9b1a4c6d7d164 (diff)
parent6375eb5d31aa250f5d990d6d6420dd04cf25e3bf (diff)
Merge branch 'issues/forcouncils/108-pick-up-a-priority'
Diffstat (limited to 'perllib/FixMyStreet/App')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm31
1 files changed, 27 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index f7ccddc70..5a1cfbe54 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -308,6 +308,28 @@ sub inspect : Private {
$c->stash->{categories} = $c->forward('/admin/categories_for_point');
$c->stash->{report_meta} = { map { $_->{name} => $_ } @{ $c->stash->{problem}->get_extra_fields() } };
+ my %category_body = map { $_->category => $_->body_id } map { $_->contacts->all } values %{$problem->bodies};
+
+ my @priorities = $c->model('DB::ResponsePriority')->for_bodies($problem->bodies_str_ids)->all;
+ my $priorities_by_category = {};
+ foreach my $pri (@priorities) {
+ my $any = 0;
+ foreach ($pri->contacts->all) {
+ $any = 1;
+ push @{$priorities_by_category->{$_->category}}, $pri->id . '=' . URI::Escape::uri_escape_utf8($pri->name);
+ }
+ if (!$any) {
+ foreach (grep { $category_body{$_} == $pri->body_id } @{$c->stash->{categories}}) {
+ push @{$priorities_by_category->{$_}}, $pri->id . '=' . URI::Escape::uri_escape_utf8($pri->name);
+ }
+ }
+ }
+ foreach (keys %{$priorities_by_category}) {
+ $priorities_by_category->{$_} = join('&', @{$priorities_by_category->{$_}});
+ }
+
+ $c->stash->{priorities_by_category} = $priorities_by_category;
+
if ( $c->get_param('save') ) {
$c->forward('/auth/check_csrf_token');
@@ -355,10 +377,6 @@ sub inspect : Private {
}
}
- if ($c->get_param('priority') && ($permissions->{report_inspect} || $permissions->{report_edit_priority})) {
- $problem->response_priority( $problem->response_priorities->find({ id => $c->get_param('priority') }) );
- }
-
if ( !$c->forward( '/admin/report_edit_location', [ $problem ] ) ) {
# New lat/lon isn't valid, show an error
$valid = 0;
@@ -378,6 +396,11 @@ sub inspect : Private {
$c->forward('/report/new/set_report_extras', [ \@contacts, $param_prefix ]);
}
+ # Updating priority must come after category, in case category has changed (and so might have priorities)
+ if ($c->get_param('priority') && ($permissions->{report_inspect} || $permissions->{report_edit_priority})) {
+ $problem->response_priority( $problem->response_priorities->find({ id => $c->get_param('priority') }) );
+ }
+
if ($valid) {
if ( $reputation_change != 0 ) {
$problem->user->update_reputation($reputation_change);