aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm21
-rw-r--r--t/app/controller/report_import.t69
-rwxr-xr-xtemplates/web/default/reports/council.html30
-rw-r--r--web/js/map-OpenLayers.js3
5 files changed, 119 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index a9ec2f935..01cad9bba 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -220,6 +220,8 @@ sub report_import : Path('/import') {
anonymous => 0,
category => '',
areas => '',
+ cobrand => $c->cobrand->moniker,
+ lang => $c->stash->{lang_code},
}
);
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index cfabb4dfd..61d7d5cb1 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -99,6 +99,7 @@ sub ward : Path : Args(2) {
$c->forward( 'ward_check', [ $ward ] )
if $ward;
$c->forward( 'load_parent' );
+ $c->forward( 'check_canonical_url', [ $council ] );
$c->forward( 'load_and_group_problems' );
$c->forward( 'sort_problems' );
@@ -235,7 +236,7 @@ sub council_check : Private {
return;
} else {
foreach (keys %$areas) {
- if ($areas->{$_}->{name} eq $q_council || $areas->{$_}->{name} =~ /^\Q$q_council\E (Borough|City|District|County) Council$/) {
+ if (lc($areas->{$_}->{name}) eq lc($q_council) || $areas->{$_}->{name} =~ /^\Q$q_council\E (Borough|City|District|County) Council$/i) {
$c->stash->{council} = $areas->{$_};
return;
}
@@ -290,6 +291,22 @@ sub load_parent : Private {
}
}
+=head2 check_canonical_url
+
+Given an already found (case-insensitively) council, check what URL
+we are at and redirect accordingly if different.
+
+=cut
+
+sub check_canonical_url : Private {
+ my ( $self, $c, $q_council ) = @_;
+
+ my $council_short = $c->cobrand->short_name( $c->stash->{council}, $c->stash->{areas_info} );
+ my $url_short = URI::Escape::uri_escape_utf8($q_council);
+ $url_short =~ s/%2B/+/g;
+ $c->detach( 'redirect_area' ) unless $council_short eq $url_short;
+}
+
sub load_and_group_problems : Private {
my ( $self, $c ) = @_;
@@ -378,7 +395,7 @@ sub redirect_area : Private {
my $url = '';
$url .= "/rss" if $c->stash->{rss};
$url .= '/reports';
- $url .= '/' . $c->cobrand->short_name( $c->stash->{council} );
+ $url .= '/' . $c->cobrand->short_name( $c->stash->{council}, $c->stash->{areas_info} );
$url .= '/' . $c->cobrand->short_name( $c->stash->{ward} )
if $c->stash->{ward};
$c->res->redirect( $c->uri_for($url) );
diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t
index ba73b2555..42b05e2b8 100644
--- a/t/app/controller/report_import.t
+++ b/t/app/controller/report_import.t
@@ -68,7 +68,6 @@ subtest "Test creating bad partial entries" => sub {
};
-# submit an empty report to import - check we get all errors
subtest "Submit a correct entry" => sub {
$mech->get_ok('/import');
@@ -156,7 +155,6 @@ subtest "Submit a correct entry" => sub {
$mech->delete_user($user);
};
-# submit an empty report to import - check we get all errors
subtest "Submit a correct entry (with location)" => sub {
$mech->get_ok('/import');
@@ -235,4 +233,71 @@ subtest "Submit a correct entry (with location)" => sub {
$mech->delete_user($user);
};
+subtest "Submit a correct entry (with location) to cobrand" => sub {
+
+ skip( "Need 'fiksgatami' in ALLOWED_COBRANDS config", 8 )
+ unless FixMyStreet::App->config->{ALLOWED_COBRANDS} =~ m{fiksgatami};
+ mySociety::MaPit::configure('http://mapit.nuug.no/');
+ ok $mech->host("fiksgatami.no"), 'change host to fiksgatami';
+
+ $mech->get_ok('/import');
+
+ $mech->submit_form_ok( #
+ {
+ with_fields => {
+ service => 'test-script',
+ lat => '59',
+ lon => '10',
+ name => 'Test User ll',
+ email => 'test-ll@example.com',
+ subject => 'Test report ll',
+ detail => 'This is a test report ll',
+ photo => $sample_file,
+ }
+ },
+ "fill in form"
+ );
+
+ is_deeply( $mech->import_errors, [], "got no errors" );
+ is $mech->content, 'SUCCESS', "Got success response";
+
+ # check that we have received the email
+ $mech->email_count_is(1);
+ my $email = $mech->get_email;
+ $mech->clear_emails_ok;
+
+ my ($token_url) = $email->body =~ m{(http://\S+)};
+ ok $token_url, "Found a token url $token_url";
+
+ # go to the token url
+ $mech->get_ok($token_url);
+
+ # check that we are on '/report/new'
+ is $mech->uri->path, '/report/new', "sent to /report/new";
+
+ # check that fields are prefilled for us
+ is_deeply $mech->visible_form_values,
+ {
+ name => 'Test User ll',
+ title => 'Test report ll',
+ detail => 'This is a test report ll',
+ photo => '',
+ phone => '',
+ may_show_name => '1',
+ },
+ "check imported fields are shown";
+
+ my $user =
+ FixMyStreet::App->model('DB::User')
+ ->find( { email => 'test-ll@example.com' } );
+ ok $user, "Found a user";
+
+ my $report = $user->problems->first;
+ is $report->state, 'partial', 'is still partial';
+ is $report->title, 'Test report ll', 'title is correct';
+ is $report->lang, 'nb', 'language is correct';
+
+ $mech->delete_user($user);
+};
+
done_testing();
diff --git a/templates/web/default/reports/council.html b/templates/web/default/reports/council.html
index 27eb208c0..e33fa1bc9 100755
--- a/templates/web/default/reports/council.html
+++ b/templates/web/default/reports/council.html
@@ -18,7 +18,7 @@
[% map_html %]
-[% IF children %]
+[% IF children.size %]
<h2 style="clear:right">[% loc('Wards of this council') %]</h2>
<p>[% loc('Follow a ward link to view only reports within that ward.') %]</p>
<ul>
@@ -31,7 +31,35 @@
</div>
<div id="side">
+[% IF council.generation_high == 10 AND c.cobrand.country == 'GB' %]
+<p id="unknown">This council no longer exists.
+[% IF council.name.match('Penwith|Kerrier|Carrick|Restormel|Caradon|North Cornwall') %]
+Its area is now covered by <a href="/reports/Cornwall">Cornwall Council</a>.
+[% ELSIF council.name.match('Durham|Easington|Sedgefield|Teesdale|Wear Valley|Derwentside|Chester le Street') %]
+Its area is now covered by <a href="/reports/Durham+County">Durham County Council</a>.
+[% ELSIF council.name.match('Blyth Valley|Wansbeck|Castle Morpeth|Tynedale|Alnwick|Berwick upon Tweed') %]
+Its area is now covered by <a href="/reports/Northumberland">Northumberland County Council</a>.
+[% ELSIF council.name.match('North Shropshire|Oswestry|Shrewsbury and Atcham|South Shropshire|Bridgnorth') %]
+Its area is now covered by <a href="/reports/Shropshire">Shropshire Council</a>.
+[% ELSIF council.name.match('Salisbury|West Wiltshire|Kennet|North Wiltshire') %]
+Its area is now covered by <a href="/reports/Wiltshire">Wiltshire Council</a>.
+[% ELSIF council.name.match('Ellesmere Port and Neston|Vale Royal|Chester') %]
+Its area is now covered by <a href="/reports/Cheshire+West+and+Chester">Cheshire West and Chester Council</a>.
+[% ELSIF council.name.match('Macclesfield|Congleton|Crewe and Nantwich') %]
+Its area is now covered by <a href="/reports/Cheshire+East">Cheshire East Council</a>.
+[% ELSIF council.name.match('Mid Bedfordshire|South Bedfordshire') %]
+Its area is now covered by <a href="/reports/Central+Bedfordshire">Central Bedfordshire Council</a>.
+[% ELSIF council.name.match('Cheshire') %]
+Its area is now covered by <a href="/reports/Cheshire+West+and+Chester">Cheshire West and Chester Council</a> or
+<a href="/reports/Cheshire+East">Cheshire East Council</a>.
+[% ELSIF council.name.match('Bedfordshire') %]
+Its area is now covered by <a href="/reports/Bedford">Bedford Borough Council</a> or
+<a href="/reports/Central+Bedfordshire">Central Bedfordshire Council</a>.
+[% END %]
+</p>
+[% ELSE %]
<p><a href="[% rss_url %]"><img align="right" src="/i/feed.png" width="16" height="16" title="[% loc('RSS feed') %]" alt="[% tprintf(loc('RSS feed of problems in this %s'), thing) %]" border="0" hspace="4"></a>
+[% END %]
[% IF c.cobrand.all_councils_report %]
[% tprintf( loc('This is a summary of all reports for one %s.'), thing ) %]
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index daea80f65..a1d870483 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -215,7 +215,8 @@ OpenLayers.Control.PermalinkFMS = OpenLayers.Class(OpenLayers.Control.Permalink,
href = href.substring( 0, href.indexOf(separator) );
}
- href += separator + OpenLayers.Util.getParameterString(this.createParams(null, this.map.getZoom()+fixmystreet.ZOOM_OFFSET));
+ href += separator + OpenLayers.Util.getParameterString(this.createParams(null, this.map.getZoom()+fixmystreet.zoomOffset));
+ // Could use mlat/mlon here as well if we are on a page with a marker
if (this.anchor && !this.element) {
window.location.href = href;
}