diff options
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode/Zurich.pm | 30 | ||||
-rw-r--r-- | t/cobrand/zurich.t | 7 | ||||
-rw-r--r-- | templates/web/zurich/admin/report_edit-sdm.html | 4 | ||||
-rw-r--r-- | templates/web/zurich/admin/report_edit.html | 4 |
5 files changed, 50 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 27ea26605..d33e45fbd 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -9,6 +9,8 @@ use Scalar::Util 'blessed'; use DateTime::Format::Pg; use Try::Tiny; +use FixMyStreet::Geocode::Zurich; + use strict; use warnings; use utf8; @@ -949,6 +951,11 @@ sub admin_report_edit { } +sub admin_district_lookup { + my ($self, $row) = @_; + FixMyStreet::Geocode::Zurich::admin_district($row->local_coords); +} + sub stash_states { my ($self, $problem) = @_; my $c = $self->{c}; diff --git a/perllib/FixMyStreet/Geocode/Zurich.pm b/perllib/FixMyStreet/Geocode/Zurich.pm index 38df431c9..0b85ab7b2 100644 --- a/perllib/FixMyStreet/Geocode/Zurich.pm +++ b/perllib/FixMyStreet/Geocode/Zurich.pm @@ -24,6 +24,8 @@ sub setup_soap { # Variables for the SOAP web service my $geocoder = FixMyStreet->config('GEOCODER'); + return unless ref $geocoder eq 'HASH'; + my $url = $geocoder->{url}; my $username = $geocoder->{username}; my $password = $geocoder->{password}; @@ -49,6 +51,34 @@ sub setup_soap { $method = SOAP::Data->name('getLocation95')->attr({ xmlns => $attr }); } +sub admin_district { + my ($e, $n) = @_; + + setup_soap(); + return unless $soap; + + my $attr = 'http://ch/geoz/fixmyzuerich/service'; + my $bo = 'http://ch/geoz/fixmyzuerich/bo'; + my $method = SOAP::Data->name('getInfoByLocation')->attr({ xmlns => $attr }); + my $location = SOAP::Data->name( + 'location' => \SOAP::Data->value( + SOAP::Data->name('bo:easting', $e), + SOAP::Data->name('bo:northing', $n), + ) + )->attr({ 'xmlns:bo' => $bo }); + my $search = SOAP::Data->value($location); + my $result; + eval { + $result = $soap->call($method, $security, $search); + }; + if ($@) { + warn $@ if FixMyStreet->config('STAGING_SITE'); + return 'The geocoder appears to be down.'; + } + $result = $result->result; + return $result; +} + # string STRING CONTEXT # Looks up on Zurich web service a user-inputted location. # Returns array of (LAT, LON, ERROR), where ERROR is either undef, a string, or diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index a27f313f6..a08eb431e 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -6,6 +6,7 @@ use Email::MIME; use File::Temp; use LWP::Protocol::PSGI; use Test::LongString; +use Test::MockModule; use Path::Tiny; use t::Mock::MapItZurich; use FixMyStreet::Script::Reports; @@ -530,7 +531,13 @@ subtest 'Test publishing of final update by DM' => sub { # Quick RSS check here, while we have a report $mech->get_ok('/rss/problems'); + my $module = Test::MockModule->new('FixMyStreet::Geocode::Zurich'); + $module->mock(admin_district => sub { 'Admin district' }); + $mech->get_ok( '/admin/report_edit/' . $report->id ); + + $mech->content_contains('Admin district'); + $mech->content_lacks( 'Unbestätigt' ); # Confirmed email $mech->submit_form_ok( { with_fields => { status_update => 'FINAL UPDATE' } } ); $mech->form_with_fields( 'status_update' ); diff --git a/templates/web/zurich/admin/report_edit-sdm.html b/templates/web/zurich/admin/report_edit-sdm.html index cc69b7024..0edbedc37 100644 --- a/templates/web/zurich/admin/report_edit-sdm.html +++ b/templates/web/zurich/admin/report_edit-sdm.html @@ -36,10 +36,12 @@ [% END %] <dt class="print-only">[% loc('Reported:') %] <!-- Meldedatum --></dt> - <dd> + <dd class="screen-no-space-after"> <strong>[% PROCESS format_date this_date=problem.created %] [% problem.created.hms %]</strong> </dd> + <dd>[% c.cobrand.admin_district_lookup(problem) %]</dd> + <input type="hidden" name="latitude" id="fixmystreet.latitude" value="[% problem.latitude %]"> <input type="hidden" name="longitude" id="fixmystreet.longitude" value="[% problem.longitude %]"> diff --git a/templates/web/zurich/admin/report_edit.html b/templates/web/zurich/admin/report_edit.html index 24d80e901..38ab68ed9 100644 --- a/templates/web/zurich/admin/report_edit.html +++ b/templates/web/zurich/admin/report_edit.html @@ -55,10 +55,12 @@ [% END %] <dt class="print-only">[% loc('Reported:') %] <!-- Meldedatum --></dt> - <dd> + <dd class="screen-no-space-after"> <strong>[% PROCESS format_date this_date=problem.created %] [% problem.created.hms %]</strong> </dd> + <dd>[% c.cobrand.admin_district_lookup(problem) %]</dd> + <input type="hidden" name="latitude" id="fixmystreet.latitude" value="[% problem.latitude %]"> <input type="hidden" name="longitude" id="fixmystreet.longitude" value="[% problem.longitude %]"> |