aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm40
-rw-r--r--perllib/FixMyStreet/Geocode/Bing.pm12
-rw-r--r--perllib/FixMyStreet/Map/Bromley.pm23
-rw-r--r--perllib/FixMyStreet/Map/FMS.pm13
4 files changed, 74 insertions, 14 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index 6c327d479..0273e0eda 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -46,31 +46,57 @@ sub index : Path : Args(0) {
my $council = $c->forward('check_page_allowed');
+ # Set up the data for the dropdowns
+
my $children = mySociety::MaPit::call('area/children', $council,
type => $mySociety::VotingArea::council_child_types,
);
$c->stash->{children} = $children;
+ # XXX Hmm, this is probably the best way to go
+ $c->stash->{all_councils} = { $council => { id => $council } };
+ $c->forward( '/report/new/setup_categories_and_councils' );
+
+ # See if we've had anything from the dropdowns
+
+ $c->stash->{ward} = $c->req->param('ward');
+ $c->stash->{category} = $c->req->param('category');
+ $c->stash->{q_state} = $c->req->param('state');
+
+ my %where = (
+ council => $council, # XXX This will break in a two tier council. Restriction needs looking at...
+ 'problem.state' => [ FixMyStreet::DB::Result::Problem->visible_states() ],
+ );
+ $where{areas} = { 'like', '%,' . $c->stash->{ward} . ',%' }
+ if $c->stash->{ward};
+ $where{category} = $c->stash->{category}
+ if $c->stash->{category};
+ if ( $c->stash->{q_state} eq 'fixed' ) {
+ $where{'problem.state'} = [ FixMyStreet::DB::Result::Problem->fixed_states() ];
+ } elsif ( $c->stash->{q_state} ) {
+ $where{'problem.state'} = $c->stash->{q_state}
+ }
+
my %counts;
my $t = DateTime->today;
$counts{wtd} = $c->forward( 'updates_search', [ {
- council => $council,
+ %where,
'me.confirmed' => { '>=', $t->subtract( days => $t->dow - 1 )
} } ] );
$counts{week} = $c->forward( 'updates_search', [ {
- council => $council,
+ %where,
'me.confirmed' => { '>=', DateTime->now->subtract( weeks => 1 )
} } ] );
$counts{weeks} = $c->forward( 'updates_search', [ {
- council => $council,
+ %where,
'me.confirmed' => { '>=', DateTime->now->subtract( weeks => 4 )
} } ] );
$counts{ytd} = $c->forward( 'updates_search', [ {
- council => $council,
+ %where,
'me.confirmed' => { '>=', DateTime->today->set( day => 1, month => 1 )
} } ] );
@@ -102,9 +128,9 @@ sub updates_search : Private {
{ %$params, mark_fixed => 1 }, { join => 'problem' }
)->count;
- $counts{total} = $c->cobrand->problems->search(
- { %$params, state => [ FixMyStreet::DB::Result::Problem::visible_states() ] }
- )->count;
+ $params->{state} = $params->{'problem.state'};
+ delete $params->{'problem.state'};
+ $counts{total} = $c->cobrand->problems->search( $params )->count;
return \%counts;
}
diff --git a/perllib/FixMyStreet/Geocode/Bing.pm b/perllib/FixMyStreet/Geocode/Bing.pm
index 4ba00dbfe..0a7fc38dc 100644
--- a/perllib/FixMyStreet/Geocode/Bing.pm
+++ b/perllib/FixMyStreet/Geocode/Bing.pm
@@ -44,8 +44,6 @@ sub string {
if (!$js) {
return { error => _('Sorry, we could not parse that location. Please try again.') };
- } elsif ($js =~ /BT\d/ && $params->{bing_country} eq 'United Kingdom') {
- return { error => _("We do not currently cover Northern Ireland, I'm afraid.") };
}
$js = JSON->new->utf8->allow_nonref->decode($js);
@@ -54,11 +52,15 @@ sub string {
}
my $results = $js->{resourceSets}->[0]->{resources};
- my ( $error, @valid_locations, $latitude, $longitude );
+ my ( $error, @valid_locations, $latitude, $longitude, $ni );
foreach (@$results) {
my $address = $_->{name};
next unless $_->{address}->{countryRegion} eq $params->{bing_country};
+ if ($params->{bing_country} eq 'United Kingdom' && $_->{address}{adminDistrict} eq 'Northern Ireland') {
+ $ni = 1;
+ next;
+ }
# Getting duplicate, yet different, results from Bing sometimes
next if @valid_locations
@@ -73,6 +75,10 @@ sub string {
push (@valid_locations, $_);
}
+ if ($ni && !scalar @valid_locations) {
+ return { error => _("We do not currently cover Northern Ireland, I'm afraid.") };
+ }
+
return { latitude => $latitude, longitude => $longitude } if scalar @valid_locations == 1;
return { error => $error };
}
diff --git a/perllib/FixMyStreet/Map/Bromley.pm b/perllib/FixMyStreet/Map/Bromley.pm
new file mode 100644
index 000000000..6d9dfa742
--- /dev/null
+++ b/perllib/FixMyStreet/Map/Bromley.pm
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+#
+# FixMyStreet:Map::Bromley
+# Bromley have slightly different tiles, with trees etc.
+#
+# Copyright (c) 2012 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+
+package FixMyStreet::Map::Bromley;
+use base 'FixMyStreet::Map::FMS';
+
+use strict;
+
+sub map_type {
+ my $self = shift;
+ return '"' . $self->map_tile_base . '"';
+}
+
+sub map_tile_base {
+ return "tilma.mysociety.org/bromley";
+}
+
+1;
diff --git a/perllib/FixMyStreet/Map/FMS.pm b/perllib/FixMyStreet/Map/FMS.pm
index 24842c861..0ea4af4c1 100644
--- a/perllib/FixMyStreet/Map/FMS.pm
+++ b/perllib/FixMyStreet/Map/FMS.pm
@@ -37,14 +37,19 @@ sub get_quadkey {
return $key;
}
+sub map_tile_base {
+ "tilma.mysociety.org/sv";
+}
+
sub map_tiles {
my ($self, $x, $y, $z) = @_;
if ($z >= 16) {
+ my $tile_base = $self->map_tile_base;
return [
- "http://a.tilma.mysociety.org/sv/$z/" . ($x-1) . "/" . ($y-1) . ".png",
- "http://b.tilma.mysociety.org/sv/$z/$x/" . ($y-1) . ".png",
- "http://c.tilma.mysociety.org/sv/$z/" . ($x-1) . "/$y.png",
- "http://tilma.mysociety.org/sv/$z/$x/$y.png",
+ "http://a.$tile_base/$z/" . ($x-1) . "/" . ($y-1) . ".png",
+ "http://b.$tile_base/$z/$x/" . ($y-1) . ".png",
+ "http://c.$tile_base/$z/" . ($x-1) . "/$y.png",
+ "http://$tile_base/$z/$x/$y.png",
];
} else {
my $url = "g=701";