aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm18
-rw-r--r--t/app/controller/around.t10
-rw-r--r--t/app/controller/report_new.t2
-rw-r--r--t/app/controller/report_new_text.t2
-rw-r--r--t/cobrand/oxfordshire.t8
-rw-r--r--web/js/map-OpenLayers.js8
-rw-r--r--web/js/map-google.js3
7 files changed, 28 insertions, 23 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 6af780c35..33b1dd740 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -33,17 +33,21 @@ If no search redirect back to the homepage.
sub index : Path : Args(0) {
my ( $self, $c ) = @_;
- # handle old coord systems
- $c->forward('redirect_en_or_xy_to_latlon');
-
- # Check if we have a partial report
- my $partial_report = $c->forward('load_partial');
+ if ($c->get_param('ajax')) {
+ $c->detach('ajax');
+ }
# Check if the user is searching for a report by ID
if ( $c->get_param('pc') && $c->get_param('pc') =~ $c->cobrand->lookup_by_ref_regex ) {
$c->go('lookup_by_ref', [ $1 ]);
}
+ # handle old coord systems
+ $c->forward('redirect_en_or_xy_to_latlon');
+
+ # Check if we have a partial report
+ my $partial_report = $c->forward('load_partial');
+
# Try to create a location for whatever we have
my $ret = $c->forward('/location/determine_location_from_coords')
|| $c->forward('/location/determine_location_from_pc');
@@ -275,7 +279,7 @@ sub map_features : Private {
$c->stash->{distance} = $distance;
}
-=head2 /ajax
+=head2 ajax
Handle the ajax calls that the map makes when it is dragged. The info returned
is used to update the pins on the map and the text descriptions on the side of
@@ -283,7 +287,7 @@ the map.
=cut
-sub ajax : Path('/ajax') {
+sub ajax : Private {
my ( $self, $c ) = @_;
my $bbox = $c->get_param('bbox');
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index cdaeaf363..8b4fc7825 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -135,7 +135,7 @@ subtest 'check non public reports are not displayed on around page' => sub {
};
-subtest 'check category and status filtering works on /ajax' => sub {
+subtest 'check category and status filtering works on /around?ajax' => sub {
my $categories = [ 'Pothole', 'Vegetation', 'Flytipping' ];
my $params = {
postcode => 'OX1 1ND',
@@ -157,19 +157,19 @@ subtest 'check category and status filtering works on /ajax' => sub {
}
}
- my $json = $mech->get_ok_json( '/ajax?bbox=' . $bbox );
+ my $json = $mech->get_ok_json( '/around?ajax=1&bbox=' . $bbox );
my $pins = $json->{pins};
is scalar @$pins, 6, 'correct number of reports when no filters';
- $json = $mech->get_ok_json( '/ajax?filter_category=Pothole&bbox=' . $bbox );
+ $json = $mech->get_ok_json( '/around?ajax=1&filter_category=Pothole&bbox=' . $bbox );
$pins = $json->{pins};
is scalar @$pins, 2, 'correct number of Pothole reports';
- $json = $mech->get_ok_json( '/ajax?status=open&bbox=' . $bbox );
+ $json = $mech->get_ok_json( '/around?ajax=1&status=open&bbox=' . $bbox );
$pins = $json->{pins};
is scalar @$pins, 3, 'correct number of open reports';
- $json = $mech->get_ok_json( '/ajax?status=fixed&filter_category=Vegetation&bbox=' . $bbox );
+ $json = $mech->get_ok_json( '/around?ajax=1&status=fixed&filter_category=Vegetation&bbox=' . $bbox );
$pins = $json->{pins};
is scalar @$pins, 1, 'correct number of fixed Vegetation reports';
};
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index efe392eab..f741ec796 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -893,7 +893,7 @@ foreach my $test (
# Test that AJAX pages return the right data
$mech->get_ok(
- '/ajax?bbox=' . ($report->longitude - 0.01) . ',' . ($report->latitude - 0.01)
+ '/around?ajax=1&bbox=' . ($report->longitude - 0.01) . ',' . ($report->latitude - 0.01)
. ',' . ($report->longitude + 0.01) . ',' . ($report->latitude + 0.01)
);
$mech->content_contains( "Test Report at caf\xc3\xa9" );
diff --git a/t/app/controller/report_new_text.t b/t/app/controller/report_new_text.t
index 94f350eba..734b9dbb4 100644
--- a/t/app/controller/report_new_text.t
+++ b/t/app/controller/report_new_text.t
@@ -362,7 +362,7 @@ subtest "test report creation for a user who is logged in" => sub {
$mech->logged_in_ok;
$mech->get_ok(
- '/ajax?bbox=' . ($report->longitude - 0.01) . ',' . ($report->latitude - 0.01)
+ '/around?ajax=1&bbox=' . ($report->longitude - 0.01) . ',' . ($report->latitude - 0.01)
. ',' . ($report->longitude + 0.01) . ',' . ($report->latitude + 0.01)
);
$mech->content_contains( "Test Report at caf\xc3\xa9" );
diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t
index dcf8b25c9..ee30e7e0b 100644
--- a/t/cobrand/oxfordshire.t
+++ b/t/cobrand/oxfordshire.t
@@ -7,7 +7,7 @@ my $mech = FixMyStreet::TestMech->new;
my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council');
-subtest 'check /ajax defaults to open reports only' => sub {
+subtest 'check /around?ajax defaults to open reports only' => sub {
my $categories = [ 'Bridges', 'Fences', 'Manhole' ];
my $params = {
postcode => 'OX28 4DS',
@@ -33,15 +33,15 @@ subtest 'check /ajax defaults to open reports only' => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ { 'oxfordshire' => '.' } ],
}, sub {
- my $json = $mech->get_ok_json( '/ajax?status=all&bbox=' . $bbox );
+ my $json = $mech->get_ok_json( '/around?ajax=1&status=all&bbox=' . $bbox );
my $pins = $json->{pins};
is scalar @$pins, 6, 'correct number of reports created';
- $json = $mech->get_ok_json( '/ajax?bbox=' . $bbox );
+ $json = $mech->get_ok_json( '/around?ajax=1&bbox=' . $bbox );
$pins = $json->{pins};
is scalar @$pins, 3, 'correct number of reports returned with no filters';
- $json = $mech->get_ok_json( '/ajax?filter_category=Fences&bbox=' . $bbox );
+ $json = $mech->get_ok_json( '/around?ajax=1&filter_category=Fences&bbox=' . $bbox );
$pins = $json->{pins};
is scalar @$pins, 1, 'only one Fences report by default';
}
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 8cc2e8e2c..e9a546786 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -483,7 +483,7 @@ var fixmystreet = fixmystreet || {};
fixmystreet.bbox_strategy = fixmystreet.bbox_strategy || new OpenLayers.Strategy.FixMyStreet();
pin_layer_options.strategies = [ fixmystreet.bbox_strategy ];
pin_layer_options.protocol = new OpenLayers.Protocol.FixMyStreet({
- url: '/ajax',
+ url: fixmystreet.original.href.split('?')[0] + '?ajax=1',
params: fixmystreet.all_pins ? { all_pins: 1 } : { },
format: new OpenLayers.Format.FixMyStreet()
});
@@ -494,7 +494,7 @@ var fixmystreet = fixmystreet || {};
if (fixmystreet.page == 'my') {
pin_layer_options.strategies = [ new OpenLayers.Strategy.FixMyStreetFixed() ];
}
- if (fixmystreet.page == 'reports' || fixmystreet.page == 'my') {
+ if (fixmystreet.page == 'around' || fixmystreet.page == 'reports' || fixmystreet.page == 'my') {
pin_layer_options.protocol = new OpenLayers.Protocol.FixMyStreet({
url: fixmystreet.original.href.split('?')[0] + '?ajax=1',
format: new OpenLayers.Format.FixMyStreet()
@@ -821,11 +821,11 @@ OpenLayers.Strategy.FixMyStreetFixed = OpenLayers.Class(OpenLayers.Strategy.Fixe
});
/* Pan data request handler */
-// This class is used to get a JSON object from /ajax that contains
+// This class is used to get a JSON object from /around?ajax that contains
// pins for the map and HTML for the sidebar. It does a fetch whenever the map
// is dragged (modulo a buffer extending outside the viewport).
// This subclass is required so we can pass the 'filter_category' and 'status' query
-// params to /ajax if the user has filtered the map.
+// params to /around?ajax if the user has filtered the map.
OpenLayers.Protocol.FixMyStreet = OpenLayers.Class(OpenLayers.Protocol.HTTP, {
read: function(options) {
// Show the loading indicator over the map
diff --git a/web/js/map-google.js b/web/js/map-google.js
index 596e4f8ee..6be2a0232 100644
--- a/web/js/map-google.js
+++ b/web/js/map-google.js
@@ -127,12 +127,13 @@ fixmystreet.maps = {};
b_ne = b.getNorthEast(),
bbox = b_sw.lng() + ',' + b_sw.lat() + ',' + b_ne.lng() + ',' + b_ne.lat(),
params = {
+ ajax: 1,
bbox: bbox
};
if (fixmystreet.all_pins) {
params.all_pins = 1;
}
- $.getJSON('/ajax', params, read_pin_json);
+ $.getJSON('/around', params, read_pin_json);
}
function map_initialize() {