diff options
author | Dave Arter <davea@mysociety.org> | 2016-11-16 11:35:53 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2016-12-13 16:14:55 +0000 |
commit | ca578e7c4150fab167f1a4ab422e23d0b1f09789 (patch) | |
tree | a098a2a173d41222cc82e05089e5772afcd6c9fa /perllib/FixMyStreet/App/Controller/Report.pm | |
parent | 96bddb2ebda556eff5a79bbd31b936fbf6f1ef6b (diff) |
Use nearby problems for duplicate suggestions instead of bounding box of map
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index cd42e89a4..f9eaf583c 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -300,6 +300,7 @@ sub action_router : Path('') : Args(2) { my ( $self, $c, $id, $action ) = @_; $c->go( 'map', [ $id ] ) if $action eq 'map'; + $c->go( 'nearby_json', [ $id ] ) if $action eq 'nearby.json'; $c->detach( '/page_error_404_not_found', [] ); } @@ -420,6 +421,31 @@ sub map : Private { } +sub nearby_json : Private { + my ( $self, $c, $id ) = @_; + + $c->forward( 'load_problem_or_display_error', [ $id ] ); + my $p = $c->stash->{problem}; + my $dist = 1000; + + my $nearby = $c->model('DB::Nearby')->nearby( + $c, $dist, [ $p->id ], 5, $p->latitude, $p->longitude, undef, [ $p->category ], undef + ); + # my @reports = map { $_->problem : $_; } @$nearby; + + my $on_map_list_html = $c->render_fragment( + 'around/on_map_list_items.html', + { on_map => [], around_map => $nearby } + ); + + my $json = {}; + $json->{current} = $on_map_list_html if $on_map_list_html; + my $body = encode_json($json); + $c->res->content_type('application/json; charset=utf-8'); + $c->res->body($body); +} + + =head2 check_has_permission_to Ensure the currently logged-in user has any of the provided permissions applied |