aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-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
5 files changed, 97 insertions, 246 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;
+