aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2011-06-07 17:50:31 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-06-07 17:50:31 +0100
commitf128b19cf7bf0da5dd445dc39d1a09e8953fc32d (patch)
treebfe7d772ece4a5725ae8389c43452c0aa0e3bb44 /perllib/FixMyStreet/Cobrand
parentb5a218792a7bcf477c930205b6a7c341a90d3efd (diff)
Creation of new Southampton cobrand, removal of old cobrands.
Diffstat (limited to 'perllib/FixMyStreet/Cobrand')
-rw-r--r--perllib/FixMyStreet/Cobrand/Barnet.pm7
-rw-r--r--perllib/FixMyStreet/Cobrand/FiksGataMi.pm41
-rw-r--r--perllib/FixMyStreet/Cobrand/Southampton.pm83
3 files changed, 106 insertions, 25 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Barnet.pm b/perllib/FixMyStreet/Cobrand/Barnet.pm
index 26c7c0453..f68d61256 100644
--- a/perllib/FixMyStreet/Cobrand/Barnet.pm
+++ b/perllib/FixMyStreet/Cobrand/Barnet.pm
@@ -28,12 +28,11 @@ sub site_title {
sub enter_postcode_text {
my ($self) = @_;
- return 'Enter a Barnet postcode, or street name and area:';
+ return 'Enter a Barnet postcode, or street name and area';
}
sub council_check {
my ( $self, $params, $context ) = @_;
- my $q = $self->request;
my $councils;
if ( $params->{all_councils} ) {
@@ -53,8 +52,8 @@ sub council_check {
}
my $url = 'http://www.fixmystreet.com/';
$url .= 'alert' if $context eq 'alert';
- $url .= '?pc=' . URI::Escape::uri_escape( $q->param('pc') )
- if $q->param('pc');
+ $url .= '?pc=' . URI::Escape::uri_escape( $self->{request}->param('pc') )
+ if $self->{request}->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 );
diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
index a5b71e46b..4dd2ef49a 100644
--- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
+++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
@@ -62,37 +62,36 @@ sub geocoded_string_check {
}
sub remove_redundant_councils {
- my $self = shift;
- my $all_councils = shift;
+ my $self = shift;
+ my $all_councils = shift;
- # Oslo is both a kommune and a fylke, we only want to show it once
- delete $all_councils->{301} #
- if $all_councils->{3};
+ # Oslo is both a kommune and a fylke, we only want to show it once
+ delete $all_councils->{301} #
+ if $all_councils->{3};
}
sub filter_all_council_ids_list {
- my $self = shift;
- my @all_councils_ids = @_;
+ my $self = shift;
+ my @all_councils_ids = @_;
- # as above we only want to show Oslo once
- return grep { $_ != 301 } @all_councils_ids;
+ # as above we only want to show Oslo once
+ return grep { $_ != 301 } @all_councils_ids;
}
sub short_name {
- my $self = shift;
- my ($area, $info) = @_;
-
- if ($area->{name} =~ /^(Os|Nes|V\xe5ler|Sande|B\xf8|Her\xf8y)$/) {
- my $parent = $info->{$area->{parent_area}}->{name};
- return URI::Escape::uri_escape_utf8("$area->{name}, $parent");
- }
+ my $self = shift;
+ my ($area, $info) = @_;
- my $name = $area->{name};
- $name =~ s/ & / and /;
- $name = URI::Escape::uri_escape_utf8($name);
- $name =~ s/%20/+/g;
- return $name;
+ if ($area->{name} =~ /^(Os|Nes|V\xe5ler|Sande|B\xf8|Her\xf8y)$/) {
+ my $parent = $info->{$area->{parent_area}}->{name};
+ return URI::Escape::uri_escape_utf8("$area->{name}, $parent");
+ }
+ my $name = $area->{name};
+ $name =~ s/ & / and /;
+ $name = URI::Escape::uri_escape_utf8($name);
+ $name =~ s/%20/+/g;
+ return $name;
}
sub council_rss_alert_options {
diff --git a/perllib/FixMyStreet/Cobrand/Southampton.pm b/perllib/FixMyStreet/Cobrand/Southampton.pm
new file mode 100644
index 000000000..aa9945c00
--- /dev/null
+++ b/perllib/FixMyStreet/Cobrand/Southampton.pm
@@ -0,0 +1,83 @@
+package FixMyStreet::Cobrand::Southampton;
+use base 'FixMyStreet::Cobrand::Default';
+
+use strict;
+use warnings;
+
+use Carp;
+use URI::Escape;
+use mySociety::VotingArea;
+
+sub site_restriction {
+ return ( "and council='2567'", 'southampton', { council => '2567' } );
+}
+
+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;
+ if ($params->{all_councils}) {
+ $councils = $params->{all_councils};
+ } elsif (defined $params->{lat}) {
+ my $parent_types = $mySociety::VotingArea::council_parent_types;
+ $councils = mySociety::MaPit::call(
+ 'point',
+ "4326/$params->{lon},$params->{lat}",
+ type => $parent_types
+ );
+ }
+ 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->{request}->param('pc'))
+ if $self->{request}->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 disambiguate_location {
+ my ( $self, $s ) = @_;
+ $s = "ll=50.913822,-1.400493&spn=0.084628,0.15701&$s";
+ return $s;
+}
+
+sub recent_photos {
+ my ($self, $num, $lat, $lon, $dist) = @_;
+ $num = 2 if $num == 3;
+ return Problems::recent_photos( $num, $lat, $lon, $dist );
+}
+
+sub tilma_mid_point {
+ return 189;
+}
+
+1;
+