aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2019-10-14 11:33:05 +0100
committerDave Arter <davea@mysociety.org>2019-12-09 12:48:12 +0000
commit4c9041d446da2772d7ee4af7ba11fd58c8c3d1d1 (patch)
tree0f1020e9d01383af476811025329910989ced82d
parente9fb01d6be50fcec63812ad9168bc92ce0f99de9 (diff)
[TfL] Reference number on site, emails and lookup.
Front page lookup with FMS<id>.
-rw-r--r--perllib/FixMyStreet/Cobrand/TfL.pm14
-rw-r--r--t/cobrand/tfl.t110
-rw-r--r--templates/email/tfl/_council_reference.html3
-rw-r--r--templates/email/tfl/_council_reference.txt2
-rw-r--r--templates/email/tfl/_council_reference_alert_update.html1
-rw-r--r--templates/email/tfl/_council_reference_alert_update.txt1
-rw-r--r--templates/email/tfl/submit.html68
-rw-r--r--templates/email/tfl/submit.txt43
-rw-r--r--templates/web/tfl/report/_council_sent_info.html17
-rw-r--r--templates/web/tfl/tokens/confirm_problem.html18
10 files changed, 277 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm
index 6dec98b26..78711d345 100644
--- a/perllib/FixMyStreet/Cobrand/TfL.pm
+++ b/perllib/FixMyStreet/Cobrand/TfL.pm
@@ -61,4 +61,18 @@ sub categories_restriction {
return $rs->search( { 'body.name' => 'TfL' } );
}
+sub lookup_by_ref_regex {
+ return qr/^\s*((?:FMS\s*)?\d+)\s*$/i;
+}
+
+sub lookup_by_ref {
+ my ($self, $ref) = @_;
+
+ if ( $ref =~ s/^\s*FMS\s*//i ) {
+ return { 'id' => $ref };
+ }
+
+ return 0;
+}
+
1;
diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t
new file mode 100644
index 000000000..3e1e851bf
--- /dev/null
+++ b/t/cobrand/tfl.t
@@ -0,0 +1,110 @@
+use FixMyStreet::TestMech;
+use FixMyStreet::App;
+use FixMyStreet::Script::Reports;
+
+# disable info logs for this test run
+FixMyStreet::App->log->disable('info');
+END { FixMyStreet::App->log->enable('info'); }
+
+my $mech = FixMyStreet::TestMech->new;
+
+my $body = $mech->create_body_ok(2482, 'TfL');
+my $staffuser = $mech->create_user_ok('counciluser@example.com', name => 'Council User', from_body => $body);
+$staffuser->user_body_permissions->create({
+ body => $body,
+ permission_type => 'contribute_as_body',
+});
+$staffuser->user_body_permissions->create({
+ body => $body,
+ permission_type => 'default_to_body',
+});
+my $user = $mech->create_user_ok('londonresident@example.com');
+
+
+my $contact1 = $mech->create_contact_ok(
+ body_id => $body->id,
+ category => 'Bus stops',
+ email => 'busstops@example.com',
+);
+my $contact2 = $mech->create_contact_ok(
+ body_id => $body->id,
+ category => 'Traffic lights',
+ email => 'trafficlights@example.com',
+);
+
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'tfl',
+ MAPIT_URL => 'http://mapit.uk/'
+}, sub {
+
+subtest "test report creation and reference number" => sub {
+ $mech->log_in_ok( $user->email );
+ $mech->get_ok('/around');
+ $mech->submit_form_ok( { with_fields => { pc => 'BR1 3UH', } }, "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 1',
+ detail => 'Test report details.',
+ name => 'Joe Bloggs',
+ may_show_name => '1',
+ category => 'Bus stops',
+ }
+ },
+ "submit good details"
+ );
+
+ my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'});
+ ok $report, "Found the report";
+
+ $mech->content_contains('Your issue is on its way to Transport for London');
+ $mech->content_contains('Your reference for this report is FMS' . $report->id) or diag $mech->content;
+
+ is_deeply $mech->page_errors, [], "check there were no errors";
+
+ is $report->state, 'confirmed', "report confirmed";
+
+ is $report->bodies_str, $body->id;
+ is $report->name, 'Joe Bloggs';
+
+ $mech->log_out_ok;
+};
+
+subtest "reference number included in email" => sub {
+ my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'});
+ my $id = $report->id;
+
+ $mech->clear_emails_ok;
+ FixMyStreet::Script::Reports::send();
+ my @email = $mech->get_email;
+ is $email[0]->header('To'), 'TfL <busstops@example.com>';
+ like $mech->get_text_body_from_email($email[0]), qr/Report reference: FMS$id/, "FMS-prefixed ID in TfL email";
+
+ $mech->get_ok( '/report/' . $report->id );
+ $mech->content_contains('FMS' . $report->id) or diag $mech->content;
+};
+
+subtest 'check lookup by reference' => sub {
+ my $id = FixMyStreet::DB->resultset("Problem")->first->id;
+
+ $mech->get_ok('/');
+ $mech->submit_form_ok( { with_fields => { pc => 'FMS12345' } }, 'bad ref');
+ $mech->content_contains('Searching found no reports');
+
+ $mech->get_ok('/');
+ $mech->submit_form_ok( { with_fields => { pc => "FMS$id" } }, 'good FMS-prefixed ref');
+ is $mech->uri->path, "/report/$id", "redirected to report page when using FMS-prefixed ref";
+
+ $mech->get_ok('/');
+ $mech->submit_form_ok( { with_fields => { pc => "fms $id" } }, 'good FMS-prefixed with a space ref');
+ is $mech->uri->path, "/report/$id", "redirected to report page when using FMS-prefixed ref";
+
+ $mech->get_ok('/');
+ $mech->submit_form_ok( { with_fields => { pc => "$id" } }, 'good ref');
+ is $mech->uri->path, "/report/$id", "redirected to report page when using non-prefixed ref";
+};
+
+};
+
+done_testing();
diff --git a/templates/email/tfl/_council_reference.html b/templates/email/tfl/_council_reference.html
new file mode 100644
index 000000000..7013a1f9f
--- /dev/null
+++ b/templates/email/tfl/_council_reference.html
@@ -0,0 +1,3 @@
+<p style="[% p_style %]">The report's reference number is <strong>FMS[% problem.id %]</strong>.
+ Please quote this if you need to contact Transport for London about this report.</p>
+
diff --git a/templates/email/tfl/_council_reference.txt b/templates/email/tfl/_council_reference.txt
new file mode 100644
index 000000000..be82dc8d6
--- /dev/null
+++ b/templates/email/tfl/_council_reference.txt
@@ -0,0 +1,2 @@
+The report's reference number is FMS[% problem.id %]. Please quote this if
+you need to contact Transport for London about this report.
diff --git a/templates/email/tfl/_council_reference_alert_update.html b/templates/email/tfl/_council_reference_alert_update.html
new file mode 100644
index 000000000..3e7a29dbf
--- /dev/null
+++ b/templates/email/tfl/_council_reference_alert_update.html
@@ -0,0 +1 @@
+[% INCLUDE '_council-reference.html' %] \ No newline at end of file
diff --git a/templates/email/tfl/_council_reference_alert_update.txt b/templates/email/tfl/_council_reference_alert_update.txt
new file mode 100644
index 000000000..2cc57a339
--- /dev/null
+++ b/templates/email/tfl/_council_reference_alert_update.txt
@@ -0,0 +1 @@
+[% INCLUDE '_council-reference.txt' %] \ No newline at end of file
diff --git a/templates/email/tfl/submit.html b/templates/email/tfl/submit.html
new file mode 100644
index 000000000..96186a032
--- /dev/null
+++ b/templates/email/tfl/submit.html
@@ -0,0 +1,68 @@
+[%
+
+PROCESS '_email_settings.html';
+
+email_summary = "A new problem in your area has been reported by a " _ site_name _ " user.";
+email_footer = "";
+email_columns = 2;
+
+INCLUDE '_email_top.html';
+
+%]
+
+<th style="[% td_style %][% primary_column_style %]" id="primary_column">
+ [% start_padded_box %]
+ <h1 style="[% h1_style %]">New problem in your&nbsp;area</h1>
+ <p style="[% p_style %]">[% multiple %]A user of [% site_name %] has submitted the following report
+of a local problem that they believe might require your attention.</p>
+
+ <p style="margin: 20px auto; text-align: center">
+ <a style="[% button_style %]" href="[% url %]">Show full report</a>
+ </p>
+ <h2 style="[% h2_style %] margin: 30px 0 10px 0">Reported by:</h2>
+ <table [% table_reset %]>
+ <tr>
+ <th style="[% contact_th_style %]">Name</th>
+ <td style="[% contact_td_style %]">[% report.name | html %]</td>
+ </tr>
+ <tr>
+ <th style="[% contact_th_style %]">Email</th>
+ <td style="[% contact_td_style %]">
+ [%~ IF report.user.email ~%]
+ <a href="mailto:[% report.user.email | html %]">[% report.user.email | html %]</a>
+ [%~ ELSE ~%]
+ <strong>No email address provided, only phone number</strong>
+ [%~ END ~%]
+ </td>
+ </tr>
+ [%~ IF report.user.phone %]
+ <tr>
+ <th style="[% contact_th_style %]">Phone</th>
+ <td style="[% contact_td_style %]"><a href="tel:[% report.user.phone | html %]">[% report.user.phone | html %]</a></td>
+ </tr>
+ [%~ END %]
+ </table>
+ <p style="[% p_style %] margin-top: 0.5em;">Replies to this message will go directly to [% report.name | html %], the user who reported the problem.</p>
+ [% end_padded_box %]
+</th>
+[% WRAPPER '_email_sidebar.html' object = report %]
+ <h2 style="[% h2_style %]">[% report.title | html %]</h2>
+ <p style="[% secondary_p_style %]"><strong>Report reference:</strong> FMS[% report.id %]</p>
+ <p style="[% secondary_p_style %]"><strong>Category:</strong> [% report.category | html %]</p>
+ <p style="[% secondary_p_style %]">[% report.detail | html %]</p>
+ [%~ IF additional_information %]
+ <p style="[% secondary_p_style %]">[% additional_information %]</p>
+ [%~ END %]
+ <p style="[% secondary_p_style %]">
+ <strong>Location:</strong>
+ <br>Easting/Northing
+ [%~ " (IE)" IF coordsyst == "I" ~%]
+ : [% easting %]/[% northing %]
+ (<a href="[% osm_url %]" title="View OpenStreetMap of this location">
+ [%~ report.latitude %], [% report.longitude ~%]
+ </a>)
+ [% IF closest_address %]<br>[% closest_address | trim | replace("\n\n", "<br>") %][% END %]
+ </p>
+[% END %]
+
+[% INCLUDE '_email_bottom.html' %]
diff --git a/templates/email/tfl/submit.txt b/templates/email/tfl/submit.txt
new file mode 100644
index 000000000..61b5edee8
--- /dev/null
+++ b/templates/email/tfl/submit.txt
@@ -0,0 +1,43 @@
+Subject: Problem Report: [% report.title %]
+
+[% multiple %]A user of
+[% site_name %] has submitted the following report
+of a local problem that they believe might require your attention.
+
+[% fuzzy %], or to provide an update on the problem,
+please visit the following link:
+
+ [% url %]
+
+[% has_photo %]----------
+
+Name: [% report.name %]
+
+Email: [% report.user.email OR 'None provided' %]
+
+Phone: [% report.user.phone OR 'None provided' %]
+
+Report reference: FMS[% report.id %]
+
+Category: [% report.category %]
+
+Subject: [% report.title %]
+
+Details: [% report.detail %]
+
+[% additional_information %]
+
+Easting/Northing
+[%- " (IE)" IF coordsyst == "I" -%]
+: [% easting %]/[% northing %]
+
+Latitude: [% report.latitude %]
+
+Longitude: [% report.longitude %]
+
+View OpenStreetMap of this location: [% osm_url %]
+
+[% closest_address %]----------
+
+Replies to this email will go to the user who submitted the problem.
+
diff --git a/templates/web/tfl/report/_council_sent_info.html b/templates/web/tfl/report/_council_sent_info.html
new file mode 100644
index 000000000..ef6cca079
--- /dev/null
+++ b/templates/web/tfl/report/_council_sent_info.html
@@ -0,0 +1,17 @@
+[% SET duration_clause = problem.duration_string(c) %]
+[% IF duration_clause || problem.whensent %]
+ <p class="council_sent_info">
+ [%- IF problem.whensent %]
+ [%- IF duration_clause %]
+ [%- external_ref_clause = tprintf(loc('TfL ref:&nbsp;FMS%s'), problem.id) %]
+ [%- ELSE %]
+ [%- external_ref_clause = tprintf(loc('%s ref:&nbsp;%s'), problem.external_body, problem.id) %]
+ [%- END %]
+ [%- END -%]
+ [% duration_clause %]
+ [%- IF external_ref_clause %]
+ [%- IF duration_clause %]. [% END %]
+ <strong>[% external_ref_clause %].</strong>
+ [%- END %]
+ </p>
+[% END %]
diff --git a/templates/web/tfl/tokens/confirm_problem.html b/templates/web/tfl/tokens/confirm_problem.html
new file mode 100644
index 000000000..be02fc4d2
--- /dev/null
+++ b/templates/web/tfl/tokens/confirm_problem.html
@@ -0,0 +1,18 @@
+[% INCLUDE 'header.html', bodyclass = 'fullwidthpage', title = loc('Confirmation') %]
+
+<div class="confirmation-header">
+
+ <h1><a href="[% c.cobrand.relative_url_for_report( report ) %][% report.url %]">[% report.title %]</a></h1>
+
+ <h2>Your issue is on its way to Transport for London.</h2>
+ <p>Your reference for this report is FMS[% report.id %], please quote it in any enquiries.</p>
+
+ <p class="confirmation-again">
+ <a href="/report/new?latitude=[% report.latitude %]&amp;longitude=[% report.longitude %]" class="btn btn-primary">
+ [% loc('Report another problem here') %]
+ </a>
+ </p>
+
+</div>
+
+[% INCLUDE 'footer.html' %]