aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2018-09-04 15:56:03 +0100
committerStruan Donald <struan@exo.org.uk>2018-09-13 11:00:53 +0100
commit90a2c224d2f4112609c140777ac065b60076f15d (patch)
tree48e11410ff00ee99d0d86512d3abe7ac00cd04d9
parentf2a5d899308634fb06605a1d8035e19eadb8932a (diff)
allow web based use of report import
if a web parameter is passed to /import then display the email confirmation sent page rather than a SUCCESS message. Enables this page to be used for creating partial reports from a web page. For mysociety/collideoscope#17
-rw-r--r--CHANGELOG.md2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm6
-rw-r--r--t/app/controller/report_import.t17
-rw-r--r--templates/web/base/report/new/report_import.html1
4 files changed, 25 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 508c4b426..b34fb900e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
## Releases
* Unreleased
+ - Front end improvements:
+ - Import end point can optionally return a web page #2225
- Bugfixes:
- Fix display of area/pins on body page when using Bing or TonerLite map.
- Do not scan through all problems to show /_dev pages.
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 869ed9461..dd4fef388 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -418,6 +418,12 @@ sub report_import : Path('/import') {
$c->send_email( 'partial.txt', { to => $report->user->email, } );
+ if ( $c->get_param('web') ) {
+ $c->res->content_type('text/html; charset=utf-8');
+ $c->stash->{template} = 'email_sent.html';
+ $c->stash->{email_type} = 'problem';
+ return 1;
+ }
$c->res->body('SUCCESS');
return 1;
}
diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t
index e4a202db7..223979d1b 100644
--- a/t/app/controller/report_import.t
+++ b/t/app/controller/report_import.t
@@ -89,6 +89,15 @@ subtest "Test creating bad partial entries" => sub {
};
+for my $test (
+ {
+ desc => 'Submit a correct entry',
+ },
+ {
+ desc => 'Submit a correct web entry',
+ web => 1,
+ }
+) {
subtest "Submit a correct entry" => sub {
$mech->get_ok('/import');
@@ -101,13 +110,18 @@ subtest "Submit a correct entry" => sub {
subject => 'Test report',
detail => 'This is a test report',
photo => $sample_file,
+ web => $test->{web},
}
},
"fill in form"
);
is_deeply( $mech->import_errors, [], "got no errors" );
- is $mech->content, 'SUCCESS', "Got success response";
+ if ( $test->{web} ) {
+ $mech->content_contains('Nearly done! Now check', "Got email confirmation page");
+ } else {
+ is $mech->content, 'SUCCESS', "Got success response";
+ }
# check that we have received the email
my $token_url = $mech->get_link_from_email;
@@ -223,6 +237,7 @@ subtest "Submit a correct entry" => sub {
$mech->delete_user($user);
};
+}
subtest "Submit a correct entry (with location)" => sub {
diff --git a/templates/web/base/report/new/report_import.html b/templates/web/base/report/new/report_import.html
index 7aa105afe..f2ead081b 100644
--- a/templates/web/base/report/new/report_import.html
+++ b/templates/web/base/report/new/report_import.html
@@ -85,6 +85,7 @@ line each starting with <samp>ERROR:</samp>.
</dd>
</dl>
+<input type="hidden" name="web" value="0">
<input type="submit" />
</form>