diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-05-19 12:46:39 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-05-19 12:46:39 +0100 |
commit | d44c6e58d1efe505006a38a62b61b1045031dd49 (patch) | |
tree | b9d453c4ca0ae8b3d869d82ec4f1607ff0d7666c /perllib/FixMyStreet/Cobrand/FiksGataMi.pm | |
parent | d8534c980d298764a0956fb803e7b23f496e9a30 (diff) |
Migrate /reports page (minus RSS).
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/FiksGataMi.pm')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FiksGataMi.pm | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm index 3981192c8..aaa5f281b 100644 --- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm +++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm @@ -5,6 +5,7 @@ use strict; use warnings; use Carp; +use mySociety::MaPit; sub set_lang_and_domain { my ( $self, $lang, $unicode, $dir ) = @_; @@ -77,4 +78,36 @@ sub short_name { } +sub reports_council_check { + my ( $self, $c, $council ) = @_; + + if ($council eq 'Oslo') { + + # There are two Oslos (kommune and fylke), we only want one of them. + $c->stash->{council} = mySociety::MaPit::call('area', 3); + return 1; + + } elsif ($council =~ /,/) { + + # Some kommunes have the same name, use the fylke name to work out which. + my ($kommune, $fylke) = split /\s*,\s*/, $council; + my @area_types = $c->cobrand->area_types; + my $areas_k = mySociety::MaPit::call('areas', $kommune, type => \@area_types); + my $areas_f = mySociety::MaPit::call('areas', $fylke, type => \@area_types); + use Data::Dumper; + if (keys %$areas_f == 1) { + ($fylke) = values %$areas_f; + foreach (values %$areas_k) { + if ($_->{name} eq $kommune && $_->{parent_area} == $fylke->{id}) { + $c->stash->{council} = $_; + return 1; + } + } + } + # If we're here, we've been given a bad name. + $c->detach( 'redirect_index' ); + + } +} + 1; |