diff options
-rw-r--r-- | conf/general.yml-example | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode/Google.pm | 28 | ||||
-rw-r--r-- | templates/web/base/admin/index.html | 19 | ||||
-rw-r--r-- | templates/web/base/admin/list_updates.html | 2 | ||||
-rw-r--r-- | templates/web/base/admin/problem_row.html | 2 | ||||
-rw-r--r-- | templates/web/base/admin/report_blocks.html | 30 | ||||
-rw-r--r-- | templates/web/base/admin/report_edit.html | 22 | ||||
-rw-r--r-- | web/js/fixmystreet.js | 9 |
9 files changed, 64 insertions, 54 deletions
diff --git a/conf/general.yml-example b/conf/general.yml-example index ee68b5cd6..f16d63c70 100644 --- a/conf/general.yml-example +++ b/conf/general.yml-example @@ -120,9 +120,7 @@ BING_MAPS_API_KEY: '' # bing_culture: <culture code, see http://msdn.microsoft.com/en-us/library/hh441729.aspx> # bing_country: <country name, only accept results that match this> # -# If using Google, you can use: -# centre: "<lat>,<lon>" -# span: "<lat span>,<lon span>" +# If using Google, you can use bounds, plus: # google_country: <.ccTLD to restrict results to> # lang: <language for results> # diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm index 013f47a29..8883bb91f 100644 --- a/perllib/FixMyStreet/App.pm +++ b/perllib/FixMyStreet/App.pm @@ -322,7 +322,7 @@ sub send_email { # create an email - will parse headers out of content my $email = Email::Simple->new($content); $email->header_set( ucfirst($_), $vars->{$_} ) - for grep { $vars->{$_} } qw( to from subject); + for grep { $vars->{$_} } qw( to from subject Reply-To); return if $c->is_abuser( $email->header('To') ); diff --git a/perllib/FixMyStreet/Geocode/Google.pm b/perllib/FixMyStreet/Geocode/Google.pm index 35fcec36f..5261bb7e4 100644 --- a/perllib/FixMyStreet/Geocode/Google.pm +++ b/perllib/FixMyStreet/Geocode/Google.pm @@ -28,34 +28,32 @@ sub string { $s = FixMyStreet::Geocode::escape($s); - my $url = 'http://maps.google.com/maps/geo?q=' . $s; - $url .= '&ll=' . $params->{centre} if $params->{centre}; - $url .= '&spn=' . $params->{span} if $params->{span}; + my $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . $s; + $url .= '&bounds=' . $params->{bounds}[0] . ',' . $params->{bounds}[1] + . '|' . $params->{bounds}[2] . ',' . $params->{bounds}[3] + if $params->{bounds}; if ($params->{google_country}) { - $url .= '&gl=' . $params->{google_country}; + $url .= '®ion=' . $params->{google_country}; } elsif ($params->{country}) { - $url .= '&gl=' . $params->{country}; + $url .= '®ion=' . $params->{country}; } - $url .= '&hl=' . $params->{lang} if $params->{lang}; + $url .= '&language=' . $params->{lang} if $params->{lang}; - my $args = 'sensor=false&key=' . FixMyStreet->config('GOOGLE_MAPS_API_KEY'); - my $js = FixMyStreet::Geocode::cache('google', $url, $args, qr/"code":6[12]0/); + my $args = 'key=' . FixMyStreet->config('GOOGLE_MAPS_API_KEY'); + my $js = FixMyStreet::Geocode::cache('google', $url, $args, qr/"status"\s*:\s*"(OVER_QUERY_LIMIT|REQUEST_DENIED|INVALID_REQUEST|UNKNOWN_ERROR)"/); if (!$js) { return { error => _('Sorry, we could not parse that location. Please try again.') }; } - if ($js->{Status}->{code} ne '200') { - return { error => _('Sorry, we could not find that location.') }; - } + return unless $js->{status} eq 'OK'; - my $results = $js->{Placemark}; + my $results = $js->{results}; my ( $error, @valid_locations, $latitude, $longitude ); foreach (@$results) { - next unless $_->{AddressDetails}->{Accuracy} >= 4; - my $address = $_->{address}; + my $address = $_->{formatted_address}; next unless $c->cobrand->geocoded_string_check( $address ); ( $longitude, $latitude ) = map { Utils::truncate_coordinate($_) } - @{ $_->{Point}->{coordinates} }; + ($_->{geometry}{location}{lat}, $_->{geometry}{location}{lng}); push (@$error, { address => $address, latitude => $latitude, diff --git a/templates/web/base/admin/index.html b/templates/web/base/admin/index.html index c9d2b8deb..a68df01d9 100644 --- a/templates/web/base/admin/index.html +++ b/templates/web/base/admin/index.html @@ -1,4 +1,5 @@ [% INCLUDE 'admin/header.html' title=loc('Summary') -%] +[% PROCESS 'admin/report_blocks.html' %] <div class="fms-admin-info fms-admin-floated"> This is the administration interface for [% PROCESS 'site-name.html' -%]. If you @@ -20,11 +21,9 @@ and to receive notices of updates. [% END %] [%- BLOCK states -%] -<h2>[% title %]</h2> - -[%- FOREACH state IN object.keys.sort %] +[%- FOREACH state IN list %] [%- '<ul>' IF loop.first %] - <li>[% object.$state %] [% state %]</li> + <li>[% object.$state %] [% state_pretty.$state %]</li> [%- "\n</ul>" IF loop.last %] [%- END %] [% END -%] @@ -44,9 +43,17 @@ and to receive notices of updates. </p> [% END -%] -[% PROCESS states title=loc('Problem breakdown by state') object=problems %] +<h2>[% loc('Problem breakdown by state') %]</h2> +[% FOREACH group IN state_groups %] +[%- '<ul>' IF loop.first %] + <li><strong>[% group.0 %]</strong> + [% PROCESS states object=problems list=group.1 %] + </li> +[%- "\n</ul>" IF loop.last %] +[%- END %] -[% PROCESS states title=loc('Update breakdown by state') object=comments %] +<h2>[% loc('Update breakdown by state') %]</h2> +[% PROCESS states object=comments list=comments.keys.sort %] [% FOREACH category IN categories %] [% IF loop.first %] diff --git a/templates/web/base/admin/list_updates.html b/templates/web/base/admin/list_updates.html index d3701bc1e..35f7adf66 100644 --- a/templates/web/base/admin/list_updates.html +++ b/templates/web/base/admin/list_updates.html @@ -34,7 +34,7 @@ <td>[% IF update.user.id == update.problem.user_id %][% loc('Yes') %][% ELSE %][% loc('No') %][% END %]</td> <td>[% IF update.user.belongs_to_body( update.problem.bodies_str ) %][% loc('Yes') %][% ELSE %][% loc('No') %][% END %]</td> <td>[% update.cobrand %]<br>[% update.cobrand_data | html %]</td> - <td>[% update.state %]<br><small> + <td>[% state_pretty.${update.state} %]<br><small> [% loc('Created:') %] [% PROCESS format_time time=update.created %] <br>[% loc('Confirmed:') %] [% PROCESS format_time time=update.confirmed %] </small></td> diff --git a/templates/web/base/admin/problem_row.html b/templates/web/base/admin/problem_row.html index 2413a6062..577e36992 100644 --- a/templates/web/base/admin/problem_row.html +++ b/templates/web/base/admin/problem_row.html @@ -30,7 +30,7 @@ [%- END -%] <br>[% problem.cobrand %]<br>[% problem.cobrand_data | html %] </td> - <td>[% problem.state %]<br><small> + <td>[% state_pretty.${problem.state} %]<br><small> [% loc('Created') %]: [% PROCESS format_time time=problem.created %] <br>[% loc('When sent') %]: [% PROCESS format_time time=problem.whensent %] [%- IF problem.is_visible %]<br>[% loc('Confirmed:' ) %] [% PROCESS format_time time=problem.confirmed %][% END -%] diff --git a/templates/web/base/admin/report_blocks.html b/templates/web/base/admin/report_blocks.html index c2cffc352..941bff821 100644 --- a/templates/web/base/admin/report_blocks.html +++ b/templates/web/base/admin/report_blocks.html @@ -1,3 +1,33 @@ +[% + +SET state_pretty = { + 'confirmed' = loc('Open') + 'investigating' = loc('Investigating') + 'planned' = loc('Planned') + 'in progress' = loc('In progress') + 'action scheduled' = loc('Action Scheduled') + 'fixed' = loc('Fixed') + 'fixed - user' = loc('Fixed - User') + 'fixed - council' = loc('Fixed - Council') + 'unable to fix' = loc('Unable to fix') + 'not responsible' = loc('Not Responsible') + 'duplicate' = loc('Duplicate') + 'closed' = loc('Closed') + 'internal referral' = loc('Internal referral') + 'hidden' = loc('Hidden') + 'partial' = loc('Partial') + 'unconfirmed' = loc('Unconfirmed') +}; + +SET state_groups = [ + [ loc('Open'), [ 'confirmed', 'investigating', 'planned', 'in progress', 'action scheduled' ] ], + [ loc('Fixed'), [ 'fixed', 'fixed - user', 'fixed - council' ] ], + [ loc('Closed'), [ 'unable to fix', 'not responsible', 'duplicate', 'closed', 'internal referral' ] ], + [ loc('Hidden'), [ 'hidden', 'partial', 'unconfirmed' ] ] +]; + +%] + [% BLOCK value_or_nbsp -%] [%- IF value %][% value | html %][% ELSE %] [% END %] [%- END %] diff --git a/templates/web/base/admin/report_edit.html b/templates/web/base/admin/report_edit.html index d488dcadc..d04a1a82b 100644 --- a/templates/web/base/admin/report_edit.html +++ b/templates/web/base/admin/report_edit.html @@ -45,28 +45,10 @@ class="admin-offsite-link">[% problem.latitude %], [% problem.longitude %]</a> <li>[% loc('Property address:') %] [% problem.extra.address | html %]</li> [% END %] <li><label class="inline" for="state">[% loc('State:') %]</label> <select name="state" id="state"> -[% FOREACH group IN [ - [ loc('Open'), [ - [ 'confirmed', loc('Open') ], [ 'investigating', loc('Investigating') ], - [ 'planned', loc('Planned') ], [ 'in progress', loc('In progress') ], - [ 'action scheduled', loc('Action Scheduled') ], - ] ], - [ loc('Fixed'), [ - [ 'fixed', loc('Fixed') ], [ 'fixed - user', loc('Fixed - User') ], - [ 'fixed - council', loc('Fixed - Council') ] - ] ], - [ loc('Closed'), [ - [ 'unable to fix', loc('Unable to fix') ], [ 'not responsible', loc('Not Responsible') ], - [ 'duplicate', loc('Duplicate') ], [ 'closed', loc('Closed') ], - [ 'internal referral', loc('Internal referral') ], - ] ], - [ loc('Hidden'), [ - [ 'hidden', loc('Hidden') ], [ 'partial', loc('Partial') ], [ 'unconfirmed',loc('Unconfirmed') ] - ] ] -] %] +[% FOREACH group IN state_groups %] <optgroup label="[% group.0 %]"> [% FOREACH state IN group.1 %] - <option [% 'selected ' IF state.0 == problem.state %] value="[% state.0 %]">[% state.1 %]</option> + <option [% 'selected ' IF state == problem.state %] value="[% state %]">[% state_pretty.$state %]</option> [% END %] </optgroup> [% END %] diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js index 78372d68c..7d8c940d9 100644 --- a/web/js/fixmystreet.js +++ b/web/js/fixmystreet.js @@ -177,13 +177,8 @@ $(function(){ category: $(this).val() }; - if ( typeof fixmystreet !== 'undefined' ) { - args.latitude = fixmystreet.latitude; - args.longitude = fixmystreet.longitude; - } else { - args.latitude = $('input[name="latitude"]').val(); - args.longitude = $('input[name="longitude"]').val(); - } + args.latitude = $('input[name="latitude"]').val(); + args.longitude = $('input[name="longitude"]').val(); $.getJSON('/report/new/category_extras', args, function(data) { var $category_meta = $('#category_meta'); |