-
-
-
-
-
-[% INCLUDE 'footer.html' pagefooter = 'yes' %]
--
cgit v1.2.3
From 02d06df3644d53aaa2611882491230fc28d843bd Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Fri, 20 Apr 2012 16:04:57 +0100
Subject: Have a whole fake mapit (for #182) that works if MAPIT_URL is set
accordingly.
Setting MAPIT_URL to .../fakemapit/ will then return one area, ID 161 and
type ZZZ, whatever co-ordinate it is given. This means the default area
type is now ZZZ, the UK specific types are moved into the UK cobrands, and
the tests updated accordingly to still function (they assume UK-ness a lot,
so probably need an ALLOWED_COBRANDS entry of "fixmystreet: 'localhost'" and
for your host's domain to show fixmystreet too).
---
perllib/FixMyStreet/App/Controller/Council.pm | 1 +
perllib/FixMyStreet/App/Controller/FakeMapit.pm | 53 +++++++++++++++++++++++++
perllib/FixMyStreet/App/Controller/Reports.pm | 4 +-
perllib/FixMyStreet/Cobrand/Default.pm | 4 +-
perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 3 ++
perllib/FixMyStreet/Cobrand/UKCouncils.pm | 3 ++
perllib/FixMyStreet/TestMech.pm | 26 ++----------
t/app/controller/around.t | 2 +-
t/app/controller/auth.t | 4 +-
t/app/controller/contact.t | 37 ++++++++---------
t/app/controller/report_display.t | 24 ++++++-----
t/app/controller/report_new.t | 12 +++---
t/app/controller/report_new_open311.t | 8 ++--
t/app/controller/report_updates.t | 4 +-
templates/web/fixmystreet/index.html | 4 ++
15 files changed, 121 insertions(+), 68 deletions(-)
create mode 100755 perllib/FixMyStreet/App/Controller/FakeMapit.pm
diff --git a/perllib/FixMyStreet/App/Controller/Council.pm b/perllib/FixMyStreet/App/Controller/Council.pm
index 48248e4fe..771603c22 100644
--- a/perllib/FixMyStreet/App/Controller/Council.pm
+++ b/perllib/FixMyStreet/App/Controller/Council.pm
@@ -37,6 +37,7 @@ there are no councils then return false.
sub load_and_check_councils : Private {
my ( $self, $c ) = @_;
+
my $latitude = $c->stash->{latitude};
my $longitude = $c->stash->{longitude};
diff --git a/perllib/FixMyStreet/App/Controller/FakeMapit.pm b/perllib/FixMyStreet/App/Controller/FakeMapit.pm
new file mode 100755
index 000000000..bc46df712
--- /dev/null
+++ b/perllib/FixMyStreet/App/Controller/FakeMapit.pm
@@ -0,0 +1,53 @@
+package FixMyStreet::App::Controller::FakeMapit;
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller'; }
+
+=head1 NAME
+
+FixMyStreet::App::Controller::FakeMapit - Catalyst Controller
+
+=head1 DESCRIPTION
+
+A controller to fake mapit when we don't have it. If you set MAPIT_URL to
+.../fakemapit/ it should all just work, with a mapit that assumes the whole
+world is one area, with ID 161 and name "Default Area".
+
+=head1 METHODS
+
+=cut
+
+my $area = { "name" => "Default Area", "type" => "ZZZ", "id" => 161 };
+
+sub output : Private {
+ my ( $self, $c, $data ) = @_;
+ my $body = JSON->new->utf8(1)->encode( $data );
+ $c->res->content_type('application/json; charset=utf-8');
+ $c->res->body( $body );
+}
+
+sub point : Local {
+ my ( $self, $c ) = @_;
+ $c->detach( 'output', [ { 161 => $area } ] );
+}
+
+sub area : Local {
+ my ( $self, $c ) = @_;
+ $c->detach( 'output', [ $area ] );
+}
+
+sub areas : Local {
+ my ( $self, $c ) = @_;
+ $c->detach( 'output', [ { 161 => $area } ] );
+}
+
+sub children : Path('area/161/children') : Args(0) {
+ my ( $self, $c ) = @_;
+ $c->detach( 'output', [ {} ] );
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
+
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 9a7bb6192..3ef0410a9 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -43,6 +43,7 @@ sub index : Path : Args(0) {
$c->stash->{message} = _("Unable to look up areas in MaPit. Please try again later.") . ' ' .
sprintf(_('The error was: %s'), $@);
$c->stash->{template} = 'errors/generic.html';
+ return;
}
# For each area, add its link and perhaps alter its name if we need to for
@@ -70,6 +71,7 @@ sub index : Path : Args(0) {
$c->stash->{message} = _("There was a problem showing the All Reports page. Please try again later.") . ' ' .
sprintf(_('The error was: %s'), $@);
$c->stash->{template} = 'errors/generic.html';
+ return;
}
# Down here so that error pages aren't cached.
@@ -126,7 +128,7 @@ sub ward : Path : Args(2) {
# List of wards
unless ($c->stash->{ward}) {
- my $children = mySociety::MaPit::call('area/children', $c->stash->{council}->{id},
+ my $children = mySociety::MaPit::call('area/children', [ $c->stash->{council}->{id} ],
type => $mySociety::VotingArea::council_child_types,
);
foreach (values %$children) {
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 5e8c9cb53..4ff0b922b 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -641,8 +641,8 @@ The MaPit types this site handles
=cut
-sub area_types { return qw(DIS LBO MTD UTA CTY COI); }
-sub area_min_generation { 10 }
+sub area_types { qw(ZZZ) }
+sub area_min_generation { '' }
=head2 contact_name, contact_email
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index d32e876bb..d838ec84b 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -1,6 +1,9 @@
package FixMyStreet::Cobrand::FixMyStreet;
use base 'FixMyStreet::Cobrand::Default';
+sub area_types { return qw(DIS LBO MTD UTA CTY COI); }
+sub area_min_generation { 10 }
+
# FixMyStreet should return all cobrands
sub restriction {
return {};
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 6d324c68a..82cf3f343 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -7,6 +7,9 @@ use warnings;
use Carp;
use URI::Escape;
+sub area_types { return qw(DIS LBO MTD UTA CTY COI); }
+sub area_min_generation { 10 }
+
sub is_council {
1;
}
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm
index dc42c1aba..2a49cc2f8 100644
--- a/perllib/FixMyStreet/TestMech.pm
+++ b/perllib/FixMyStreet/TestMech.pm
@@ -211,26 +211,6 @@ sub get_email {
return $emails[0];
}
-=head2 form_errors
-
- my $arrayref = $mech->form_errors;
-
-Find all the form errors on the current page and return them in page order as an
-arrayref of TEXTs. If none found return empty arrayref.
-
-=cut
-
-sub form_errors {
- my $mech = shift;
- my $result = scraper {
- process 'div.form-error', 'errors[]', 'TEXT';
- process 'p.form-error', 'errors[]', 'TEXT';
- process 'p.error', 'errors[]', 'TEXT';
- }
- ->scrape( $mech->response );
- return $result->{errors} || [];
-}
-
=head2 page_errors
my $arrayref = $mech->page_errors;
@@ -243,8 +223,7 @@ arrayref of TEXTs. If none found return empty arrayref.
sub page_errors {
my $mech = shift;
my $result = scraper {
- process 'p.error', 'errors[]', 'TEXT';
- process 'ul.error li', 'errors[]', 'TEXT';
+ process 'div.form-error, p.form-error, p.error, ul.error li', 'errors[]', 'TEXT';
}
->scrape( $mech->response );
return $result->{errors} || [];
@@ -327,6 +306,7 @@ sub extract_problem_meta {
my $result = scraper {
process 'div#side p em', 'meta', 'TEXT';
+ process '.problem-header p em', 'meta', 'TEXT';
}
->scrape( $mech->response );
@@ -348,6 +328,7 @@ sub extract_problem_title {
my $result = scraper {
process 'div#side h1', 'title', 'TEXT';
+ process '.problem-header h1', 'title', 'TEXT';
}
->scrape( $mech->response );
@@ -388,6 +369,7 @@ sub extract_update_metas {
my $result = scraper {
process 'div#updates div.problem-update p em', 'meta[]', 'TEXT';
+ process '.update-text .meta-2', 'meta[]', 'TEXT';
}
->scrape( $mech->response );
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index ca1694b49..db03e00f4 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -72,7 +72,7 @@ foreach my $test (
$mech->get_ok('/');
$mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
"good location" );
- is_deeply $mech->form_errors, [], "no errors for pc '$test->{pc}'";
+ is_deeply $mech->page_errors, [], "no errors for pc '$test->{pc}'";
is_deeply $mech->extract_location, $test,
"got expected location for pc '$test->{pc}'";
};
diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t
index efc5e60e6..5c6a4ef09 100644
--- a/t/app/controller/auth.t
+++ b/t/app/controller/auth.t
@@ -33,7 +33,7 @@ for my $test (
my ( $email, $error_message ) = @$test;
pass "--- testing bad email '$email' gives error '$error_message'";
$mech->get_ok('/auth');
- is_deeply $mech->form_errors, [], 'no errors initially';
+ is_deeply $mech->page_errors, [], 'no errors initially';
$mech->submit_form_ok(
{
form_name => 'general_auth',
@@ -43,7 +43,7 @@ for my $test (
"try to create an account with email '$email'"
);
is $mech->uri->path, '/auth', "still on auth page";
- is_deeply $mech->form_errors, [ $error_message ], 'no errors initially';
+ is_deeply $mech->page_errors, [ $error_message ], 'no errors initially';
}
# create a new account
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t
index 970241d12..11e0d30cf 100644
--- a/t/app/controller/contact.t
+++ b/t/app/controller/contact.t
@@ -131,8 +131,7 @@ for my $test (
message => '',
},
page_errors =>
- [ 'There were problems with your report. Please see below.', ],
- field_errors => [
+ [ 'There were problems with your report. Please see below.',
'Please enter your name',
'Please enter your email',
'Please enter a subject',
@@ -147,8 +146,7 @@ for my $test (
message => '',
},
page_errors =>
- [ 'There were problems with your report. Please see below.', ],
- field_errors => [
+ [ 'There were problems with your report. Please see below.',
'Please enter your name',
'Please enter a valid email address',
'Please enter a subject',
@@ -162,9 +160,10 @@ for my $test (
subject => '',
message => '',
},
- page_errors =>
- [ 'There were problems with your report. Please see below.', ],
- field_errors => [ 'Please enter a subject', 'Please write a message', ]
+ page_errors => [
+ 'There were problems with your report. Please see below.',
+ 'Please enter a subject', 'Please write a message',
+ ]
},
{
fields => {
@@ -173,9 +172,10 @@ for my $test (
subject => 'A subject',
message => '',
},
- page_errors =>
- [ 'There were problems with your report. Please see below.', ],
- field_errors => [ 'Please write a message', ]
+ page_errors => [
+ 'There were problems with your report. Please see below.',
+ 'Please write a message',
+ ]
},
{
fields => {
@@ -184,9 +184,11 @@ for my $test (
subject => ' ',
message => '',
},
- page_errors =>
- [ 'There were problems with your report. Please see below.', ],
- field_errors => [ 'Please enter a subject', 'Please write a message', ]
+ page_errors => [
+ 'There were problems with your report. Please see below.',
+ 'Please enter a subject',
+ 'Please write a message',
+ ]
},
{
fields => {
@@ -195,9 +197,10 @@ for my $test (
subject => 'A subject',
message => ' ',
},
- page_errors =>
- [ 'There were problems with your report. Please see below.', ],
- field_errors => [ 'Please write a message', ]
+ page_errors => [
+ 'There were problems with your report. Please see below.',
+ 'Please write a message',
+ ]
},
{
url => '/contact?id=' . $problem_main->id,
@@ -209,7 +212,6 @@ for my $test (
id => 'invalid',
},
page_errors => [ 'Illegal ID' ],
- field_errors => []
},
)
{
@@ -217,7 +219,6 @@ for my $test (
$mech->get_ok( $test->{url} ? $test->{url} : '/contact' );
$mech->submit_form_ok( { with_fields => $test->{fields} } );
is_deeply $mech->page_errors, $test->{page_errors}, 'page errors';
- is_deeply $mech->form_errors, $test->{field_errors}, 'field_errors';
# we santise this when we submit so need to remove it
delete $test->{fields}->{id}
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t
index 548580fe1..6c2733e36 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -209,7 +209,7 @@ for my $test (
),
state => 'confirmed',
banner_id => 'unknown',
- banner_text => 'This problem is old and of unknown status.',
+ banner_text => 'unknown',
fixed => 0
},
{
@@ -224,7 +224,7 @@ for my $test (
),
state => 'fixed',
banner_id => 'fixed',
- banner_text => 'This problem has been fixed.',
+ banner_text => 'fixed',
fixed => 1
},
{
@@ -232,7 +232,7 @@ for my $test (
date => DateTime->now,
state => 'fixed',
banner_id => 'fixed',
- banner_text => 'This problem has been fixed.',
+ banner_text => 'fixed',
fixed => 1
},
{
@@ -240,7 +240,7 @@ for my $test (
date => DateTime->now,
state => 'fixed - user',
banner_id => 'fixed',
- banner_text => 'This problem has been fixed.',
+ banner_text => 'fixed',
fixed => 1
},
{
@@ -248,7 +248,7 @@ for my $test (
date => DateTime->now,
state => 'fixed - council',
banner_id => 'fixed',
- banner_text => 'This problem has been fixed.',
+ banner_text => 'fixed',
fixed => 1
},
{
@@ -256,7 +256,7 @@ for my $test (
date => DateTime->now,
state => 'closed',
banner_id => 'closed',
- banner_text => 'This problem has been closed.',
+ banner_text => 'closed',
fixed => 0
},
{
@@ -264,7 +264,7 @@ for my $test (
date => DateTime->now,
state => 'investigating',
banner_id => 'progress',
- banner_text => 'This problem is in progress.',
+ banner_text => 'progress',
fixed => 0
},
{
@@ -272,7 +272,7 @@ for my $test (
date => DateTime->now,
state => 'planned',
banner_id => 'progress',
- banner_text => 'This problem is in progress.',
+ banner_text => 'progress',
fixed => 0
},
{
@@ -280,7 +280,7 @@ for my $test (
date => DateTime->now,
state => 'in progress',
banner_id => 'progress',
- banner_text => 'This problem is in progress.',
+ banner_text => 'progress',
fixed => 0
},
) {
@@ -299,7 +299,11 @@ for my $test (
}
is $banner->{id}, $test->{banner_id}, 'banner id';
- is $banner->{text}, $test->{banner_text}, 'banner text';
+ if ($test->{banner_text}) {
+ ok $banner->{text} =~ /$test->{banner_text}/i, 'banner text';
+ } else {
+ is $banner->{text}, $test->{banner_text}, 'banner text';
+ }
my $update_form = $mech->form_name( 'updateForm' );
if ( $test->{fixed} ) {
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 2875af537..909588766 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -374,7 +374,7 @@ foreach my $test (
# submit initial pc form
$mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
"submit location" );
- is_deeply $mech->form_errors, [], "no errors for pc '$test->{pc}'";
+ is_deeply $mech->page_errors, [], "no errors for pc '$test->{pc}'";
# click through to the report page
$mech->follow_link_ok( { text_regex => qr/skip this step/i, },
@@ -385,7 +385,7 @@ foreach my $test (
"submit form" );
# check that we got the errors expected
- is_deeply $mech->form_errors, $test->{errors}, "check errors";
+ is_deeply $mech->page_errors, $test->{errors}, "check errors";
# check that fields have changed as expected
my $new_values = {
@@ -466,7 +466,7 @@ foreach my $test (
);
# check that we got the errors expected
- is_deeply $mech->form_errors, [], "check there were no errors";
+ is_deeply $mech->page_errors, [], "check there were no errors";
# check that the user has been created/ not changed
my $user =
@@ -576,7 +576,7 @@ subtest "test password errors for a user who is signing in as they report" => su
);
# check that we got the errors expected
- is_deeply $mech->form_errors, [
+ is_deeply $mech->page_errors, [
"There was a problem with your email/password combination. If you cannot remember your password, or do not have one, please fill in the \x{2018}sign in by email\x{2019} section of the form.",
], "check there were errors";
};
@@ -623,7 +623,7 @@ subtest "test report creation for a user who is signing in as they report" => su
);
# check that we got the errors expected
- is_deeply $mech->form_errors, [
+ is_deeply $mech->page_errors, [
'You have successfully signed in; please check and confirm your details are accurate:',
], "check there were errors";
@@ -801,7 +801,7 @@ subtest "check that a lat/lon off coast leads to /around" => sub {
is $mech->uri->path, '/around', "redirected to '/around'";
is_deeply #
- $mech->form_errors,
+ $mech->page_errors,
[ 'That spot does not appear to be covered by a council. If you have'
. ' tried to report an issue past the shoreline, for example, please'
. ' specify the closest point on land.' ], #
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index dc3583e6b..863571ad0 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -113,10 +113,10 @@ foreach my $test (
# submit initial pc form
$mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
"submit location" );
- is_deeply $mech->form_errors, [], "no errors for pc '$test->{pc}'";
+ is_deeply $mech->page_errors, [], "no errors for pc '$test->{pc}'";
# click through to the report page
- $mech->follow_link_ok( { text => 'skip this step', },
+ $mech->follow_link_ok( { text_regex => qr/skip this step/i, },
"follow 'skip this step' link" );
# submit the main form
@@ -124,7 +124,7 @@ foreach my $test (
"submit form" );
# check that we got the errors expected
- is_deeply $mech->form_errors, $test->{errors}, "check errors";
+ is_deeply $mech->page_errors, $test->{errors}, "check errors";
# check that fields have changed as expected
my $new_values = {
@@ -136,7 +136,7 @@ foreach my $test (
if ( $test->{fields}->{category} eq 'Street lighting' ) {
my $result = scraper {
- process 'div#category_meta div select#form_type option', 'option[]' => '@value';
+ process 'select#form_type option', 'option[]' => '@value';
}
->scrape( $mech->response );
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 0337a881b..cf6af16cb 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -271,7 +271,7 @@ for my $test (
$mech->submit_form_ok( { with_fields => $test->{fields} },
'submit update' );
- is_deeply $mech->form_errors, $test->{field_errors}, 'field errors';
+ is_deeply $mech->page_errors, $test->{field_errors}, 'field errors';
my $values = {
%{ $test->{fields} },
@@ -640,7 +640,7 @@ for my $test (
'submit update'
);
- is_deeply $mech->form_errors, $test->{field_errors}, 'check there were errors';
+ is_deeply $mech->page_errors, $test->{field_errors}, 'check there were errors';
SKIP: {
skip( "Incorrect password", 5 ) unless $test->{form_values}{password_sign_in} eq $pw;
diff --git a/templates/web/fixmystreet/index.html b/templates/web/fixmystreet/index.html
index 476c426b0..b7b2cbe77 100644
--- a/templates/web/fixmystreet/index.html
+++ b/templates/web/fixmystreet/index.html
@@ -45,6 +45,10 @@ Modernizr.load({
[% INCLUDE 'header.html', title = '', bodyclass = 'frontpage fullwidthpage' %]
+[% IF error %]
+
[% error %]
+[% END %]
+
[% IF c.cobrand.moniker == 'bromley' %]
This is primarily for reporting physical problems that can be fixed
like graffiti, cleansing issues or road defects. To report other
--
cgit v1.2.3
From df59d7dbefa36b66c427f1d33f6392f1a3c209f5 Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Fri, 13 Jul 2012 10:55:41 +0100
Subject: Remove various UK specific code out of Default cobrand into UK one.
---
perllib/FixMyStreet/App/Controller/Council.pm | 6 +-
perllib/FixMyStreet/Cobrand/Default.pm | 76 +++------------
perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 48 +---------
perllib/FixMyStreet/Cobrand/UK.pm | 131 ++++++++++++++++++++++++++
perllib/FixMyStreet/Cobrand/UKCouncils.pm | 20 +---
perllib/FixMyStreet/Geocode/Bing.pm | 2 +-
6 files changed, 152 insertions(+), 131 deletions(-)
create mode 100644 perllib/FixMyStreet/Cobrand/UK.pm
diff --git a/perllib/FixMyStreet/App/Controller/Council.pm b/perllib/FixMyStreet/App/Controller/Council.pm
index 771603c22..b513ac930 100644
--- a/perllib/FixMyStreet/App/Controller/Council.pm
+++ b/perllib/FixMyStreet/App/Controller/Council.pm
@@ -23,7 +23,7 @@ there are no councils then return false.
sub load_and_check_councils_and_wards : Private {
my ( $self, $c ) = @_;
- my @area_types = ( $c->cobrand->area_types(), @$mySociety::VotingArea::council_child_types );
+ my @area_types = ( $c->cobrand->area_types(), $c->cobrand->area_types_children() );
$c->stash->{area_types} = \@area_types;
$c->forward('load_and_check_councils');
}
@@ -69,6 +69,10 @@ sub load_and_check_councils : Private {
mySociety::MaPit::call( 'point', "4326/$short_longitude,$short_latitude",
type => \@area_types );
}
+ if ($all_councils->{error}) {
+ $c->stash->{location_error} = $all_councils->{error};
+ return;
+ }
# Let cobrand do a check
my ( $success, $error_msg ) =
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 4ff0b922b..fc195432d 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -14,11 +14,12 @@ use mySociety::PostcodeUtil;
=head1 country
Returns the country that this cobrand operates in, as an ISO3166-alpha2 code.
+Default is none.
=cut
sub country {
- return 'GB';
+ return '';
}
=head1 problems_clause
@@ -237,17 +238,11 @@ sub front_stats_data {
=head2 disambiguate_location
-Returns disambiguating information available
+Returns any disambiguating information available. Defaults to none.
=cut
-sub disambiguate_location {
- return {
- country => 'uk',
- bing_culture => 'en-GB',
- bing_country => 'United Kingdom'
- };
-}
+sub disambiguate_location { return {}; }
=head2 cobrand_data_for_generic_update
@@ -417,7 +412,7 @@ adverts
=cut
-sub allow_crosssell_adverts { return 1; }
+sub allow_crosssell_adverts { return 0; }
=head2 allow_photo_display
@@ -444,35 +439,6 @@ Given a QUERY, return LAT/LON and/or ERROR.
sub geocode_postcode {
my ( $self, $s ) = @_;
-
- if ($s =~ /^\d+$/) {
- return {
- error => 'FixMyStreet is a UK-based website that currently works in England, Scotland, and Wales. Please enter either a postcode, or a Great British street name and area.'
- };
- } elsif (mySociety::PostcodeUtil::is_valid_postcode($s)) {
- my $location = mySociety::MaPit::call('postcode', $s);
- if ($location->{error}) {
- return {
- error => $location->{code} =~ /^4/
- ? _('That postcode was not recognised, sorry.')
- : $location->{error}
- };
- }
- my $island = $location->{coordsyst};
- if (!$island) {
- return {
- error => _("Sorry, that appears to be a Crown dependency postcode, which we don't cover.")
- };
- } elsif ($island eq 'I') {
- return {
- error => _("We do not currently cover Northern Ireland, I'm afraid.")
- };
- }
- return {
- latitude => $location->{wgs84_lat},
- longitude => $location->{wgs84_lon},
- };
- }
return {};
}
@@ -642,6 +608,7 @@ The MaPit types this site handles
=cut
sub area_types { qw(ZZZ) }
+sub area_types_children { qw() }
sub area_min_generation { '' }
=head2 contact_name, contact_email
@@ -707,16 +674,6 @@ Remove councils whose reports go to another council
sub remove_redundant_councils {
my $self = shift;
my $all_councils = shift;
-
- # Ipswich & St Edmundsbury are responsible for everything in their
- # areas, not Suffolk
- delete $all_councils->{2241}
- if $all_councils->{2446} #
- || $all_councils->{2443};
-
- # Norwich is responsible for everything in its areas, not Norfolk
- delete $all_councils->{2233} #
- if $all_councils->{2391};
}
=item filter_all_council_ids_list
@@ -738,21 +695,12 @@ Remove extra information from council names for tidy URIs
=cut
sub short_name {
- my $self = shift;
- my ($area, $info) = @_;
- # Special case Durham as it's the only place with two councils of the same name
- return 'Durham+County' if $area->{name} eq 'Durham County Council';
- return 'Durham+City' if $area->{name} eq 'Durham City Council';
-
- my $name = $area->{name};
- $name =~ s/ (Borough|City|District|County) Council$//;
- $name =~ s/ Council$//;
- $name =~ s/ & / and /;
- $name =~ s{/}{_}g;
- $name = URI::Escape::uri_escape_utf8($name);
- $name =~ s/%20/+/g;
- return $name;
-
+ my $self = shift;
+ my ($area, $info) = @_;
+ my $name = $area->{name};
+ $name = URI::Escape::uri_escape_utf8($name);
+ $name =~ s/%20/+/g;
+ return $name;
}
=item is_council
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index d838ec84b..d44c58f37 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -1,8 +1,5 @@
package FixMyStreet::Cobrand::FixMyStreet;
-use base 'FixMyStreet::Cobrand::Default';
-
-sub area_types { return qw(DIS LBO MTD UTA CTY COI); }
-sub area_min_generation { 10 }
+use base 'FixMyStreet::Cobrand::UK';
# FixMyStreet should return all cobrands
sub restriction {
@@ -13,21 +10,6 @@ sub admin_base_url {
return 'https://secure.mysociety.org/admin/bci/';
}
-sub get_council_sender {
- my ( $self, $area_id, $area_info ) = @_;
-
- my $send_method;
-
- my $council_config = FixMyStreet::App->model("DB::Open311conf")->search( { area_id => $area_id } )->first;
- $send_method = $council_config->send_method if $council_config;
-
- return $send_method if $send_method;
-
- return 'London' if $area_info->{type} eq 'LBO';
-
- return 'Email';
-}
-
sub all_reports_style { return 'detailed'; }
sub generate_problem_banner {
@@ -56,33 +38,7 @@ sub generate_problem_banner {
return $banner;
}
-sub process_extras {
- my $self = shift;
- my $ctx = shift;
- my $area_id = shift;
- my $extra = shift;
- my $fields = shift || [];
-
- if ( $area_id == 2482 ) {
- my @fields = ( 'fms_extra_title', @$fields );
- for my $field ( @fields ) {
- my $value = $ctx->request->param( $field );
+sub allow_crosssell_adverts { return 1; }
- if ( !$value ) {
- $ctx->stash->{field_errors}->{ $field } = _('This information is required');
- }
- push @$extra, {
- name => $field,
- description => uc( $field),
- value => $value || '',
- };
- }
-
- if ( $ctx->request->param('fms_extra_title') ) {
- $ctx->stash->{fms_extra_title} = $ctx->request->param('fms_extra_title');
- $ctx->stash->{extra_name_info} = 1;
- }
- }
-}
1;
diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm
new file mode 100644
index 000000000..f160d193e
--- /dev/null
+++ b/perllib/FixMyStreet/Cobrand/UK.pm
@@ -0,0 +1,131 @@
+package FixMyStreet::Cobrand::UK;
+use base 'FixMyStreet::Cobrand::Default';
+
+use mySociety::VotingArea;
+
+sub country { return 'GB'; }
+sub area_types { return qw(DIS LBO MTD UTA CTY COI); }
+sub area_types_children { return @$mySociety::VotingArea::council_child_types }
+sub area_min_generation { 10 }
+
+sub disambiguate_location {
+ return {
+ country => 'uk',
+ bing_culture => 'en-GB',
+ bing_country => 'United Kingdom'
+ };
+}
+
+sub get_council_sender {
+ my ( $self, $area_id, $area_info ) = @_;
+
+ my $send_method;
+
+ my $council_config = FixMyStreet::App->model("DB::Open311conf")->search( { area_id => $area_id } )->first;
+ $send_method = $council_config->send_method if $council_config;
+
+ return $send_method if $send_method;
+
+ return 'London' if $area_info->{type} eq 'LBO';
+
+ return 'Email';
+}
+
+sub process_extras {
+ my $self = shift;
+ my $ctx = shift;
+ my $area_id = shift;
+ my $extra = shift;
+ my $fields = shift || [];
+
+ if ( $area_id == 2482 ) {
+ my @fields = ( 'fms_extra_title', @$fields );
+ for my $field ( @fields ) {
+ my $value = $ctx->request->param( $field );
+
+ if ( !$value ) {
+ $ctx->stash->{field_errors}->{ $field } = _('This information is required');
+ }
+ push @$extra, {
+ name => $field,
+ description => uc( $field),
+ value => $value || '',
+ };
+ }
+
+ if ( $ctx->request->param('fms_extra_title') ) {
+ $ctx->stash->{fms_extra_title} = $ctx->request->param('fms_extra_title');
+ $ctx->stash->{extra_name_info} = 1;
+ }
+ }
+}
+
+sub geocode_postcode {
+ my ( $self, $s ) = @_;
+
+ if ($s =~ /^\d+$/) {
+ return {
+ error => 'FixMyStreet is a UK-based website that currently works in England, Scotland, and Wales. Please enter either a postcode, or a Great British street name and area.'
+ };
+ } elsif (mySociety::PostcodeUtil::is_valid_postcode($s)) {
+ my $location = mySociety::MaPit::call('postcode', $s);
+ if ($location->{error}) {
+ return {
+ error => $location->{code} =~ /^4/
+ ? _('That postcode was not recognised, sorry.')
+ : $location->{error}
+ };
+ }
+ my $island = $location->{coordsyst};
+ if (!$island) {
+ return {
+ error => _("Sorry, that appears to be a Crown dependency postcode, which we don't cover.")
+ };
+ } elsif ($island eq 'I') {
+ return {
+ error => _("We do not currently cover Northern Ireland, I'm afraid.")
+ };
+ }
+ return {
+ latitude => $location->{wgs84_lat},
+ longitude => $location->{wgs84_lon},
+ };
+ }
+ return {};
+}
+
+sub remove_redundant_councils {
+ my $self = shift;
+ my $all_councils = shift;
+
+ # Ipswich & St Edmundsbury are responsible for everything in their
+ # areas, not Suffolk
+ delete $all_councils->{2241}
+ if $all_councils->{2446} #
+ || $all_councils->{2443};
+
+ # Norwich is responsible for everything in its areas, not Norfolk
+ delete $all_councils->{2233} #
+ if $all_councils->{2391};
+}
+
+sub short_name {
+ my $self = shift;
+ my ($area, $info) = @_;
+ # Special case Durham as it's the only place with two councils of the same name
+ return 'Durham+County' if $area->{name} eq 'Durham County Council';
+ return 'Durham+City' if $area->{name} eq 'Durham City Council';
+
+ my $name = $area->{name};
+ $name =~ s/ (Borough|City|District|County) Council$//;
+ $name =~ s/ Council$//;
+ $name =~ s/ & / and /;
+ $name =~ s{/}{_}g;
+ $name = URI::Escape::uri_escape_utf8($name);
+ $name =~ s/%20/+/g;
+ return $name;
+
+}
+
+1;
+
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 82cf3f343..23f84e76f 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -1,5 +1,5 @@
package FixMyStreet::Cobrand::UKCouncils;
-use base 'FixMyStreet::Cobrand::Default';
+use base 'FixMyStreet::Cobrand::UK';
use strict;
use warnings;
@@ -7,9 +7,6 @@ use warnings;
use Carp;
use URI::Escape;
-sub area_types { return qw(DIS LBO MTD UTA CTY COI); }
-sub area_min_generation { 10 }
-
sub is_council {
1;
}
@@ -94,19 +91,4 @@ sub recent_photos {
return $self->problems->recent_photos( $num, $lat, $lon, $dist );
}
-sub get_council_sender {
- my ( $self, $area_id, $area_info ) = @_;
-
- my $send_method;
-
- my $council_config = FixMyStreet::App->model("DB::Open311conf")->search( { area_id => $area_id } )->first;
- $send_method = $council_config->send_method if $council_config;
-
- return $send_method if $send_method;
-
- return 'London' if $area_info->{type} eq 'LBO';
-
- return 'Email';
-}
-
1;
diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm
index 3bbb9dcdc..148ad5f43 100644
--- a/perllib/FixMyStreet/Geocode/Bing.pm
+++ b/perllib/FixMyStreet/Geocode/Bing.pm
@@ -56,7 +56,7 @@ sub string {
foreach (@$results) {
my $address = $_->{name};
- next unless $_->{address}->{countryRegion} eq $params->{bing_country};
+ next if $params->{bing_country} && $_->{address}->{countryRegion} ne $params->{bing_country};
if ($params->{bing_country} eq 'United Kingdom' && $_->{address}{adminDistrict} eq 'Northern Ireland') {
$ni = 1;
next;
--
cgit v1.2.3
From 20138c0fa9805e8eb8cb1b413310242f1ac1f8cd Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Fri, 13 Jul 2012 13:30:45 +0100
Subject: Move banner generation logic out of cobrand code and into templates.
---
perllib/FixMyStreet/App/Controller/Report.pm | 2 --
perllib/FixMyStreet/Cobrand/Default.pm | 36 ---------------------------
perllib/FixMyStreet/Cobrand/EmptyHomes.pm | 22 ----------------
perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 26 -------------------
templates/web/bromley/report/display.html | 7 +-----
templates/web/default/report/banner.html | 22 ++++++++++++++++
templates/web/default/report/display.html | 7 +-----
templates/web/emptyhomes/report/display.html | 6 ++---
templates/web/fixmystreet/report/banner.html | 21 ++++++++++++++++
templates/web/fixmystreet/report/display.html | 8 +-----
10 files changed, 49 insertions(+), 108 deletions(-)
create mode 100644 templates/web/default/report/banner.html
create mode 100644 templates/web/fixmystreet/report/banner.html
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 6f249b2fe..24abc5ba4 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -115,8 +115,6 @@ sub format_problem_for_display : Private {
my $problem = $c->stash->{problem};
- $c->stash->{banner} = $c->cobrand->generate_problem_banner($problem);
-
( $c->stash->{short_latitude}, $c->stash->{short_longitude} ) =
map { Utils::truncate_coordinate($_) }
( $problem->latitude, $problem->longitude );
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index fc195432d..a73487ca4 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -855,42 +855,6 @@ sub council_rss_alert_options {
return ( \@options, @reported_to_options ? \@reported_to_options : undef );
}
-=head2 generate_problem_banner
-
- my $banner = $c->cobrand->generate_problem_banner;
-
-
[% banner.text %]
-
-Generate id and text for banner that appears at top of problem page.
-
-=cut
-
-sub generate_problem_banner {
- my ( $self, $problem ) = @_;
-
- my $banner = {};
- if ($problem->is_fixed ) {
- $banner->{id} = 'fixed';
- $banner->{text} = _('This problem has been fixed') . '.';
- }
-
- return $banner;
-}
-
=head2 default_photo_resize
Size that photos are to be resized to for display. If photos aren't
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index d44c58f37..33e071b66 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -12,32 +12,6 @@ sub admin_base_url {
sub all_reports_style { return 'detailed'; }
-sub generate_problem_banner {
- my ( $self, $problem ) = @_;
-
- my $banner = {};
- if ( $problem->is_open && time() - $problem->lastupdate_local->epoch > 8 * 7 * 24 * 60 * 60 )
- {
- $banner->{id} = 'unknown';
- $banner->{text} = _('Unknown');
- }
- if ($problem->is_fixed) {
- $banner->{id} = 'fixed';
- $banner->{text} = _('Fixed');
- }
- if ($problem->is_closed) {
- $banner->{id} = 'closed';
- $banner->{text} = _('Closed');
- }
-
- if ( grep { $problem->state eq $_ } ( 'investigating', 'in progress', 'planned' ) ) {
- $banner->{id} = 'progress';
- $banner->{text} = _('In progress');
- }
-
- return $banner;
-}
-
sub allow_crosssell_adverts { return 1; }
1;
diff --git a/templates/web/bromley/report/display.html b/templates/web/bromley/report/display.html
index 89b74277f..13bc5f960 100644
--- a/templates/web/bromley/report/display.html
+++ b/templates/web/bromley/report/display.html
@@ -15,12 +15,7 @@
-[% IF banner.id %]
-
-
[% banner.text %]
-
-[% END %]
-
+[% INCLUDE 'report/banner.html' %]
[% INCLUDE 'report/_main.html' %]
diff --git a/templates/web/default/report/banner.html b/templates/web/default/report/banner.html
new file mode 100644
index 000000000..85aaed82d
--- /dev/null
+++ b/templates/web/default/report/banner.html
@@ -0,0 +1,22 @@
+[% USE date %]
+[% BLOCK banner %]
+
+ [% text %]
+
+[% END %]
+
+[% IF problem.is_open AND date.now - problem.lastupdate_local.epoch > 8 * 7 * 24 * 60 * 60 %]
+ [% INCLUDE banner, id = 'unknown', text = loc('This problem is old and of unknown status.') %]
+[% END %]
+[% IF problem.is_fixed %]
+ [% INCLUDE banner, id = 'fixed', text = loc('This problem has been fixed') %]
+[% END %]
+[% IF problem.is_closed %]
+ [% INCLUDE banner, id = 'closed', text = loc('This problem has been closed') %]
+[% END %]
+[% states = [ 'investigating', 'in progress', 'planned' ];
+ IF states.grep(problem.state).size %]
+ [% INCLUDE banner, id = 'progress', text = loc('This problem is in progress') %]
+[% END %]
+
+
diff --git a/templates/web/default/report/display.html b/templates/web/default/report/display.html
index fac3ef0b2..6b93539f2 100644
--- a/templates/web/default/report/display.html
+++ b/templates/web/default/report/display.html
@@ -13,12 +13,7 @@
-[% IF banner.id %]
-
- [% banner.text %]
-
-[% END %]
-
+[% INCLUDE 'report/banner.html' %]
[% INCLUDE 'report/_main.html' %]
[% END %]
diff --git a/templates/web/fixmystreet/report/banner.html b/templates/web/fixmystreet/report/banner.html
new file mode 100644
index 000000000..58712604e
--- /dev/null
+++ b/templates/web/fixmystreet/report/banner.html
@@ -0,0 +1,21 @@
+[% USE date %]
+[% BLOCK banner %]
+
+
[% text %]
+
+[% END %]
+
+[% IF problem.is_open AND date.now - problem.lastupdate_local.epoch > 8 * 7 * 24 * 60 * 60 %]
+ [% INCLUDE banner, id = 'unknown', text = loc('Unknown') %]
+[% END %]
+[% IF problem.is_fixed %]
+ [% INCLUDE banner, id = 'fixed', text = loc('Fixed') %]
+[% END %]
+[% IF problem.is_closed %]
+ [% INCLUDE banner, id = 'closed', text = loc('Closed') %]
+[% END %]
+[% states = [ 'investigating', 'in progress', 'planned' ];
+ IF states.grep(problem.state).size %]
+ [% INCLUDE banner, id = 'progress', text = loc('In progress') %]
+[% END %]
+
diff --git a/templates/web/fixmystreet/report/display.html b/templates/web/fixmystreet/report/display.html
index c5cfc8915..a22de373d 100644
--- a/templates/web/fixmystreet/report/display.html
+++ b/templates/web/fixmystreet/report/display.html
@@ -14,13 +14,7 @@
-
-[% IF banner.id %]
-
-
[% banner.text %]
-
-[% END %]
-
+[% INCLUDE 'report/banner.html' %]
[% INCLUDE 'report/_main.html' %]
--
cgit v1.2.3
From eb0afb86462032b1fd8a380a3d237c72602ade43 Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Fri, 13 Jul 2012 13:57:27 +0100
Subject: If no MAPIT_URL in config, default to the fake one.
---
perllib/FixMyStreet/App.pm | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index 9553aafa2..0adf66ee9 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -183,6 +183,10 @@ sub setup_request {
FixMyStreet::Map::set_map_class( $cobrand->map_type || $c->req->param('map_override') );
+ unless ( FixMyStreet->config('MAPIT_URL') ) {
+ mySociety::MaPit::configure( "http://$host/fakemapit/" );
+ }
+
return $c;
}
--
cgit v1.2.3
From dbeb763d227b011b42ccd44a8cb72a01dcea24ca Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Fri, 13 Jul 2012 13:58:05 +0100
Subject: Always allow OSM as an allowed map type, even if none given.
---
perllib/FixMyStreet/Map.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm
index 08bba3285..d36b91ffe 100644
--- a/perllib/FixMyStreet/Map.pm
+++ b/perllib/FixMyStreet/Map.pm
@@ -18,7 +18,6 @@ use Module::Pluggable
# Get the list of maps we want and load map classes at compile time
my @ALL_MAP_CLASSES = allowed_maps();
-use mySociety::Config;
use mySociety::Gaze;
use mySociety::Locale;
use Utils;
@@ -31,7 +30,8 @@ are permitted by the config.
=cut
sub allowed_maps {
- my @allowed = split /,/, mySociety::Config::get('MAP_TYPE');
+ my @allowed = split /,/, ( FixMyStreet->config('MAP_TYPE') or "");
+ push @allowed, 'OSM'; # OSM is always allowed
@allowed = map { __PACKAGE__.'::'.$_ } @allowed;
my %avail = map { $_ => 1 } __PACKAGE__->maps;
return grep { $avail{$_} } @allowed;
--
cgit v1.2.3
From 0000afc1f4b28c96365981fc24437a6983ee7ea2 Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Fri, 13 Jul 2012 15:12:06 +0100
Subject: Add Nominatim-based geocoding service (fixes #183).
---
bin/generate_council_location | 2 +-
notes/customisation.pod | 2 +-
perllib/FixMyStreet/Cobrand/Barnet.pm | 2 +-
perllib/FixMyStreet/Cobrand/Bromley.pm | 2 +-
perllib/FixMyStreet/Cobrand/LichfieldDC.pm | 2 +-
perllib/FixMyStreet/Cobrand/Reading.pm | 2 +-
perllib/FixMyStreet/Cobrand/Southampton.pm | 2 +-
perllib/FixMyStreet/Cobrand/UK.pm | 3 +-
perllib/FixMyStreet/Geocode.pm | 7 ++-
perllib/FixMyStreet/Geocode/Bing.pm | 2 +-
perllib/FixMyStreet/Geocode/Google.pm | 12 ++++--
perllib/FixMyStreet/Geocode/OSM.pm | 69 +++++++++++++++++++++++++++---
12 files changed, 87 insertions(+), 20 deletions(-)
diff --git a/bin/generate_council_location b/bin/generate_council_location
index 36bf14d04..6acb21b0e 100644
--- a/bin/generate_council_location
+++ b/bin/generate_council_location
@@ -22,5 +22,5 @@ my $spn_lon = $max_lon - $min_lon;
print <<"EOT";
centre => '$c_lat,$c_lon',
span => '$spn_lat,$spn_lon',
- bounds => [ '$min_lat,$min_lon','$max_lat,$max_lon' ],
+ bounds => [ $min_lat, $min_lon, $max_lat, $max_lon ],
EOT
diff --git a/notes/customisation.pod b/notes/customisation.pod
index 04bfb6e1d..fedd9da44 100644
--- a/notes/customisation.pod
+++ b/notes/customisation.pod
@@ -133,7 +133,7 @@ that the geocoder will consider:
return {
centre => '52.688198,-1.804966',
span => '0.1196,0.218675',
- bounds => [ '52.807793,-1.586291', '52.584891,-1.963232' ],
+ bounds => [ 52.807793, -1.586291, 52.584891, -1.963232 ],
};
}
diff --git a/perllib/FixMyStreet/Cobrand/Barnet.pm b/perllib/FixMyStreet/Cobrand/Barnet.pm
index d33204521..7320edc40 100644
--- a/perllib/FixMyStreet/Cobrand/Barnet.pm
+++ b/perllib/FixMyStreet/Cobrand/Barnet.pm
@@ -31,7 +31,7 @@ sub disambiguate_location {
town => 'Barnet',
centre => '51.612832,-0.218169',
span => '0.0563,0.09',
- bounds => [ '51.584682,-0.263169', '51.640982,-0.173169' ],
+ bounds => [ 51.584682, -0.263169, 51.640982, -0.173169 ],
};
}
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index c5c6c6345..a52875819 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -42,7 +42,7 @@ sub disambiguate_location {
town => 'Bromley',
centre => '51.366836,0.040623',
span => '0.154963,0.24347',
- bounds => [ '51.289355,-0.081112', '51.444318,0.162358' ],
+ bounds => [ 51.289355, -0.081112, 51.444318, 0.162358 ],
};
}
diff --git a/perllib/FixMyStreet/Cobrand/LichfieldDC.pm b/perllib/FixMyStreet/Cobrand/LichfieldDC.pm
index f98775c91..fb00aec48 100644
--- a/perllib/FixMyStreet/Cobrand/LichfieldDC.pm
+++ b/perllib/FixMyStreet/Cobrand/LichfieldDC.pm
@@ -22,7 +22,7 @@ sub disambiguate_location {
%{ $self->SUPER::disambiguate_location() },
centre => '52.688198,-1.804966',
span => '0.1196,0.218675',
- bounds => [ '52.584891,-1.963232', '52.807793,-1.586291' ],
+ bounds => [ 52.584891, -1.963232, 52.807793, -1.586291 ],
};
}
diff --git a/perllib/FixMyStreet/Cobrand/Reading.pm b/perllib/FixMyStreet/Cobrand/Reading.pm
index c8591924e..4cd3f82e2 100644
--- a/perllib/FixMyStreet/Cobrand/Reading.pm
+++ b/perllib/FixMyStreet/Cobrand/Reading.pm
@@ -18,7 +18,7 @@ sub disambiguate_location {
town => 'Reading',
centre => '51.452983,-0.983827',
span => '0.083355,0.1245',
- bounds => [ '51.409779,-1.052994', '51.493134,-0.928494' ],
+ bounds => [ 51.409779, -1.052994, 51.493134, -0.928494 ],
};
}
diff --git a/perllib/FixMyStreet/Cobrand/Southampton.pm b/perllib/FixMyStreet/Cobrand/Southampton.pm
index b57091bef..b7374149a 100644
--- a/perllib/FixMyStreet/Cobrand/Southampton.pm
+++ b/perllib/FixMyStreet/Cobrand/Southampton.pm
@@ -16,7 +16,7 @@ sub disambiguate_location {
town => 'Southampton',
centre => '50.913822,-1.400493',
span => '0.084628,0.15701',
- bounds => [ '50.871508,-1.478998', '50.956136,-1.321988' ],
+ bounds => [ 50.871508, -1.478998, 50.956136, -1.321988 ],
};
}
diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm
index f160d193e..093ba152b 100644
--- a/perllib/FixMyStreet/Cobrand/UK.pm
+++ b/perllib/FixMyStreet/Cobrand/UK.pm
@@ -10,7 +10,8 @@ sub area_min_generation { 10 }
sub disambiguate_location {
return {
- country => 'uk',
+ country => 'gb',
+ google_country => 'uk',
bing_culture => 'en-GB',
bing_country => 'United Kingdom'
};
diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm
index 6ee17029a..e5983810b 100644
--- a/perllib/FixMyStreet/Geocode.pm
+++ b/perllib/FixMyStreet/Geocode.pm
@@ -12,6 +12,7 @@ use strict;
use URI::Escape;
use FixMyStreet::Geocode::Bing;
use FixMyStreet::Geocode::Google;
+use FixMyStreet::Geocode::OSM;
# lookup STRING CONTEXT
# Given a user-inputted string, try and convert it into co-ordinates using either
@@ -41,8 +42,10 @@ sub string {
my $params = $c->cobrand->disambiguate_location();
return FixMyStreet::Geocode::Bing::string($s, $c, $params)
if FixMyStreet->config('BING_MAPS_API_KEY');
- # Fall back to Google API, which allow acces with and without a key
- return FixMyStreet::Geocode::Google::string($s, $c, $params);
+ # Fall back to Google API, which allow access with and without a key
+ return FixMyStreet::Geocode::Google::string($s, $c, $params)
+ if FixMyStreet->config('GOOGLE_MAPS_API_KEY');
+ return FixMyStreet::Geocode::OSM::string($s, $c, $params);
}
1;
diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm
index 148ad5f43..13542347d 100644
--- a/perllib/FixMyStreet/Geocode/Bing.pm
+++ b/perllib/FixMyStreet/Geocode/Bing.pm
@@ -24,7 +24,7 @@ sub string {
my ( $s, $c, $params ) = @_;
$s .= '+' . $params->{town} if $params->{town} and $s !~ /$params->{town}/i;
my $url = "http://dev.virtualearth.net/REST/v1/Locations?q=$s";
- $url .= '&userMapView=' . $params->{bounds}[0] . ',' . $params->{bounds}[1]
+ $url .= '&userMapView=' . join(',', @{$params->{bounds}})
if $params->{bounds};
$url .= '&userLocation=' . $params->{centre} if $params->{centre};
$url .= '&c=' . $params->{bing_culture} if $params->{bing_culture};
diff --git a/perllib/FixMyStreet/Geocode/Google.pm b/perllib/FixMyStreet/Geocode/Google.pm
index 1ab347066..0d568f8f1 100644
--- a/perllib/FixMyStreet/Geocode/Google.pm
+++ b/perllib/FixMyStreet/Geocode/Google.pm
@@ -24,10 +24,14 @@ sub string {
my ( $s, $c, $params ) = @_;
my $url = 'http://maps.google.com/maps/geo?q=' . $s;
- $url .= '&ll=' . $params->{centre} if $params->{centre};
- $url .= '&spn=' . $params->{span} if $params->{span};
- $url .= '&gl=' . $params->{country} if $params->{country};
- $url .= '&hl=' . $params->{lang} if $params->{lang};
+ $url .= '&ll=' . $params->{centre} if $params->{centre};
+ $url .= '&spn=' . $params->{span} if $params->{span};
+ if ($params->{google_country}) {
+ $url .= '&gl=' . $params->{google_country};
+ } elsif ($params->{country}) {
+ $url .= '&gl=' . $params->{country};
+ }
+ $url .= '&hl=' . $params->{lang} if $params->{lang};
my $cache_dir = FixMyStreet->config('GEO_CACHE') . 'google/';
my $cache_file = $cache_dir . md5_hex($url);
diff --git a/perllib/FixMyStreet/Geocode/OSM.pm b/perllib/FixMyStreet/Geocode/OSM.pm
index b1becaa7a..ba939b443 100644
--- a/perllib/FixMyStreet/Geocode/OSM.pm
+++ b/perllib/FixMyStreet/Geocode/OSM.pm
@@ -11,20 +11,79 @@ package FixMyStreet::Geocode::OSM;
use warnings;
use strict;
-use Memcached;
-use mySociety::Config;
+use Digest::MD5 qw(md5_hex);
+use Encode;
+use File::Slurp;
+use File::Path ();
use LWP::Simple;
+use Memcached;
use XML::Simple;
my $osmapibase = "http://www.openstreetmap.org/api/";
my $nominatimbase = "http://nominatim.openstreetmap.org/";
+# string STRING CONTEXT
+# Looks up on Nominatim, and caches, a user-inputted location.
+# Returns array of (LAT, LON, ERROR), where ERROR is either undef, a string, or
+# an array of matches if there are more than one. The information in the query
+# may be used to disambiguate the location in cobranded versions of the site.
+sub string {
+ my ( $s, $c, $params ) = @_;
+ $s .= '+' . $params->{town} if $params->{town} and $s !~ /$params->{town}/i;
+ my $url = "${nominatimbase}search?";
+ my %query_params = (
+ q => $s,
+ format => 'json',
+ #'accept-language' => '',
+ email => 'support' . chr(64) . 'fixmystreet.com',
+ );
+ $query_params{viewbox} = $params->{bounds}[1] . ',' . $params->{bounds}[2] . ',' . $params->{bounds}[3] . ',' . $params->{bounds}[0]
+ if $params->{bounds};
+ $query_params{countrycodes} = $params->{country}
+ if $params->{country};
+ $url .= join('&', map { "$_=$query_params{$_}" } keys %query_params);
+
+ my $cache_dir = FixMyStreet->config('GEO_CACHE') . 'osm/';
+ my $cache_file = $cache_dir . md5_hex($url);
+ my $js;
+ if (-s $cache_file) {
+ $js = File::Slurp::read_file($cache_file);
+ } else {
+ $js = LWP::Simple::get($url);
+ $js = encode_utf8($js) if utf8::is_utf8($js);
+ File::Path::mkpath($cache_dir);
+ File::Slurp::write_file($cache_file, $js) if $js;
+ }
+
+ if (!$js) {
+ return { error => _('Sorry, we could not parse that location. Please try again.') };
+ }
+
+ $js = JSON->new->utf8->allow_nonref->decode($js);
+
+ my ( $error, @valid_locations, $latitude, $longitude );
+ foreach (@$js) {
+ # These co-ordinates are output as query parameters in a URL, make sure they have a "."
+ ( $latitude, $longitude ) = ( $_->{lat}, $_->{lon} );
+ mySociety::Locale::in_gb_locale {
+ push (@$error, {
+ address => $_->{display_name},
+ latitude => sprintf('%0.6f', $latitude),
+ longitude => sprintf('%0.6f', $longitude)
+ });
+ };
+ push (@valid_locations, $_);
+ }
+
+ return { latitude => $latitude, longitude => $longitude } if scalar @valid_locations == 1;
+ return { error => $error };
+}
-sub lookup_location {
+sub reverse_geocode {
my ($latitude, $longitude, $zoom) = @_;
my $url =
"${nominatimbase}reverse?format=xml&zoom=$zoom&lat=$latitude&lon=$longitude";
- my $key = "OSM:lookup_location:$url";
+ my $key = "OSM:reverse_geocode:$url";
my $result = Memcached::get($key);
unless ($result) {
my $j = LWP::Simple::get($url);
@@ -74,7 +133,7 @@ sub get_object_tags {
# http://www.geonames.org/maps/osm-reverse-geocoder.html#findNearbyStreetsOSM
sub get_nearest_road_tags {
my ( $cobrand, $latitude, $longitude ) = @_;
- my $inforef = lookup_location($latitude, $longitude, 16);
+ my $inforef = reverse_geocode($latitude, $longitude, 16);
if (exists $inforef->{result}->{osm_type}
&& 'way' eq $inforef->{result}->{osm_type}) {
my $osmtags = get_object_tags('way',
--
cgit v1.2.3
From 932f88e1a7776eeb2567b91e003361bb5275bf5d Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Fri, 13 Jul 2012 15:48:30 +0100
Subject: Move all_reports_style functionality to templates.
---
perllib/FixMyStreet/Cobrand/Bromley.pm | 1 -
perllib/FixMyStreet/Cobrand/Default.pm | 9 --
perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 2 -
templates/web/default/reports/_list-entry.html | 6 +
templates/web/default/reports/_rss.html | 2 +
templates/web/default/reports/_ward-list.html | 9 ++
templates/web/default/reports/council.html | 130 +++++----------------
templates/web/fixmystreet/reports/_list-entry.html | 21 ++++
templates/web/fixmystreet/reports/_rss.html | 19 +++
templates/web/fixmystreet/reports/_ward-list.html | 12 ++
10 files changed, 98 insertions(+), 113 deletions(-)
create mode 100755 templates/web/default/reports/_list-entry.html
create mode 100644 templates/web/default/reports/_rss.html
create mode 100755 templates/web/default/reports/_ward-list.html
create mode 100755 templates/web/fixmystreet/reports/_list-entry.html
create mode 100644 templates/web/fixmystreet/reports/_rss.html
create mode 100755 templates/web/fixmystreet/reports/_ward-list.html
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index a52875819..62827eec1 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -10,7 +10,6 @@ sub council_id { return 2482; }
sub council_area { return 'Bromley'; }
sub council_name { return 'Bromley Council'; }
sub council_url { return 'bromley'; }
-sub all_reports_style { return 'detailed'; }
sub base_url {
return FixMyStreet->config('BASE_URL') if FixMyStreet->config('STAGING_SITE');
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index a73487ca4..5de8bac37 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -132,15 +132,6 @@ Parameter is QUERY
sub enter_postcode_text { '' }
-=head2 all_reports_style
-
-Return the type of problem information to display on the all reports
-pages for councils. Can be either simple or detailed.
-
-=cut
-
-sub all_reports_style { return 'simple'; }
-
=head2 set_lang_and_domain
my $set_lang = $cobrand->set_lang_and_domain( $lang, $unicode, $dir )
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index 33e071b66..65507b1a1 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -10,8 +10,6 @@ sub admin_base_url {
return 'https://secure.mysociety.org/admin/bci/';
}
-sub all_reports_style { return 'detailed'; }
-
sub allow_crosssell_adverts { return 1; }
1;
diff --git a/templates/web/default/reports/_list-entry.html b/templates/web/default/reports/_list-entry.html
new file mode 100755
index 000000000..14863c4a1
--- /dev/null
+++ b/templates/web/default/reports/_list-entry.html
@@ -0,0 +1,6 @@
+
[% problem.title | html %]
+ [% IF problem.councils > 1 %] [% loc('(sent to both)') %] [% END %]
+ [% IF c.cobrand.moniker != 'emptyhomes' %]
+ [% IF problem.councils == 0 %] [% loc('(not sent to council)') %] [% END %]
+ [% END %]
+
diff --git a/templates/web/default/reports/_rss.html b/templates/web/default/reports/_rss.html
new file mode 100644
index 000000000..9756f131d
--- /dev/null
+++ b/templates/web/default/reports/_rss.html
@@ -0,0 +1,2 @@
+
+
diff --git a/templates/web/default/reports/_ward-list.html b/templates/web/default/reports/_ward-list.html
new file mode 100755
index 000000000..e78ac7d90
--- /dev/null
+++ b/templates/web/default/reports/_ward-list.html
@@ -0,0 +1,9 @@
+[% IF location == 'before' AND children.size %]
+
[% ward_text %]
+
[% loc('Follow a ward link to view only reports within that ward.') %]
+
+[% FOR child IN children.values.sort('name') %]
+
-[% END %]
+[% INCLUDE 'reports/_ward-list.html', location = 'before' %]
@@ -53,67 +45,38 @@
[% IF council.generation_high == 10 AND c.cobrand.country == 'GB' %]
-
This council no longer exists.
-[% IF council.name.match('Penwith|Kerrier|Carrick|Restormel|Caradon|North Cornwall') %]
-Its area is now covered by Cornwall Council.
-[% ELSIF council.name.match('Durham|Easington|Sedgefield|Teesdale|Wear Valley|Derwentside|Chester le Street') %]
-Its area is now covered by Durham County Council.
-[% ELSIF council.name.match('Blyth Valley|Wansbeck|Castle Morpeth|Tynedale|Alnwick|Berwick upon Tweed') %]
-Its area is now covered by Northumberland County Council.
-[% ELSIF council.name.match('North Shropshire|Oswestry|Shrewsbury and Atcham|South Shropshire|Bridgnorth') %]
-Its area is now covered by Shropshire Council.
-[% ELSIF council.name.match('Salisbury|West Wiltshire|Kennet|North Wiltshire') %]
-Its area is now covered by Wiltshire Council.
-[% ELSIF council.name.match('Ellesmere Port and Neston|Vale Royal|Chester') %]
-Its area is now covered by Cheshire West and Chester Council.
-[% ELSIF council.name.match('Macclesfield|Congleton|Crewe and Nantwich') %]
-Its area is now covered by Cheshire East Council.
-[% ELSIF council.name.match('Mid Bedfordshire|South Bedfordshire') %]
-Its area is now covered by Central Bedfordshire Council.
-[% ELSIF council.name.match('Cheshire') %]
-Its area is now covered by Cheshire West and Chester Council or
-Cheshire East Council.
-[% ELSIF council.name.match('Bedfordshire') %]
-Its area is now covered by Bedford Borough Council or
-Central Bedfordshire Council.
-[% END %]
-
This council no longer exists.
+ [% IF council.name.match('Penwith|Kerrier|Carrick|Restormel|Caradon|North Cornwall') %]
+ Its area is now covered by Cornwall Council.
+ [% ELSIF council.name.match('Durham|Easington|Sedgefield|Teesdale|Wear Valley|Derwentside|Chester le Street') %]
+ Its area is now covered by Durham County Council.
+ [% ELSIF council.name.match('Blyth Valley|Wansbeck|Castle Morpeth|Tynedale|Alnwick|Berwick upon Tweed') %]
+ Its area is now covered by Northumberland County Council.
+ [% ELSIF council.name.match('North Shropshire|Oswestry|Shrewsbury and Atcham|South Shropshire|Bridgnorth') %]
+ Its area is now covered by Shropshire Council.
+ [% ELSIF council.name.match('Salisbury|West Wiltshire|Kennet|North Wiltshire') %]
+ Its area is now covered by Wiltshire Council.
+ [% ELSIF council.name.match('Ellesmere Port and Neston|Vale Royal|Chester') %]
+ Its area is now covered by Cheshire West and Chester Council.
+ [% ELSIF council.name.match('Macclesfield|Congleton|Crewe and Nantwich') %]
+ Its area is now covered by Cheshire East Council.
+ [% ELSIF council.name.match('Mid Bedfordshire|South Bedfordshire') %]
+ Its area is now covered by Central Bedfordshire Council.
+ [% ELSIF council.name.match('Cheshire') %]
+ Its area is now covered by Cheshire West and Chester Council or
+ Cheshire East Council.
+ [% ELSIF council.name.match('Bedfordshire') %]
+ Its area is now covered by Bedford Borough Council or
+ Central Bedfordshire Council.
+ [% END %]
+
[% ELSE %]
-
+ [% INCLUDE 'reports/_rss.html' %]
[% END %]
[% TRY %][% INCLUDE 'reports/cobrand_stats.html' %][% CATCH file %][% END %]
-[% IF c.cobrand.all_reports_style == 'detailed' AND children.size %]
-
-
[% ward_text %]
-
[% loc('Follow a ward link to view only reports within that ward.') %]
-
- [% FOR child IN children.values.sort('name') %]
-
-
-[% END %]
+[% INCLUDE 'reports/_ward-list.html', location = 'after' %]
[% IF c.cobrand.moniker == 'fixmystreet' %]
@@ -139,43 +102,8 @@ Its area is now covered by Bedford Borough Council
-[% IF c.cobrand.all_reports_style == 'detailed' %]
-
[% FOREACH problem IN problems %]
-
-[% END %]
-
-[% ELSE %]
-
-[% FOREACH problem IN problems %]
-
[% problem.title | html %]
- [% IF problem.councils > 1 %] [% loc('(sent to both)') %] [% END %]
- [% IF c.cobrand.moniker != 'emptyhomes' %]
- [% IF problem.councils == 0 %] [% loc('(not sent to council)') %] [% END %]
- [% END %]
-
-[% END %]
-
+ [% INCLUDE 'reports/_list-entry.html' %]
[% END %]
diff --git a/templates/web/fixmystreet/reports/_list-entry.html b/templates/web/fixmystreet/reports/_list-entry.html
new file mode 100755
index 000000000..b25bdf318
--- /dev/null
+++ b/templates/web/fixmystreet/reports/_list-entry.html
@@ -0,0 +1,21 @@
+
+
+[% END %]
+
--
cgit v1.2.3
From eecd3bdb3a2925631af2d447ec9e3c7b10edc298 Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Fri, 13 Jul 2012 16:02:44 +0100
Subject: Now display things are in the templates, inheritance can be tidied
up.
---
perllib/FixMyStreet/Cobrand/Barnet.pm | 7 -------
perllib/FixMyStreet/Cobrand/Bromley.pm | 4 ----
perllib/FixMyStreet/Cobrand/EmptyHomes.pm | 2 +-
3 files changed, 1 insertion(+), 12 deletions(-)
diff --git a/perllib/FixMyStreet/Cobrand/Barnet.pm b/perllib/FixMyStreet/Cobrand/Barnet.pm
index 7320edc40..0d38d30f2 100644
--- a/perllib/FixMyStreet/Cobrand/Barnet.pm
+++ b/perllib/FixMyStreet/Cobrand/Barnet.pm
@@ -1,16 +1,9 @@
package FixMyStreet::Cobrand::Barnet;
-use mro 'c3';
-use parent 'FixMyStreet::Cobrand::FixMyStreet';
use parent 'FixMyStreet::Cobrand::UKCouncils';
use strict;
use warnings;
-# As parent FixMyStreet has blank. XXX Do this better?
-sub restriction {
- return { cobrand => 'barnet' };
-}
-
sub council_id { return 2489; }
sub council_area { return 'Barnet'; }
sub council_name { return 'Barnet Council'; }
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index 62827eec1..b39f7ed5b 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -1,6 +1,4 @@
package FixMyStreet::Cobrand::Bromley;
-use mro 'c3';
-use parent 'FixMyStreet::Cobrand::FixMyStreet';
use parent 'FixMyStreet::Cobrand::UKCouncils';
use strict;
@@ -16,8 +14,6 @@ sub base_url {
return 'https://fix.bromley.gov.uk';
}
-sub admin_base_url { '' }
-
sub path_to_web_templates {
my $self = shift;
return [
diff --git a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
index a7634e565..679c49889 100644
--- a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
+++ b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
@@ -1,5 +1,5 @@
package FixMyStreet::Cobrand::EmptyHomes;
-use base 'FixMyStreet::Cobrand::FixMyStreet';
+use base 'FixMyStreet::Cobrand::UK';
use strict;
use warnings;
--
cgit v1.2.3
From 4ca9e95be61444a4b410a7eb28d597d87c36a462 Mon Sep 17 00:00:00 2001
From: Matthew Somerville
Date: Fri, 13 Jul 2012 17:07:24 +0100
Subject: Merge a few similar templates into default, brings in couple of minor
council-based improvements too.
---
templates/web/default/alert/_list.html | 100 ++++++++++++++++++++++++++
templates/web/default/alert/choose.html | 2 +-
templates/web/default/alert/index.html | 39 ++++++----
templates/web/default/alert/list.html | 106 ++--------------------------
templates/web/default/my/my.html | 6 +-
templates/web/fixmystreet/alert/_list.html | 4 +-
templates/web/fixmystreet/alert/choose.html | 14 ----
templates/web/fixmystreet/alert/index.html | 53 --------------
templates/web/fixmystreet/alert/list.html | 39 ----------
9 files changed, 140 insertions(+), 223 deletions(-)
create mode 100644 templates/web/default/alert/_list.html
delete mode 100644 templates/web/fixmystreet/alert/choose.html
delete mode 100644 templates/web/fixmystreet/alert/index.html
delete mode 100644 templates/web/fixmystreet/alert/list.html
diff --git a/templates/web/default/alert/_list.html b/templates/web/default/alert/_list.html
new file mode 100644
index 000000000..2ffcfae39
--- /dev/null
+++ b/templates/web/default/alert/_list.html
@@ -0,0 +1,100 @@
+
+
+
+
+ [% IF pretty_pc %]
+ [% tprintf( loc('Here are the types of local problem alerts for ‘%s’.'), pretty_pc ) %]
+ [% END %]
+ [% loc('Select which type of alert you\'d like and click the button for an RSS feed, or enter your email address to subscribe to an email alert.') %]
+
+ [% loc('(alternatively the RSS feed can be customised, within') %]
+ 2km / 5km / 10km / 20km)
+
+
+
+ [% IF c.cobrand.is_council %]
+ Or you can subscribe to an alert for all council problems or one based upon what ward you’re in:
+ [% ELSE %]
+ [% loc("Or you can subscribe to an alert based upon what ward or council you’re in:") %]
+ [% END %]
+
+
+ [% IF reported_to_options %]
+
+
+ [% loc('Problems within the boundary of:') %]
+
+
+ [% ELSE %]
+
+ [% END %]
+
+ [% FOREACH option IN options %]
+
+
+
+
+
+ [% END %]
+
+ [% IF reported_to_options %]
+
+ [% loc('Or problems reported to:') %]
+
+
+ [% FOREACH option IN reported_to_options %]
+
+
+
+
+
+ [% END %]
+
+
+ [% loc( 'FixMyStreet sends different categories of problem
+to the appropriate council, so problems within the boundary of a particular council
+might not match the problems sent to that council. For example, a graffiti report
+will be sent to the district council, so will appear in both of the district
+council’s alerts, but will only appear in the "Within the boundary" alert
+for the county council.' ) %]
+
+
+
+ [% END %]
+
+
+
+
+
+
+ [% loc('or') %]
+
+
+ [% UNLESS c.user_exists %]
+
+ [% loc('Your email:') %]
+
+ [% END %]
+
+
+
+
+
+
diff --git a/templates/web/default/alert/choose.html b/templates/web/default/alert/choose.html
index fad365088..312b9f520 100644
--- a/templates/web/default/alert/choose.html
+++ b/templates/web/default/alert/choose.html
@@ -4,7 +4,7 @@
[% IF possible_location_matches %]
[% loc('We found more than one match for that location. We show up to ten matches, please try a different search if yours is not here.') %]
[% END %]
diff --git a/templates/web/default/alert/index.html b/templates/web/default/alert/index.html
index 274d61780..717d365b7 100644
--- a/templates/web/default/alert/index.html
+++ b/templates/web/default/alert/index.html
@@ -1,37 +1,52 @@
-[% INCLUDE 'header.html', title => loc('Local RSS feeds and email alerts') %]
+[% INCLUDE 'header.html', title = loc('Local RSS feeds and email alerts'), bodyclass = 'twothirdswidthpage' %]
[% loc('Local RSS feeds and email alerts') %]
+[% IF c.cobrand.is_council %]
+FixMyStreet has a variety of RSS feeds and email alerts for local problems, including
+alerts for all problems within a particular ward, or all problems
+within a certain distance of a particular location.
+[% ELSE %]
[% loc('FixMyStreet has a variety of RSS feeds and email alerts for local problems, including
alerts for all problems within a particular ward or council, or all problems
within a certain distance of a particular location.') %]
+[% END %]
[% IF location_offshore %]
-
[% loc('That location does not appear to be covered by a council, perhaps it is offshore - please try somewhere more specific.') %]
+
[% loc('That location does not appear to be covered by a council, perhaps it is offshore - please try somewhere more specific.') %]
[% ELSIF location_error %]
-
[% location_error %]
+
[% location_error %]
[% ELSE %]
[% INCLUDE 'errors.html' %]
[% END %]
-
[% IF photos.size %]
-
-
[% loc('Some photos of recent reports') %]
+
+
[% END %]
diff --git a/templates/web/default/alert/list.html b/templates/web/default/alert/list.html
index 9f2bd69d0..20ebbf455 100644
--- a/templates/web/default/alert/list.html
+++ b/templates/web/default/alert/list.html
@@ -6,7 +6,7 @@
END;
%]
-[% INCLUDE 'header.html', title => title %]
+[% INCLUDE 'header.html', title = title, bodyclass = 'twothirdswidthpage' %]
[% IF pretty_pc %]
[%
@@ -19,113 +19,21 @@