aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-01-13 18:23:04 +0000
committerMatthew Somerville <matthew@mysociety.org>2012-01-13 18:23:04 +0000
commit17bf62de05999e5afb886bb1d4530e017a2ac4af (patch)
treee2eed4d6eb2fbf044593a79df7eac30c89faca16
parent4b3418484e94307240a191d619083f7dfaec670a (diff)
Give all council cobrands a common parent to use.
-rw-r--r--perllib/FixMyStreet/Cobrand/Barnet.pm69
-rw-r--r--perllib/FixMyStreet/Cobrand/LichfieldDC.pm63
-rw-r--r--perllib/FixMyStreet/Cobrand/Reading.pm67
-rw-r--r--perllib/FixMyStreet/Cobrand/Southampton.pm69
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm75
-rw-r--r--t/00-check-config.t17
-rw-r--r--templates/web/default/alert/index.html2
-rw-r--r--web/cobrands/fixmystreet/base.scss12
-rw-r--r--web/cobrands/fixmystreet/layout.scss7
9 files changed, 106 insertions, 275 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Barnet.pm b/perllib/FixMyStreet/Cobrand/Barnet.pm
index a12fa6d06..9791b071a 100644
--- a/perllib/FixMyStreet/Cobrand/Barnet.pm
+++ b/perllib/FixMyStreet/Cobrand/Barnet.pm
@@ -1,66 +1,13 @@
package FixMyStreet::Cobrand::Barnet;
-use base 'FixMyStreet::Cobrand::Default';
+use base 'FixMyStreet::Cobrand::UKCouncils';
use strict;
use warnings;
-use Carp;
-use URI::Escape;
-use mySociety::VotingArea;
-
-sub site_restriction {
- return ( "and council='2489'", 'barnet', { council => '2489' } );
-}
-
-sub problems_clause {
- return { council => '2489' };
-}
-
-sub problems {
- my $self = shift;
- return $self->{c}->model('DB::Problem')->search( $self->problems_clause );
-}
-
-sub base_url {
- my $base_url = mySociety::Config::get('BASE_URL');
- if ( $base_url !~ /barnet/ ) {
- $base_url =~ s{http://(?!www\.)}{http://barnet.}g;
- $base_url =~ s{http://www\.}{http://barnet.}g;
- }
- return $base_url;
-}
-
-sub site_title {
- my ($self) = @_;
- return 'Barnet Council FixMyStreet';
-}
-
-sub enter_postcode_text {
- my ($self) = @_;
- return 'Enter a Barnet postcode, or street name and area';
-}
-
-sub council_check {
- my ( $self, $params, $context ) = @_;
-
- my $councils = $params->{all_councils};
- my $council_match = defined $councils->{2489};
- if ($council_match) {
- return 1;
- }
- my $url = 'http://www.fixmystreet.com/';
- $url .= 'alert' if $context eq 'alert';
- $url .= '?pc=' . URI::Escape::uri_escape( $self->{c}->req->param('pc') )
- if $self->{c}->req->param('pc');
- my $error_msg = "That location is not covered by Barnet.
-Please visit <a href=\"$url\">the main FixMyStreet site</a>.";
- return ( 0, $error_msg );
-}
-
-# All reports page only has the one council.
-sub all_councils_report {
- return 0;
-}
+sub council_id { return 2489; }
+sub council_area { return 'Barnet'; }
+sub council_name { return 'Barnet Council'; }
+sub council_url { return 'barnet'; }
sub disambiguate_location {
return {
@@ -70,11 +17,5 @@ sub disambiguate_location {
};
}
-sub recent_photos {
- my ( $self, $num, $lat, $lon, $dist ) = @_;
- $num = 2 if $num == 3;
- return $self->problems->recent_photos( $num, $lat, $lon, $dist );
-}
-
1;
diff --git a/perllib/FixMyStreet/Cobrand/LichfieldDC.pm b/perllib/FixMyStreet/Cobrand/LichfieldDC.pm
index 12882faee..91c5e10ec 100644
--- a/perllib/FixMyStreet/Cobrand/LichfieldDC.pm
+++ b/perllib/FixMyStreet/Cobrand/LichfieldDC.pm
@@ -1,13 +1,16 @@
package FixMyStreet::Cobrand::LichfieldDC;
-use base 'FixMyStreet::Cobrand::Default';
+use base 'FixMyStreet::Cobrand::UKCouncils';
use strict;
use warnings;
-use Carp;
-use URI::Escape;
-use mySociety::VotingArea;
+sub council_id { return 2434; }
+sub council_area { return 'Lichfield district'; }
+sub council_name { return 'Lichfield District Council'; }
+sub council_url { return 'lichfielddc'; }
+# Different to councils parent due to this being a two-tier council. If we get
+# more, this can be genericised in the parent.
sub site_restriction {
return ( "and council like '%2434%'", 'lichfield', { council => '2434' } );
}
@@ -16,52 +19,6 @@ sub problems_clause {
return { council => { like => '%2434%' } };
}
-sub problems {
- my $self = shift;
- return $self->{c}->model('DB::Problem')->search( $self->problems_clause );
-}
-
-sub base_url {
- my $base_url = mySociety::Config::get('BASE_URL');
- if ( $base_url !~ /lichfielddc/ ) {
- $base_url =~ s{http://(?!www\.)}{http://lichfielddc.}g;
- $base_url =~ s{http://www\.}{http://lichfielddc.}g;
- }
- return $base_url;
-}
-
-sub site_title {
- my ($self) = @_;
- return 'Lichfield District Council FixMyStreet';
-}
-
-sub enter_postcode_text {
- my ($self) = @_;
- return 'Enter a Lichfield district postcode, or street name and area';
-}
-
-sub council_check {
- my ( $self, $params, $context ) = @_;
-
- my $councils = $params->{all_councils};
- my $council_match = defined $councils->{2434};
- if ($council_match) {
- return 1;
- }
- my $url = 'http://www.fixmystreet.com/';
- $url .= 'alert' if $context eq 'alert';
- $url .= '?pc=' . URI::Escape::uri_escape( $self->{c}->req->param('pc') )
- if $self->{c}->req->param('pc');
- my $error_msg = "That location is not covered by Lichfield District Council.
-Please visit <a href=\"$url\">the main FixMyStreet site</a>.";
- return ( 0, $error_msg );
-}
-
-# All reports page only has the one council.
-sub all_councils_report {
- return 0;
-}
-
# FIXME - need to double check this is all correct
sub disambiguate_location {
return {
@@ -71,11 +28,5 @@ sub disambiguate_location {
};
}
-sub recent_photos {
- my ( $self, $num, $lat, $lon, $dist ) = @_;
- $num = 2 if $num == 3;
- return $self->problems->recent_photos( $num, $lat, $lon, $dist );
-}
-
1;
diff --git a/perllib/FixMyStreet/Cobrand/Reading.pm b/perllib/FixMyStreet/Cobrand/Reading.pm
index 8e98931fd..afc2b6ac6 100644
--- a/perllib/FixMyStreet/Cobrand/Reading.pm
+++ b/perllib/FixMyStreet/Cobrand/Reading.pm
@@ -1,66 +1,15 @@
package FixMyStreet::Cobrand::Reading;
-use base 'FixMyStreet::Cobrand::Default';
+use base 'FixMyStreet::Cobrand::UKCouncils';
use strict;
use warnings;
use Carp;
-use URI::Escape;
-use mySociety::VotingArea;
-sub site_restriction {
- return ( "and council='2596'", 'reading', { council => '2596' } );
-}
-
-sub problems_clause {
- return { council => '2596' };
-}
-
-sub problems {
- my $self = shift;
- return $self->{c}->model('DB::Problem')->search( $self->problems_clause );
-}
-
-sub base_url {
- my $base_url = mySociety::Config::get('BASE_URL');
- if ($base_url !~ /reading/) {
- $base_url =~ s{http://(?!www\.)}{http://reading.}g;
- $base_url =~ s{http://www\.}{http://reading.}g;
- }
- return $base_url;
-}
-
-sub site_title {
- my ( $self ) = @_;
- return 'Reading City Council FixMyStreet';
-}
-
-sub enter_postcode_text {
- my ( $self ) = @_;
- return 'Enter a Reading postcode, or street name and area';
-}
-
-sub council_check {
- my ( $self, $params, $context ) = @_;
-
- my $councils = $params->{all_councils};
- my $council_match = defined $councils->{2596};
- if ($council_match) {
- return 1;
- }
- my $url = 'http://www.fixmystreet.com/';
- $url .= 'alert' if $context eq 'alert';
- $url .= '?pc=' . URI::Escape::uri_escape_utf8($self->{c}->req->param('pc'))
- if $self->{c}->req->param('pc');
- my $error_msg = "That location is not covered by Reading.
-Please visit <a href=\"$url\">the main FixMyStreet site</a>.";
- return ( 0, $error_msg );
-}
-
-# All reports page only has the one council.
-sub all_councils_report {
- return 0;
-}
+sub council_id { return 2596; }
+sub council_area { return 'Reading'; }
+sub council_name { return 'Reading City Council'; }
+sub council_url { return 'reading'; }
sub disambiguate_location {
return {
@@ -71,12 +20,6 @@ sub disambiguate_location {
};
}
-sub recent_photos {
- my ($self, $num, $lat, $lon, $dist) = @_;
- $num = 2 if $num == 3;
- return $self->problems->recent_photos( $num, $lat, $lon, $dist );
-}
-
sub get_report_stats {
my $self = shift;
diff --git a/perllib/FixMyStreet/Cobrand/Southampton.pm b/perllib/FixMyStreet/Cobrand/Southampton.pm
index 213dd533b..5bb7df3b6 100644
--- a/perllib/FixMyStreet/Cobrand/Southampton.pm
+++ b/perllib/FixMyStreet/Cobrand/Southampton.pm
@@ -1,66 +1,13 @@
package FixMyStreet::Cobrand::Southampton;
-use base 'FixMyStreet::Cobrand::Default';
+use base 'FixMyStreet::Cobrand::UKCouncils';
use strict;
use warnings;
-use Carp;
-use URI::Escape;
-use mySociety::VotingArea;
-
-sub site_restriction {
- return ( "and council='2567'", 'southampton', { council => '2567' } );
-}
-
-sub problems_clause {
- return { council => '2567' };
-}
-
-sub problems {
- my $self = shift;
- return $self->{c}->model('DB::Problem')->search( $self->problems_clause );
-}
-
-sub base_url {
- my $base_url = mySociety::Config::get('BASE_URL');
- if ($base_url !~ /southampton/) {
- $base_url =~ s{http://(?!www\.)}{http://southampton.}g;
- $base_url =~ s{http://www\.}{http://southampton.}g;
- }
- return $base_url;
-}
-
-sub site_title {
- my ( $self ) = @_;
- return 'Southampton City Council FixMyStreet';
-}
-
-sub enter_postcode_text {
- my ( $self ) = @_;
- return 'Enter a Southampton postcode, or street name and area';
-}
-
-sub council_check {
- my ( $self, $params, $context ) = @_;
-
- my $councils = $params->{all_councils};
- my $council_match = defined $councils->{2567};
- if ($council_match) {
- return 1;
- }
- my $url = 'http://www.fixmystreet.com/';
- $url .= 'alert' if $context eq 'alert';
- $url .= '?pc=' . URI::Escape::uri_escape_utf8($self->{c}->req->param('pc'))
- if $self->{c}->req->param('pc');
- my $error_msg = "That location is not covered by Southampton.
-Please visit <a href=\"$url\">the main FixMyStreet site</a>.";
- return ( 0, $error_msg );
-}
-
-# All reports page only has the one council.
-sub all_councils_report {
- return 0;
-}
+sub council_id { return 2567; }
+sub council_area { return 'Southampton'; }
+sub council_name { return 'Southampton City Council'; }
+sub council_url { return 'southampton'; }
sub disambiguate_location {
return {
@@ -71,11 +18,5 @@ sub disambiguate_location {
};
}
-sub recent_photos {
- my ($self, $num, $lat, $lon, $dist) = @_;
- $num = 2 if $num == 3;
- return $self->problems->recent_photos( $num, $lat, $lon, $dist );
-}
-
1;
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
new file mode 100644
index 000000000..570c90c46
--- /dev/null
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -0,0 +1,75 @@
+package FixMyStreet::Cobrand::UKCouncils;
+use base 'FixMyStreet::Cobrand::Default';
+
+use strict;
+use warnings;
+
+use Carp;
+use URI::Escape;
+
+sub site_restriction {
+ my $self = shift;
+ return ( "and council='" . $self->council_id . "'", $self->council_url, { council => sprintf('%d', $self->council_id) } );
+}
+
+sub problems_clause {
+ my $self = shift;
+ return { council => sprintf('%d', $self->council_id) };
+}
+
+sub problems {
+ my $self = shift;
+ return $self->{c}->model('DB::Problem')->search( $self->problems_clause );
+}
+
+sub base_url {
+ my $self = shift;
+ my $base_url = mySociety::Config::get('BASE_URL');
+ my $u = $self->council_url;
+ if ( $base_url !~ /$u/ ) {
+ $base_url =~ s{http://(?!www\.)}{http://$u.}g;
+ $base_url =~ s{http://www\.}{http://$u.}g;
+ }
+ return $base_url;
+}
+
+sub site_title {
+ my ($self) = @_;
+ return $self->council_name . ' FixMyStreet';
+}
+
+sub enter_postcode_text {
+ my ($self) = @_;
+ return 'Enter a ' . $self->council_area . ' postcode, or street name and area';
+}
+
+sub council_check {
+ my ( $self, $params, $context ) = @_;
+
+ my $councils = $params->{all_councils};
+ my $council_match = defined $councils->{$self->council_id};
+ if ($council_match) {
+ return 1;
+ }
+ my $url = 'http://www.fixmystreet.com/';
+ $url .= 'alert' if $context eq 'alert';
+ $url .= '?pc=' . URI::Escape::uri_escape( $self->{c}->req->param('pc') )
+ if $self->{c}->req->param('pc');
+ my $error_msg = "That location is not covered by " . $self->council_name . ".
+Please visit <a href=\"$url\">the main FixMyStreet site</a>.";
+ return ( 0, $error_msg );
+}
+
+# All reports page only has the one council.
+sub all_councils_report {
+ return 0;
+}
+
+sub recent_photos {
+ my ( $self, $num, $lat, $lon, $dist ) = @_;
+ $num = 2 if $num == 3;
+ return $self->problems->recent_photos( $num, $lat, $lon, $dist );
+}
+
+1;
+
diff --git a/t/00-check-config.t b/t/00-check-config.t
index 7d334152c..20f0fe8cf 100644
--- a/t/00-check-config.t
+++ b/t/00-check-config.t
@@ -2,11 +2,12 @@ use strict;
use warnings;
use Test::More;
+use YAML;
use FixMyStreet;
-# check that all the fields listed in general-example are also present in
-# general - helps prevent later test failures due to un-noticed additions to the
+# check that all the fields listed in general.yml-example are also present in
+# general.yml - helps prevent later test failures due to un-noticed additions to the
# config file.
# This code will bail_out to prevent the test suite proceeding to save time if
@@ -14,10 +15,8 @@ use FixMyStreet;
# load the config file and store the contents in a readonly hash
-mySociety::Config::set_file( FixMyStreet->path_to("conf/general-example") );
-my $example_config = mySociety::Config::get_list();
-mySociety::Config::set_file( FixMyStreet->path_to("conf/general") );
-my $local_config = mySociety::Config::get_list();
+my $example_config = YAML::LoadFile( FixMyStreet->path_to("conf/general.yml-example") );
+my $local_config = YAML::LoadFile( FixMyStreet->path_to("conf/general.yml") );
# find all keys missing from each config
my @missing_from_example = find_missing( $example_config, $local_config );
@@ -25,12 +24,12 @@ my @missing_from_local = find_missing( $local_config, $example_config );
if ( @missing_from_example || @missing_from_local ) {
- fail "Missing from 'general': $_" for @missing_from_local;
- fail "Missing from 'general-example': $_" for @missing_from_example;
+ fail "Missing from 'general.yml': $_" for @missing_from_local;
+ fail "Missing from 'general.yml-example': $_" for @missing_from_example;
# bail out to prevent other tests failing due to config issues
BAIL_OUT( "Config has changed"
- . " - update your 'general' and add/remove the keys listed above" );
+ . " - update your 'general.yml' and add/remove the keys listed above" );
}
else {
pass "configs contain the same keys";
diff --git a/templates/web/default/alert/index.html b/templates/web/default/alert/index.html
index 4d63e7f34..f717ad58c 100644
--- a/templates/web/default/alert/index.html
+++ b/templates/web/default/alert/index.html
@@ -11,7 +11,7 @@ within a certain distance of a particular location.') %]
[% IF location_offshore %]
<ul class="error"><li>[% loc('That location does not appear to be covered by a council, perhaps it is offshore - please try somewhere more specific.') %]</li></ul>
[% ELSIF location_error %]
- <ul class="error"><li>[% location_error | html %]</li></ul>
+ <ul class="error"><li>[% location_error %]</li></ul>
[% ELSE %]
[% INCLUDE 'errors.html' %]
[% END %]
diff --git a/web/cobrands/fixmystreet/base.scss b/web/cobrands/fixmystreet/base.scss
index 7c53ef6e5..2eccad197 100644
--- a/web/cobrands/fixmystreet/base.scss
+++ b/web/cobrands/fixmystreet/base.scss
@@ -87,7 +87,6 @@ a:active, a:hover {
/* header is a div containing a link on all pages bar the front page, when it
* is a h1 that is not a link. It should always display the same. */
#header {
- color: $colour;
display: block;
margin: 0 0 0.5em 0;
font-size: 200%;
@@ -96,17 +95,6 @@ a:active, a:hover {
a {
text-decoration: none;
}
- a:visited {
- color: $colour;
- }
- a:hover {
- color: #200;
- }
-}
-
-/* The "My" of "FixMyStreet" in the heading is coloured differently. */
-#my {
- color: $colour_dark;
}
#meta {
diff --git a/web/cobrands/fixmystreet/layout.scss b/web/cobrands/fixmystreet/layout.scss
index 49441c006..fea728bc6 100644
--- a/web/cobrands/fixmystreet/layout.scss
+++ b/web/cobrands/fixmystreet/layout.scss
@@ -3,13 +3,6 @@
body {
margin: 7px 0 0 0;
padding: 0;
- background-attachment: fixed;
- background-color: $colour;
- background-image: -webkit-linear-gradient(top, $colour_dark, $colour 6px); /* Chrome 10+, Saf5.1+, iOS 5+ */
- background-image: -moz-linear-gradient(top, $colour_dark, $colour 6px); /* FF3.6 */
- background-image: -ms-linear-gradient(top, $colour_dark, $colour 6px); /* IE10 */
- background-image: -o-linear-gradient(top, $colour_dark, $colour 6px); /* Opera 11.10+ */
- background-image: linear-gradient(top, $colour_dark, $colour 6px);
background-color: #3c3c3c;
background-image: url(/cobrands/fixmystreet/texture.png);
}