diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-02-13 16:13:38 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-02-16 18:02:19 +0000 |
commit | 24bd9e82e5470be7269e06def8452015608bd00a (patch) | |
tree | a1c2680e849ea6cfbef86fa456743bdcd2c438bb | |
parent | ce311876233b03631358f397619f87534946aa39 (diff) |
Prefill first question from questionnaire email.
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Questionnaire.pm | 3 | ||||
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 4 | ||||
-rw-r--r-- | t/app/controller/questionnaire.t | 4 | ||||
-rw-r--r-- | templates/email/default/questionnaire.html | 6 | ||||
-rw-r--r-- | templates/email/fixamingata/questionnaire.html | 6 |
6 files changed, 14 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b9b90878..c7db840e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ * Unreleased - Front end improvements: - - Include don't know link in questionnaire email. #1939 + - Include don't know link in questionnaire email, and + prefill form question. #1939 * v2.3.1 (12th February 2018) - Front end improvements: diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm index 1b338732b..1ff57e920 100755 --- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm +++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm @@ -46,6 +46,7 @@ sub check_questionnaire : Private { $c->stash->{problem} = $problem; $c->stash->{answered_ever_reported} = $problem->user->answered_ever_reported; + $c->stash->{been_fixed} = $c->get_param('been_fixed') || ''; } =head2 submit @@ -223,7 +224,7 @@ sub submit_standard : Private { sub process_questionnaire : Private { my ( $self, $c ) = @_; - map { $c->stash->{$_} = $c->get_param($_) || '' } qw(been_fixed reported another update); + map { $c->stash->{$_} = $c->get_param($_) || '' } qw(reported another update); $c->stash->{update} = Utils::cleanup_text($c->stash->{update}, { allow_multiline => 1 }); diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index ac2ac023d..c5b72a7cf 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -247,7 +247,7 @@ sub get_text_body_from_email { } sub get_link_from_email { - my ($mech, $email, $multiple) = @_; + my ($mech, $email, $multiple, $mismatch) = @_; unless ($email) { $email = $mech->get_email; $mech->clear_emails_ok; @@ -261,7 +261,7 @@ sub get_link_from_email { if (@links) { # Must be an HTML part now, first two links are in header my @html_links = $part->body =~ m{https?://[^"]+}g; - is $links[0], $html_links[2], 'HTML link matches text link'; + is $links[0], $html_links[2], 'HTML link matches text link' unless $mismatch; } else { @links = $part->body =~ m{https?://\S+}g; ok @links, "Found links in email '@links'"; diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t index c6d112df7..0dcfdaba6 100644 --- a/t/app/controller/questionnaire.t +++ b/t/app/controller/questionnaire.t @@ -52,7 +52,7 @@ like $plain->body, qr/fill in our short questionnaire/i, "got questionnaire emai like $plain->body_str, qr/Testing \x{2013} Detail/, 'email contains encoded character'; is $plain->header('Content-Type'), 'text/plain; charset="utf-8"', 'in the right character set'; -my $url = $mech->get_link_from_email($email); +my $url = $mech->get_link_from_email($email, 0, 1); my ($token) = $url =~ m{/Q/(\S+)}; ok $token, "extracted questionnaire token '$token'"; $mech->clear_emails_ok; @@ -399,7 +399,7 @@ FixMyStreet::override_config { $mech->clear_emails_ok; $body =~ s/\s+/ /g; like $body, qr/fill in our short questionnaire/i, "got questionnaire email"; - my $url = $mech->get_link_from_email($email); + my $url = $mech->get_link_from_email($email, 0, 1); ($token) = $url =~ m{/Q/(\S+)}; ok $token, "extracted questionnaire token '$token'"; diff --git a/templates/email/default/questionnaire.html b/templates/email/default/questionnaire.html index 854cac066..eaa570ae0 100644 --- a/templates/email/default/questionnaire.html +++ b/templates/email/default/questionnaire.html @@ -16,11 +16,11 @@ INCLUDE '_email_top.html'; <p style="[% p_style %]">[% created %] ago, you reported a problem using [% site_name %].</p> <p style="[% p_style %]">Help us keep [% site_name %] up to date by letting us know whether the problem has been fixed yet:</p> <p style="margin: 20px auto; text-align: center"> - <a style="[% fixed_button_style %]" href="[% url %]">Fixed</a> - <a style="[% notfixed_button_style %]" href="[% url %]">Not fixed</a> + <a style="[% fixed_button_style %]" href="[% url %]?been_fixed=Yes">Fixed</a> + <a style="[% notfixed_button_style %]" href="[% url %]?been_fixed=No">Not fixed</a> </p> <p style="margin: 20px auto; text-align: center"> - <a style="[% dontknow_button_style %]" href="[% url %]">Don’t know</a> + <a style="[% dontknow_button_style %]" href="[% url %]?been_fixed=Unknown">Don’t know</a> </p> <p style="[% p_style %]">Thank you! Your feedback is really valuable.</p> [% end_padded_box %] diff --git a/templates/email/fixamingata/questionnaire.html b/templates/email/fixamingata/questionnaire.html index 0d3fc90c4..d66c50535 100644 --- a/templates/email/fixamingata/questionnaire.html +++ b/templates/email/fixamingata/questionnaire.html @@ -16,11 +16,11 @@ INCLUDE '_email_top.html'; <p style="[% p_style %]">[% created %] sedan lämnade du en rapport på FixaMinGata.</p> <p style="[% p_style %]">För att hålla alla rapporter uppdaterade skulle vi uppskatta om du kunde informera oss om huruvida problemet har blivit fixat än:</p> <p style="margin: 20px auto; text-align: center"> - <a style="[% fixed_button_style %]" href="[% url %]">Fixat</a> - <a style="[% notfixed_button_style %]" href="[% url %]">Ej fixat</a> + <a style="[% fixed_button_style %]" href="[% url %]?been_fixed=Yes">Fixat</a> + <a style="[% notfixed_button_style %]" href="[% url %]?been_fixed=No">Ej fixat</a> </p> <p style="margin: 20px auto; text-align: center"> - <a style="[% dontknow_button_style %]" href="[% url %]">Vet ej</a> + <a style="[% dontknow_button_style %]" href="[% url %]?been_fixed=Unknown">Vet ej</a> </p> <p style="[% p_style %]">Tack! Din feedback är värdefull.</p> [% end_padded_box %] |