aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--CHANGELOG.md3
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm28
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm21
-rw-r--r--t/app/controller/around.t16
-rw-r--r--t/app/controller/report_new.t45
-rw-r--r--templates/web/base/around/_error_multiple.html2
-rw-r--r--templates/web/base/header.html2
8 files changed, 105 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index e5a3f23c6..cf29316ee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,6 +47,7 @@ gh_fixmycommunity
*[Ff]ix[Mm]indelo*
*[Dd]ans[Mm]on[Qq]wat*
*[Cc]uido[Mm]i[Cc]iudad*
+*[Yy]o[Dd]enuncio*
# Commercial
/fixmystreet-commercial
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e73a903a..6552cd743 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -57,6 +57,9 @@
- 'Auto-response' flag on response templates is honoured for fetched
Open311 updates. #1924
- Store all successful send methods. #1933
+ - Development improvements:
+ - Add hook for pre-wrapper content.
+ - Include JSON representation of extra fields in category_extras output
- UK:
- Use SVG logo, inlined on front page. #1887
- Inline critical CSS on front page.
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index d1bf2d950..da17cbd56 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -60,18 +60,22 @@ sub index : Path : Args(0) {
# Check to see if the spot is covered by a area - if not show an error.
return unless $c->forward('check_location_is_acceptable', []);
- # If we have a partial - redirect to /report/new so that it can be
- # completed.
- if ($partial_report) {
- my $new_uri = $c->uri_for(
- '/report/new',
- {
- partial => $c->stash->{partial_token}->token,
- latitude => $c->stash->{latitude},
- longitude => $c->stash->{longitude},
- pc => $c->stash->{pc},
- }
- );
+ # Redirect to /report/new in two cases:
+ # - if we have a partial report, so that it can be completed.
+ # - if the cobrand doesn't show anything on /around (e.g. a private
+ # reporting site)
+ if ($partial_report || $c->cobrand->call_hook("skip_around_page")) {
+ my $params = {
+ latitude => $c->stash->{latitude},
+ longitude => $c->stash->{longitude},
+ pc => $c->stash->{pc}
+ };
+ if ($partial_report) {
+ $params->{partial} = $c->stash->{partial_token}->token;
+ } elsif ($c->get_param("category")) {
+ $params->{category} = $c->get_param("category");
+ }
+ my $new_uri = $c->uri_for('/report/new', $params);
return $c->res->redirect($new_uri);
}
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 951f6f2be..ca4fa2fd2 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -257,6 +257,7 @@ sub category_extras_ajax : Path('category_extras') : Args(0) {
};
my $category_extra = '';
+ my $category_extra_json = [];
my $generate;
if ( $c->stash->{category_extras}->{$category} && @{ $c->stash->{category_extras}->{$category} } >= 1 ) {
$c->stash->{category_extras} = { $category => $c->stash->{category_extras}->{$category} };
@@ -270,6 +271,7 @@ sub category_extras_ajax : Path('category_extras') : Args(0) {
}
if ($generate) {
$category_extra = $c->render_fragment('report/new/category_extras.html', $vars);
+ $category_extra_json = $c->forward('generate_category_extra_json');
}
my $councils_text = $c->render_fragment( 'report/new/councils_text.html', $vars);
@@ -279,6 +281,7 @@ sub category_extras_ajax : Path('category_extras') : Args(0) {
category_extra => $category_extra,
councils_text => $councils_text,
councils_text_private => $councils_text_private,
+ category_extra_json => $category_extra_json,
});
$c->res->content_type('application/json; charset=utf-8');
@@ -1457,6 +1460,24 @@ sub redirect_to_around : Private {
return $c->res->redirect($around_uri);
}
+sub generate_category_extra_json : Private {
+ my ( $self, $c ) = @_;
+
+ my $true = JSON->true;
+ my $false = JSON->false;
+
+ my @fields = map {
+ {
+ %$_,
+ required => $_->{required} eq "true" ? $true : $false,
+ variable => $_->{variable} eq "true" ? $true : $false,
+ order => int($_->{order}),
+ }
+ } @{ $c->stash->{category_extras}->{$c->stash->{category}} };
+
+ return \@fields;
+}
+
__PACKAGE__->meta->make_immutable;
1;
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index 8b4fc7825..d1254edb7 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -1,3 +1,5 @@
+use Test::MockModule;
+
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
@@ -174,4 +176,18 @@ subtest 'check category and status filtering works on /around?ajax' => sub {
is scalar @$pins, 1, 'correct number of fixed Vegetation reports';
};
+subtest 'check skip_around skips around page' => sub {
+ my $cobrand = Test::MockModule->new('FixMyStreet::Cobrand::Default');
+ $cobrand->mock('skip_around_page', sub { 1 });
+ $cobrand->mock('country', sub { 1 });
+
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $mech->get('/around?latitude=51.754926&longitude=-1.256179');
+ is $mech->res->code, 302, "around page is a redirect";
+ is $mech->uri->path, '/report/new', "and redirects to /report/new";
+ };
+};
+
done_testing();
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index f741ec796..e0fe205bd 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -1056,6 +1056,51 @@ subtest "check that a lat/lon off coast leads to /around" => sub {
};
+subtest "check we load a partial report correctly" => sub {
+ my $user = FixMyStreet::App->model('DB::User')->find_or_create(
+ {
+ email => 'test-partial@example.com'
+ }
+ );
+
+ my $report = FixMyStreet::App->model('DB::Problem')->create( {
+ name => '',
+ postcode => '',
+ category => 'Street lighting',
+ title => 'Testing',
+ detail => "Testing Detail",
+ anonymous => 0,
+ state => 'partial',
+ lang => 'en-gb',
+ service => '',
+ areas => '',
+ used_map => 1,
+ latitude => '51.754926',
+ longitude => '-1.256179',
+ user_id => $user->id,
+ } );
+
+ my $report_id = $report->id;
+
+ my $token = FixMyStreet::App->model("DB::Token")
+ ->create( { scope => 'partial', data => $report->id } );
+
+ my $token_code = $token->token;
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.uk/',
+ },
+ sub {
+ $mech->get("/L/$token_code");
+ is $mech->res->previous->code, 302, 'partial token page redirects';
+ is $mech->uri->path, "/report/new", "partial redirects to report page";
+ $mech->content_contains('Testing Detail');
+ };
+
+ $mech->delete_user($user);
+};
+
for my $test (
{
desc => 'user title not set if not bromley problem',
diff --git a/templates/web/base/around/_error_multiple.html b/templates/web/base/around/_error_multiple.html
index ca047f1d0..751d81173 100644
--- a/templates/web/base/around/_error_multiple.html
+++ b/templates/web/base/around/_error_multiple.html
@@ -6,7 +6,7 @@
<p>[% loc('We found more than one match for that location.') %]</p>
<ul class="pc_alternatives">
[% FOREACH match IN possible_location_matches %]
- <li><a href="/around?latitude=[% match.latitude | uri %];longitude=[% match.longitude | uri %]">[% match.address | html %]</a></li>
+ <li><a href="/around?latitude=[% match.latitude | uri %];longitude=[% match.longitude | uri %][% IF c.req.params.category %];category=[% c.req.params.category | uri %][% END %]">[% match.address | html %]</a></li>
[% END %]
</ul>
<p>[% loc('We show up to ten matches, please try a different search if yours is not here.') %]</p>
diff --git a/templates/web/base/header.html b/templates/web/base/header.html
index faba02519..3cc166a32 100644
--- a/templates/web/base/header.html
+++ b/templates/web/base/header.html
@@ -27,6 +27,8 @@
[% TRY %][% PROCESS 'set_body_class.html' %][% CATCH file %][% END %]
<body class="[% bodyclass | html IF bodyclass %]">
+ [% TRY %][% PROCESS 'before_wrapper.html' %][% CATCH file %][% END %]
+
<div class="wrapper">
<div class="table-cell">
[% INCLUDE 'header_site.html' %]