diff options
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 28 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 21 |
2 files changed, 37 insertions, 12 deletions
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; |