From 51a83fee9ff77c9a0c9eea1ce10ac43793118d0e Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 14 Oct 2016 14:01:42 +0100 Subject: Fix list of response templates for a problem. Instead of returning all templates for the problem's body, return those for the problem's category (or with no category). --- perllib/FixMyStreet/DB/Result/Problem.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm') diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 855732f83..ae713ef2d 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -658,13 +658,15 @@ order of title. =cut sub response_templates { - my $problem = shift; - return $problem->result_source->schema->resultset('ResponseTemplate')->search( + my $self = shift; + return $self->result_source->schema->resultset('ResponseTemplate')->search( { - body_id => $problem->bodies_str_ids + 'me.body_id' => $self->bodies_str_ids, + 'contact.category' => [ $self->category, undef ], }, { - order_by => 'title' + order_by => 'title', + join => { 'contact_response_templates' => 'contact' }, } ); } -- cgit v1.2.3