aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rwxr-xr-xbin/oxfordshire/send-rdi-emails1
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm1
-rw-r--r--perllib/FixMyStreet/Integrations/ExorRDI.pm28
-rw-r--r--t/Mock/MapIt.pm1
-rw-r--r--t/cobrand/oxfordshire.t84
-rw-r--r--templates/email/default/problem-confirm.html2
-rw-r--r--templates/email/default/problem-confirm.txt1
-rw-r--r--templates/email/oxfordshire/_problem-confirm_extra.html14
-rw-r--r--templates/email/oxfordshire/_problem-confirm_extra.txt12
-rw-r--r--templates/web/base/email_sent.html2
-rw-r--r--templates/web/base/report/_inspect.html1
-rw-r--r--templates/web/oxfordshire/_email_sent_extra.html1
-rw-r--r--templates/web/oxfordshire/_response_time.html14
-rw-r--r--templates/web/oxfordshire/report/_council_sent_info.html15
-rw-r--r--templates/web/oxfordshire/report/_inspect_extra_info.html8
-rw-r--r--templates/web/oxfordshire/tokens/_extras_confirm.html1
17 files changed, 168 insertions, 19 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 480723c1b..0fc68419b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@
- Report pages list every update to a report. #1806
- Clearer wording and more prominent email input on alert page.
- Cobrands can implement `hide_areas_on_reports` to hide outline on map.
+ - Templates to allow extra messages through problem confirmation. #1837
- Admin improvements:
- Highlight current shortlisted user in list tooltip. #1788
- Extra fields on contacts can be edited. #1743
diff --git a/bin/oxfordshire/send-rdi-emails b/bin/oxfordshire/send-rdi-emails
index 9eff02715..ab58ff525 100755
--- a/bin/oxfordshire/send-rdi-emails
+++ b/bin/oxfordshire/send-rdi-emails
@@ -38,6 +38,7 @@ foreach my $inspector (@inspectors) {
end_date => $end_date,
inspection_date => $inspection_date,
user => $inspector,
+ mark_as_processed => 1,
};
my $rdi = FixMyStreet::Integrations::ExorRDI->new($params);
try {
diff --git a/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm b/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm
index b6f1e6bdf..bdeecc1a3 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/ExorDefects.pm
@@ -53,6 +53,7 @@ sub download : Path('download') : Args(0) {
inspection_date => $start_date,
end_date => $end_date + $one_day,
user => $c->get_param('user_id'),
+ mark_as_processed => 0,
};
my $rdi = FixMyStreet::Integrations::ExorRDI->new($params);
diff --git a/perllib/FixMyStreet/Integrations/ExorRDI.pm b/perllib/FixMyStreet/Integrations/ExorRDI.pm
index 4ce888cff..fc7e9d673 100644
--- a/perllib/FixMyStreet/Integrations/ExorRDI.pm
+++ b/perllib/FixMyStreet/Integrations/ExorRDI.pm
@@ -23,7 +23,7 @@ use Scalar::Util 'blessed';
use FixMyStreet::DB;
use namespace::clean;
-has [qw(start_date end_date inspection_date)] => (
+has [qw(start_date end_date inspection_date mark_as_processed)] => (
is => 'ro',
required => 1,
);
@@ -43,13 +43,23 @@ sub construct {
my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('oxfordshire')->new;
my $dtf = $cobrand->problems->result_source->storage->datetime_parser;
+ my $missed_cutoff = DateTime->now - DateTime::Duration->new( hours => 24 );
my %params = (
-and => [
state => [ 'action scheduled' ],
external_id => { '!=' => undef },
- 'admin_log_entries.action' => 'inspected',
- 'admin_log_entries.whenedited' => { '>=', $dtf->format_datetime($self->start_date) },
- 'admin_log_entries.whenedited' => { '<=', $dtf->format_datetime($self->end_date) },
+ -or => [
+ -and => [
+ 'admin_log_entries.action' => 'inspected',
+ 'admin_log_entries.whenedited' => { '>=', $dtf->format_datetime($self->start_date) },
+ 'admin_log_entries.whenedited' => { '<=', $dtf->format_datetime($self->end_date) },
+ ],
+ -and => [
+ extra => { -not_like => '%rdi_processed%' },
+ 'admin_log_entries.action' => 'inspected',
+ 'admin_log_entries.whenedited' => { '<=', $dtf->format_datetime($missed_cutoff) },
+ ]
+ ]
]
);
@@ -198,6 +208,16 @@ sub construct {
0, 0, 0 # error counts, always zero
);
+ if ($self->mark_as_processed) {
+ # Mark all these problems are having been included in an RDI
+ my $now = DateTime->now->strftime( '%Y-%m-%d %H:%M' );
+ $problems->reset;
+ while ( my $report = $problems->next ) {
+ $report->set_extra_metadata('rdi_processed' => $now);
+ $report->update;
+ }
+ }
+
# The RDI format is very weird CSV - each line must be wrapped in
# double quotes.
return join "", map { "\"$_\"\r\n" } @$body;
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index ad1d0c99c..926d94b1e 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -28,6 +28,7 @@ my @PLACES = (
[ 'SW1A 1AA', 51.501009, -0.141588, 2504, 'Westminster City Council', 'LBO' ],
[ 'GL50 2PR', 51.896268, -2.093063, 2226, 'Gloucestershire County Council', 'CTY', 2326, 'Cheltenham Borough Council', 'DIS', 4544, 'Lansdown', 'DIW', 143641, 'Lansdown and Park', 'CED' ],
[ '?', 51.754926, -1.256179, 2237, 'Oxfordshire County Council', 'CTY', 2421, 'Oxford City Council', 'DIS' ],
+ [ 'OX20 1SZ', 51.754926, -1.256179, 2237, 'Oxfordshire County Council', 'CTY', 2421, 'Oxford City Council', 'DIS' ],
[ 'BR1 3UH', 51.4021, 0.01578, 2482, 'Bromley Council', 'LBO' ],
[ '?', 50.78301, -0.646929 ],
[ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ],
diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t
index 89792765c..e6c16950c 100644
--- a/t/cobrand/oxfordshire.t
+++ b/t/cobrand/oxfordshire.t
@@ -1,3 +1,5 @@
+use FixMyStreet::Integrations::ExorRDI;
+
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
@@ -47,6 +49,8 @@ my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super Us
my $inspector = $mech->create_user_ok('inspector@example.com', name => 'Inspector');
$inspector->user_body_permissions->create({ body => $oxon, permission_type => 'report_inspect' });
+my @problems = FixMyStreet::DB->resultset('Problem')->search({}, { rows => 3 })->all;
+
subtest 'Exor RDI download appears on Oxfordshire cobrand admin' => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ { 'oxfordshire' => '.' } ],
@@ -97,7 +101,6 @@ subtest 'Exor file looks okay' => sub {
$dt2->set_extra_metadata(activity_code => 'S');
$dt2->set_extra_metadata(defect_code => 'ACC2');
$dt2->update;
- my @problems = FixMyStreet::DB->resultset('Problem')->search({}, { rows => 3 })->all;
my $i = 123;
foreach my $problem (@problems) {
$problem->update({ state => 'action scheduled', external_id => $i });
@@ -142,9 +145,88 @@ subtest 'Exor file looks okay' => sub {
"P,0,999999"
"X,3,3,3,3,0,0,0,3,0,3,0,0,0"
EOF
+ foreach my $problem (@problems) {
+ $problem->discard_changes;
+ is $problem->get_extra_metadata('rdi_processed'), undef, "Problem was not logged as sent in RDI";
+ }
+
}
};
+subtest 'Reports are marked as inspected correctly' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'oxfordshire' ],
+ }, sub {
+ my $date = DateTime->new(year => 2017, month => 5, day => 5, hour => 12);
+ my $params = {
+ start_date => $date,
+ end_date => $date,
+ inspection_date => $date,
+ user => $inspector,
+ mark_as_processed => 1,
+ };
+ my $rdi = FixMyStreet::Integrations::ExorRDI->new($params);
+ $rdi->construct;
+
+ my $now = DateTime->now->strftime( '%Y-%m-%d %H:%M' );
+ foreach my $problem (@problems) {
+ $problem->discard_changes;
+ is $problem->get_extra_metadata('rdi_processed'), $now, "Problem was logged as sent in RDI";
+ }
+ };
+};
+
+subtest 'response times messages displayed' => sub {
+ my $oxfordshire = $mech->create_body_ok(
+ 2237, 'Oxfordshire County Council'
+ );
+ my $contact = $mech->create_contact_ok(
+ body_id => $oxfordshire->id,
+ category => 'Pothole',
+ email => 'pothole@example.com',
+ );
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'oxfordshire' ],
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $mech->log_out_ok;
+ $mech->clear_emails_ok;
+
+ $mech->get_ok('/around');
+ $mech->submit_form_ok( {
+ with_fields => { pc => 'OX20 1SZ' }
+ },
+ "submit_location"
+ );
+
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
+ "follow 'skip this step' link" );
+
+ $mech->submit_form_ok(
+ {
+ with_fields => {
+ title => 'Test Report',
+ detail => 'Test report details.',
+ photo1 => '',
+ email => 'test-2@example.com',
+ name => 'Test User',
+ category => 'Pothole',
+ }
+ },
+ "submit details"
+ );
+
+ $mech->text_contains('Problems in the Pothole category are generally responded');
+ my $email = $mech->get_email;
+ ok $email, 'got and email';
+ like $mech->get_text_body_from_email, qr/Problems in the Pothole category/, 'emails contains response time message';
+ my $url = $mech->get_link_from_email($email);
+ $mech->get_ok($url);
+ $mech->text_contains('Problems in the Pothole category are generally responded')
+ };
+};
+
END {
done_testing();
}
diff --git a/templates/email/default/problem-confirm.html b/templates/email/default/problem-confirm.html
index 904cf7777..f545d7385 100644
--- a/templates/email/default/problem-confirm.html
+++ b/templates/email/default/problem-confirm.html
@@ -17,6 +17,8 @@ INCLUDE '_email_top.html';
Please note that [% c.cobrand.council_name %] is not responsible for this type
of problem, so it will instead be sent to [% report.body %].
[% END %]
+
+[% TRY %][% INCLUDE '_problem-confirm_extra.html' %][% CATCH file %][% END %]
</p>
<p style="[% p_style %]">Your report will also appear on the [% site_name %] website.</p>
<p style="margin: 20px auto; text-align: center">
diff --git a/templates/email/default/problem-confirm.txt b/templates/email/default/problem-confirm.txt
index 9d0767671..e9e7378d1 100644
--- a/templates/email/default/problem-confirm.txt
+++ b/templates/email/default/problem-confirm.txt
@@ -14,6 +14,7 @@ into your web browser and press return.
Please note that [% c.cobrand.council_name %] is not responsible for this type
of problem, so it will instead be sent to [% report.body %].
[% END %]
+[% TRY %][% INCLUDE '_problem-confirm_extra.txt' %][% CATCH file %][% END %]
Your problem had the title:
[% report.title %]
diff --git a/templates/email/oxfordshire/_problem-confirm_extra.html b/templates/email/oxfordshire/_problem-confirm_extra.html
new file mode 100644
index 000000000..5e22be6b9
--- /dev/null
+++ b/templates/email/oxfordshire/_problem-confirm_extra.html
@@ -0,0 +1,14 @@
+[% IF c.cobrand.problem_response_days(report) == 'emergency' %]
+ <p>
+ Thank you for contacting Oxfordshire County Council [% report.category %], unfortunately we are currently only available to respond to emergency situations which may have an impact on the health and safety of members of the public, these will be dealt with within a 24 hour period.<br />
+ Reported faults will continue to be registered on our management system and these will be tackled in coming months.
+ </p>
+[% ELSIF c.cobrand.problem_response_days(report) > 0 %]
+ <p>
+ Problems in the
+ [% report.category %]
+ category are generally responded to within
+ [% c.cobrand.problem_response_days(report) %]
+ working days.
+ </p>
+[% END %]
diff --git a/templates/email/oxfordshire/_problem-confirm_extra.txt b/templates/email/oxfordshire/_problem-confirm_extra.txt
new file mode 100644
index 000000000..eb9ccfd12
--- /dev/null
+++ b/templates/email/oxfordshire/_problem-confirm_extra.txt
@@ -0,0 +1,12 @@
+[% IF c.cobrand.problem_response_days(report) == 'emergency' %]
+Thank you for contacting Oxfordshire County Council [% report.category %],
+unfortunately we are currently only available to respond to emergency
+situations which may have an impact on the health and safety of members
+of the public, these will be dealt with within a 24 hour period.
+
+Reported faults will continue to be registered on our management
+system and these will be tackled in coming months.
+[% ELSIF c.cobrand.problem_response_days(report) > 0 %]
+Problems in the [% report.category %] category are generally responded
+to within [% c.cobrand.problem_response_days(report) %] working days.
+[% END %]
diff --git a/templates/web/base/email_sent.html b/templates/web/base/email_sent.html
index 7d38f9d67..2724dabb9 100644
--- a/templates/web/base/email_sent.html
+++ b/templates/web/base/email_sent.html
@@ -14,6 +14,8 @@
[% END %]
</p>
+ [% TRY %][% INCLUDE '_email_sent_extra.html' %][% CATCH file %][% END %]
+
<p>
[% loc("Can&rsquo;t find our email? Check your spam folder&nbsp;&ndash; that&rsquo;s the solution 99% of the time.") %]
</p>
diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html
index 59806dc66..561be30d1 100644
--- a/templates/web/base/report/_inspect.html
+++ b/templates/web/base/report/_inspect.html
@@ -171,6 +171,7 @@
[% ELSE %]
<p>[% loc("<strong>Note:</strong> This report hasn't yet been sent onwards for action. Any changes made may not be passed on.") %]</p>
[% END %]
+ [% TRY %][% INCLUDE 'report/_inspect_extra_info.html' %][% CATCH file %][% END %]
[% END %]
<p>
diff --git a/templates/web/oxfordshire/_email_sent_extra.html b/templates/web/oxfordshire/_email_sent_extra.html
new file mode 100644
index 000000000..5fdcd3bfd
--- /dev/null
+++ b/templates/web/oxfordshire/_email_sent_extra.html
@@ -0,0 +1 @@
+[% INCLUDE '_response_time.html' problem=report %]
diff --git a/templates/web/oxfordshire/_response_time.html b/templates/web/oxfordshire/_response_time.html
new file mode 100644
index 000000000..c3cb5fdfa
--- /dev/null
+++ b/templates/web/oxfordshire/_response_time.html
@@ -0,0 +1,14 @@
+[% IF c.cobrand.problem_response_days(problem) == 'emergency' %]
+ <p>
+ Thank you for contacting Oxfordshire County Council [% problem.category %], unfortunately we are currently only available to respond to emergency situations which may have an impact on the health and safety of members of the public, these will be dealt with within a 24 hour period.<br />
+ Reported faults will continue to be registered on our management system and these will be tackled in coming months.
+ </p>
+[% ELSIF c.cobrand.problem_response_days(problem) > 0 %]
+ <p>
+ Problems in the
+ [% problem.category %]
+ category are generally responded to within
+ [% c.cobrand.problem_response_days(problem) %]
+ working days.
+ </p>
+[% END %]
diff --git a/templates/web/oxfordshire/report/_council_sent_info.html b/templates/web/oxfordshire/report/_council_sent_info.html
index 52b20a0af..5bc7949ff 100644
--- a/templates/web/oxfordshire/report/_council_sent_info.html
+++ b/templates/web/oxfordshire/report/_council_sent_info.html
@@ -10,20 +10,7 @@
</h3>
[% END %]
- [% IF c.cobrand.problem_response_days(problem) == 'emergency' %]
- <p>
- Thank you for contacting Oxfordshire County Council [% problem.category %], unfortunately we are currently only available to respond to emergency situations which may have an impact on the health and safety of members of the public, these will be dealt with within a 24 hour period.<br />
- Reported faults will continue to be registered on our management system and these will be tackled in coming months.
- </p>
- [% ELSIF c.cobrand.problem_response_days(problem) > 0 %]
- <p>
- Problems in the
- [% problem.category %]
- category are generally responded to within
- [% c.cobrand.problem_response_days(problem) %]
- working days.
- </p>
- [% END %]
+ [% INCLUDE '_response_time.html' %]
</div>
[% END %]
diff --git a/templates/web/oxfordshire/report/_inspect_extra_info.html b/templates/web/oxfordshire/report/_inspect_extra_info.html
new file mode 100644
index 000000000..6151d79ae
--- /dev/null
+++ b/templates/web/oxfordshire/report/_inspect_extra_info.html
@@ -0,0 +1,8 @@
+<p><small>
+RDI sent:
+[% IF problem.get_extra_metadata('rdi_processed') %]
+ [% problem.get_extra_metadata('rdi_processed') %]
+[% ELSE %]
+ <strong>not yet sent</strong>
+[% END %]
+</small></p>
diff --git a/templates/web/oxfordshire/tokens/_extras_confirm.html b/templates/web/oxfordshire/tokens/_extras_confirm.html
new file mode 100644
index 000000000..5fdcd3bfd
--- /dev/null
+++ b/templates/web/oxfordshire/tokens/_extras_confirm.html
@@ -0,0 +1 @@
+[% INCLUDE '_response_time.html' problem=report %]