aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm3
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm6
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/DefectType.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm8
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/ResponseTemplate.pm2
-rw-r--r--perllib/FixMyStreet/Roles/ContactExtra.pm2
-rw-r--r--perllib/FixMyStreet/TestMech.pm31
7 files changed, 16 insertions, 38 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 81d5b18b5..98c4aba17 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -413,7 +413,8 @@ sub inspect : Private {
if ($c->cobrand->can('body')) {
my $priorities_by_category = FixMyStreet::App->model('DB::ResponsePriority')->by_categories(
$c->stash->{contacts},
- body_id => $c->cobrand->body->id
+ body_id => $c->cobrand->body->id,
+ problem => $problem,
);
$c->stash->{priorities_by_category} = $priorities_by_category;
my $templates_by_category = FixMyStreet::App->model('DB::ResponseTemplate')->by_categories(
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 705f07f79..cd5e876b4 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -780,7 +780,11 @@ alphabetical order of name.
sub response_priorities {
my $self = shift;
- return $self->result_source->schema->resultset('ResponsePriority')->for_bodies($self->bodies_str_ids, $self->category);
+ my $rs = $self->result_source->schema->resultset('ResponsePriority')->for_bodies($self->bodies_str_ids, $self->category);
+ $rs->search([
+ 'me.deleted' => 0,
+ 'me.id' => $self->response_priority_id,
+ ]);
}
=head2 defect_types
diff --git a/perllib/FixMyStreet/DB/ResultSet/DefectType.pm b/perllib/FixMyStreet/DB/ResultSet/DefectType.pm
index 5b1247129..c4c11042f 100644
--- a/perllib/FixMyStreet/DB/ResultSet/DefectType.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/DefectType.pm
@@ -12,7 +12,7 @@ sub join_table {
}
sub map_extras {
- my ($rs, @ts) = @_;
+ my ($rs, $params, @ts) = @_;
return map {
my $meta = $_->get_extra_metadata();
my %extra = map { $_ => $meta->{$_} } keys %$meta;
diff --git a/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm b/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm
index 96f7cf7a0..af605afa6 100644
--- a/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm
@@ -12,8 +12,12 @@ sub join_table {
}
sub map_extras {
- my ($rs, @ts) = @_;
- return map { { id => $_->id, name => $_->name } } @ts;
+ my ($rs, $params, @ts) = @_;
+ my $current = $params->{problem} && $params->{problem}->response_priority_id || 0;
+ return
+ map { { id => $_->id, name => $_->name } }
+ grep { !$_->deleted || $_->id == $current }
+ @ts;
}
1;
diff --git a/perllib/FixMyStreet/DB/ResultSet/ResponseTemplate.pm b/perllib/FixMyStreet/DB/ResultSet/ResponseTemplate.pm
index 46fcba153..88ecc2f94 100644
--- a/perllib/FixMyStreet/DB/ResultSet/ResponseTemplate.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/ResponseTemplate.pm
@@ -14,7 +14,7 @@ sub name_column {
}
sub map_extras {
- my ($rs, @ts) = @_;
+ my ($rs, $params, @ts) = @_;
return map {
my $out = { id => $_->text, name => $_->title };
$out->{state} = $_->state if $_->state;
diff --git a/perllib/FixMyStreet/Roles/ContactExtra.pm b/perllib/FixMyStreet/Roles/ContactExtra.pm
index 73b1d3e6a..9615b0f0c 100644
--- a/perllib/FixMyStreet/Roles/ContactExtra.pm
+++ b/perllib/FixMyStreet/Roles/ContactExtra.pm
@@ -45,7 +45,7 @@ sub by_categories {
$_->$join_table == 0 # There's no category at all on this defect type/template/priority
|| (grep { $_->contact_id == $contact->get_column('id') } $_->$join_table)
} @results;
- @ts = $rs->map_extras(@ts);
+ @ts = $rs->map_extras(\%params, @ts);
$extras{$contact->category} = JSON::XS->new->encode(\@ts);
}
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm
index f6854fc98..7f7104d3d 100644
--- a/perllib/FixMyStreet/TestMech.pm
+++ b/perllib/FixMyStreet/TestMech.pm
@@ -609,29 +609,6 @@ sub get_ok_json {
return decode_json( $res->content );
}
-sub delete_body {
- my $mech = shift;
- my $body = shift;
-
- $mech->delete_problems_for_body($body->id);
- $mech->delete_defect_type($_) for $body->defect_types;
- $mech->delete_contact($_) for $body->contacts;
- $mech->delete_user($_) for $body->users;
- $_->delete for $body->response_templates;
- $_->delete for $body->response_priorities;
- $body->body_areas->delete;
- $body->delete;
-}
-
-sub delete_contact {
- my $mech = shift;
- my $contact = shift;
-
- $contact->contact_response_templates->delete_all;
- $contact->contact_response_priorities->delete_all;
- $contact->delete;
-}
-
sub delete_problems_for_body {
my $mech = shift;
my $body = shift;
@@ -646,14 +623,6 @@ sub delete_problems_for_body {
}
}
-sub delete_defect_type {
- my $mech = shift;
- my $defect_type = shift;
-
- $defect_type->contact_defect_types->delete_all;
- $defect_type->delete;
-}
-
sub delete_response_template {
my $mech = shift;
my $response_template = shift;