aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-03-27 17:52:30 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-03-27 17:52:30 +0000
commit251f152b46816ed1c8401cda7f57305d08830af1 (patch)
tree3c46e9960b113869e757b011ecfdbcbdef5ff3ad
parent48c807b87f81ba89732d36b4459a4ca5bd4933ef (diff)
parentae88108b6a176744fef215093bcec835b323e5e6 (diff)
Merge branch 'issues/commercial/1273-ref-number-com'
-rw-r--r--perllib/FixMyStreet/Cobrand/BathNES.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Buckinghamshire.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Lincolnshire.pm2
-rw-r--r--perllib/FixMyStreet/Script/Reports.pm12
-rw-r--r--t/app/controller/report_as_other.t4
-rw-r--r--t/app/model/problem.t2
-rw-r--r--t/cobrand/bucks.t22
-rw-r--r--templates/email/buckinghamshire/other-reported.html4
-rw-r--r--templates/email/buckinghamshire/other-reported.txt4
-rw-r--r--templates/email/default/other-reported.html4
-rw-r--r--templates/email/default/other-reported.txt4
-rw-r--r--templates/email/fixamingata/other-reported.html4
-rw-r--r--templates/email/fixamingata/other-reported.txt4
-rw-r--r--templates/email/fixmystreet.com/_council_reference.html4
-rw-r--r--templates/email/fixmystreet.com/_council_reference.txt4
-rw-r--r--templates/email/fixmystreet.com/confirm_report_sent.html1
-rw-r--r--templates/email/fixmystreet.com/confirm_report_sent.txt1
18 files changed, 53 insertions, 29 deletions
diff --git a/perllib/FixMyStreet/Cobrand/BathNES.pm b/perllib/FixMyStreet/Cobrand/BathNES.pm
index e3ae6763f..e26e846c3 100644
--- a/perllib/FixMyStreet/Cobrand/BathNES.pm
+++ b/perllib/FixMyStreet/Cobrand/BathNES.pm
@@ -151,7 +151,7 @@ sub available_permissions {
return $permissions;
}
-sub report_sent_confirmation_email { 1 }
+sub report_sent_confirmation_email { 'id' }
sub lookup_usrn {
my $self = shift;
diff --git a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
index ef5b53356..3a33d6f58 100644
--- a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
@@ -447,7 +447,7 @@ sub should_skip_sending_update {
sub disable_phone_number_entry { 1 }
-sub report_sent_confirmation_email { 1 }
+sub report_sent_confirmation_email { 'external_id' }
sub is_council_with_case_management { 1 }
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 946523626..ed15dbf05 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -1031,7 +1031,7 @@ sub report_check_for_errors {
);
}
-sub report_sent_confirmation_email { 0; }
+sub report_sent_confirmation_email { '' }
=item never_confirm_reports
diff --git a/perllib/FixMyStreet/Cobrand/Lincolnshire.pm b/perllib/FixMyStreet/Cobrand/Lincolnshire.pm
index a4cee8a03..8d8ba3268 100644
--- a/perllib/FixMyStreet/Cobrand/Lincolnshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Lincolnshire.pm
@@ -20,7 +20,7 @@ sub is_two_tier { 1 }
sub enable_category_groups { 1 }
sub send_questionnaires { 0 }
-sub report_sent_confirmation_email { 1 }
+sub report_sent_confirmation_email { 'external_id' }
sub admin_user_domain { 'lincolnshire.gov.uk' }
diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm
index ba629b016..1fef6fe08 100644
--- a/perllib/FixMyStreet/Script/Reports.pm
+++ b/perllib/FixMyStreet/Script/Reports.pm
@@ -127,10 +127,19 @@ sub send(;$) {
$missing = join(' / ', @missing) if @missing;
}
+ my $send_confirmation_email = $cobrand->report_sent_confirmation_email;
+
my @dear;
my %reporters = ();
my $skip = 0;
while (my $body = $bodies->next) {
+ # See if this body wants confirmation email (in case report made on national site, for example)
+ if (my $cobrand_body = $body->get_cobrand_handler) {
+ if (my $id_ref = $cobrand_body->report_sent_confirmation_email) {
+ $send_confirmation_email = $id_ref;
+ }
+ }
+
my $sender_info = $cobrand->get_body_sender( $body, $row->category );
my $sender = "FixMyStreet::SendReport::" . $sender_info->{method};
@@ -243,7 +252,8 @@ sub send(;$) {
whensent => \'current_timestamp',
lastupdate => \'current_timestamp',
} );
- if ( $cobrand->report_sent_confirmation_email && !$h{anonymous_report}) {
+ if ($send_confirmation_email && !$h{anonymous_report}) {
+ $h{sent_confirm_id_ref} = $row->$send_confirmation_email;
_send_report_sent_email( $row, \%h, $nomail, $cobrand );
}
debug_print("send successful: OK", $row->id) if $debug_mode;
diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t
index f256374a8..9ed46190b 100644
--- a/t/app/controller/report_as_other.t
+++ b/t/app/controller/report_as_other.t
@@ -123,7 +123,7 @@ subtest "Body user, has permission to add report as another (existing) user with
my $send_confirmation_mail_override = Sub::Override->new(
"FixMyStreet::Cobrand::Default::report_sent_confirmation_email",
- sub { return 1; }
+ sub { return 'external_id'; }
);
FixMyStreet::Script::Reports::send();
$mech->email_count_is(2);
@@ -168,7 +168,7 @@ subtest "Body user, has permission to add report as anonymous user" => sub {
my $send_confirmation_mail_override = Sub::Override->new(
"FixMyStreet::Cobrand::Default::report_sent_confirmation_email",
- sub { return 1; }
+ sub { return 'external_id'; }
);
FixMyStreet::Script::Reports::send();
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index b9bbe4682..503fa9276 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -633,7 +633,7 @@ subtest 'check can set multiple emails as a single contact' => sub {
subtest 'check can turn on report sent email alerts' => sub {
my $send_confirmation_mail_override = Sub::Override->new(
"FixMyStreet::Cobrand::Default::report_sent_confirmation_email",
- sub { return 1; }
+ sub { return 'external_id'; }
);
$mech->clear_emails_ok;
diff --git a/t/cobrand/bucks.t b/t/cobrand/bucks.t
index 74684c27e..965b90107 100644
--- a/t/cobrand/bucks.t
+++ b/t/cobrand/bucks.t
@@ -51,9 +51,10 @@ my ($report) = $mech->create_problems_for_body(1, $body->id, 'On Road', {
subtest 'flytipping on road sent to extra email' => sub {
FixMyStreet::Script::Reports::send();
- my $email = $mech->get_email;
+ my @email = $mech->get_email;
my $tfb = join('', 'illegaldumpingcosts', '@', 'buckscc.gov.uk');
- is $email->header('To'), '"TfB" <' . $tfb . '>';
+ is $email[0]->header('To'), '"TfB" <' . $tfb . '>';
+ like $mech->get_text_body_from_email($email[1]), qr/report's reference number/;
$report->discard_changes;
is $report->external_id, 248, 'Report has right external ID';
};
@@ -67,22 +68,24 @@ subtest 'flytipping on road sent to extra email' => sub {
},
});
-subtest 'pothole on road not sent to extra email' => sub {
+subtest 'pothole on road not sent to extra email, only confirm sent' => sub {
$mech->clear_emails_ok;
FixMyStreet::Script::Reports::send();
- $mech->email_count_is(0);
+ $mech->email_count_is(1);
+ like $mech->get_text_body_from_email, qr/report's reference number/;
$report->discard_changes;
is $report->external_id, 248, 'Report has right external ID';
};
($report) = $mech->create_problems_for_body(1, $district->id, 'Off Road', {
- category => 'Flytipping', cobrand => 'fixmystreet',
+ category => 'Flytipping', cobrand => 'buckinghamshire',
latitude => 51.813173, longitude => -0.826741,
});
subtest 'flytipping off road sent to extra email' => sub {
FixMyStreet::Script::Reports::send();
- my $email = $mech->get_email;
- is $email->header('To'), '"Chiltern" <flytipping@chiltern>';
+ my @email = $mech->get_email;
+ is $email[0]->header('To'), '"Chiltern" <flytipping@chiltern>';
+ like $mech->get_text_body_from_email($email[1]), qr/Please note that Buckinghamshire County Council is not responsible/;
$report->discard_changes;
is $report->external_id, undef, 'Report has right external ID';
};
@@ -95,9 +98,10 @@ my ($report2) = $mech->create_problems_for_body(1, $body->id, 'Drainage problem'
subtest 'blocked drain sent to extra email' => sub {
$mech->clear_emails_ok;
FixMyStreet::Script::Reports::send();
- my $email = $mech->get_email;
+ my @email = $mech->get_email;
my $e = join('@', 'floodmanagement', 'buckscc.gov.uk');
- is $email->header('To'), '"Flood Management" <' . $e . '>';
+ is $email[0]->header('To'), '"Flood Management" <' . $e . '>';
+ like $mech->get_text_body_from_email($email[1]), qr/report's reference number/;
};
$cobrand = FixMyStreet::Cobrand::Buckinghamshire->new();
diff --git a/templates/email/buckinghamshire/other-reported.html b/templates/email/buckinghamshire/other-reported.html
index fe03376f5..584c5b89e 100644
--- a/templates/email/buckinghamshire/other-reported.html
+++ b/templates/email/buckinghamshire/other-reported.html
@@ -12,8 +12,8 @@ INCLUDE '_email_top.html';
[% start_padded_box %]
<h1 style="[% h1_style %]">Your report has been&nbsp;logged</h1>
<p style="[% p_style %]">Your report to [% report.body %] has been logged on [% site_name %].</p>
-[% IF c.cobrand.is_council && !c.cobrand.owns_problem( report ) %]
-<p style="[% p_style %]">Please note that [% c.cobrand.council_name %] is not responsible for this type
+[% IF cobrand.is_council && !cobrand.owns_problem( report ) %]
+<p style="[% p_style %]">Please note that [% cobrand.council_name %] is not responsible for this type
of report, so it will instead be sent to [% report.body %].</p>
[% ELSE %]
[% TRY %][% INCLUDE '_council_reference.html' problem=report %][% CATCH file %][% END %]
diff --git a/templates/email/buckinghamshire/other-reported.txt b/templates/email/buckinghamshire/other-reported.txt
index 50a879d79..7f78617e0 100644
--- a/templates/email/buckinghamshire/other-reported.txt
+++ b/templates/email/buckinghamshire/other-reported.txt
@@ -4,8 +4,8 @@ Hello [% report.name %],
Your report to [% report.body %] has been logged on [% site_name %].
-[% IF c.cobrand.is_council && !c.cobrand.owns_problem( report ) %]
-Please note that [% c.cobrand.council_name %] is not responsible for this type
+[% IF cobrand.is_council && !cobrand.owns_problem( report ) %]
+Please note that [% cobrand.council_name %] is not responsible for this type
of report, so it will instead be sent to [% report.body %].
[% ELSE %]
[% TRY %][% INCLUDE '_council_reference.txt' problem=report %][% CATCH file %][% END %]
diff --git a/templates/email/default/other-reported.html b/templates/email/default/other-reported.html
index fe03376f5..584c5b89e 100644
--- a/templates/email/default/other-reported.html
+++ b/templates/email/default/other-reported.html
@@ -12,8 +12,8 @@ INCLUDE '_email_top.html';
[% start_padded_box %]
<h1 style="[% h1_style %]">Your report has been&nbsp;logged</h1>
<p style="[% p_style %]">Your report to [% report.body %] has been logged on [% site_name %].</p>
-[% IF c.cobrand.is_council && !c.cobrand.owns_problem( report ) %]
-<p style="[% p_style %]">Please note that [% c.cobrand.council_name %] is not responsible for this type
+[% IF cobrand.is_council && !cobrand.owns_problem( report ) %]
+<p style="[% p_style %]">Please note that [% cobrand.council_name %] is not responsible for this type
of report, so it will instead be sent to [% report.body %].</p>
[% ELSE %]
[% TRY %][% INCLUDE '_council_reference.html' problem=report %][% CATCH file %][% END %]
diff --git a/templates/email/default/other-reported.txt b/templates/email/default/other-reported.txt
index 1dc8d0b44..7b1230555 100644
--- a/templates/email/default/other-reported.txt
+++ b/templates/email/default/other-reported.txt
@@ -4,8 +4,8 @@ Hello [% report.name %],
Your report to [% report.body %] has been logged on [% site_name %].
-[% IF c.cobrand.is_council && !c.cobrand.owns_problem( report ) %]
-Please note that [% c.cobrand.council_name %] is not responsible for this type
+[% IF cobrand.is_council && !cobrand.owns_problem( report ) %]
+Please note that [% cobrand.council_name %] is not responsible for this type
of report, so it will instead be sent to [% report.body %].
[% ELSE %]
[% TRY %][% INCLUDE '_council_reference.txt' problem=report %][% CATCH file %][% END %]
diff --git a/templates/email/fixamingata/other-reported.html b/templates/email/fixamingata/other-reported.html
index 3ba29dcb0..0b0160696 100644
--- a/templates/email/fixamingata/other-reported.html
+++ b/templates/email/fixamingata/other-reported.html
@@ -12,8 +12,8 @@ INCLUDE '_email_top.html';
[% start_padded_box %]
<h1 style="[% h1_style %]">Din rapport har&nbsp;loggats</h1>
<p style="[% p_style %]">Din rapport till [% report.body %] har blivit loggad på [% site_name %].
-[% IF c.cobrand.is_council && !c.cobrand.owns_problem( report ) %]
-Eftersom [% c.cobrand.council_name %] inte är ansvarig för den här typen av
+[% IF cobrand.is_council && !cobrand.owns_problem( report ) %]
+Eftersom [% cobrand.council_name %] inte är ansvarig för den här typen av
rapporter, så kommer rapporten istället att skickas till [% report.body %].
[% END %]
</p>
diff --git a/templates/email/fixamingata/other-reported.txt b/templates/email/fixamingata/other-reported.txt
index 2c50c765c..e39adf527 100644
--- a/templates/email/fixamingata/other-reported.txt
+++ b/templates/email/fixamingata/other-reported.txt
@@ -4,8 +4,8 @@ Hej [% report.name %],
Din rapport till [% report.body %] har blivit loggad på [% site_name %].
-[% IF c.cobrand.is_council && !c.cobrand.owns_problem( report ) %]
-Eftersom [% c.cobrand.council_name %] inte är ansvarig för den här typen av
+[% IF cobrand.is_council && !cobrand.owns_problem( report ) %]
+Eftersom [% cobrand.council_name %] inte är ansvarig för den här typen av
rapporter, så kommer rapporten istället att skickas till [% report.body %].
[% END %]
diff --git a/templates/email/fixmystreet.com/_council_reference.html b/templates/email/fixmystreet.com/_council_reference.html
new file mode 100644
index 000000000..7a37c4454
--- /dev/null
+++ b/templates/email/fixmystreet.com/_council_reference.html
@@ -0,0 +1,4 @@
+[% IF sent_confirm_id_ref ~%]
+<p style="[% p_style %]">The report's reference number is <strong>[% sent_confirm_id_ref %]</strong>.
+ Please quote this if you need to contact the council about this report.</p>
+[%~ END %]
diff --git a/templates/email/fixmystreet.com/_council_reference.txt b/templates/email/fixmystreet.com/_council_reference.txt
new file mode 100644
index 000000000..5eac50791
--- /dev/null
+++ b/templates/email/fixmystreet.com/_council_reference.txt
@@ -0,0 +1,4 @@
+[% IF sent_confirm_id_ref ~%]
+The report's reference number is [% sent_confirm_id_ref %]. Please quote this
+if you need to contact the council about this report.
+[%~ END %]
diff --git a/templates/email/fixmystreet.com/confirm_report_sent.html b/templates/email/fixmystreet.com/confirm_report_sent.html
new file mode 100644
index 000000000..5a0c19f0d
--- /dev/null
+++ b/templates/email/fixmystreet.com/confirm_report_sent.html
@@ -0,0 +1 @@
+[% INCLUDE 'other-reported.html' %] \ No newline at end of file
diff --git a/templates/email/fixmystreet.com/confirm_report_sent.txt b/templates/email/fixmystreet.com/confirm_report_sent.txt
new file mode 100644
index 000000000..3d566f89b
--- /dev/null
+++ b/templates/email/fixmystreet.com/confirm_report_sent.txt
@@ -0,0 +1 @@
+[% INCLUDE 'other-reported.txt' %]