aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Open311.pm7
-rw-r--r--perllib/FixMyStreet/Cobrand/Base.pm3
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm5
-rw-r--r--perllib/FixMyStreet/Cobrand/FiksGataMi.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm46
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm4
-rw-r--r--t/cobrand/zurich.t2
-rw-r--r--templates/web/base/open311/index.html2
8 files changed, 62 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm
index f3841acef..64b21db6b 100644
--- a/perllib/FixMyStreet/App/Controller/Open311.pm
+++ b/perllib/FixMyStreet/App/Controller/Open311.pm
@@ -252,7 +252,12 @@ sub output_requests : Private {
'interface_used' => [ $problem->service ], # Not in Open311 v2
};
- if ( $c->cobrand->moniker ne 'zurich' ) { # XXX
+ if ( $c->cobrand->moniker eq 'zurich' ) {
+ $request->{service_notice} = [
+ $problem->get_extra_metadata('public_response')
+ ];
+ }
+ else {
# FIXME Not according to Open311 v2
$request->{agency_responsible} = $problem->bodies;
}
diff --git a/perllib/FixMyStreet/Cobrand/Base.pm b/perllib/FixMyStreet/Cobrand/Base.pm
index 4941712b2..5a9842233 100644
--- a/perllib/FixMyStreet/Cobrand/Base.pm
+++ b/perllib/FixMyStreet/Cobrand/Base.pm
@@ -51,5 +51,8 @@ sub is_default {
return $self->moniker eq 'default';
}
+# NB: this Base class is for 'meta' features. To add base methods for all cobrands,
+# you may want to look at FMS::Cobrand::Default instead!
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index fa3d856bc..abf5d4fb5 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -898,5 +898,10 @@ sub get_country_for_ip_address {
return 0;
}
+sub jurisdiction_id_example {
+ my $self = shift;
+ return $self->moniker;
+}
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
index 34cb2f719..7b175f371 100644
--- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
+++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
@@ -223,4 +223,8 @@ sub reports_body_check {
}
}
+sub jurisdiction_id_example {
+ 'fiksgatami.no';
+}
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 8d7424328..100349efb 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -735,25 +735,55 @@ sub admin_stats {
'latitude', 'longitude',
'cobrand', 'category',
'state', 'user_id',
- 'external_body'
- ]
+ 'external_body',
+ 'title', 'detail',
+ 'photo',
+ 'whensent', 'lastupdate',
+ 'service',
+ 'extra',
+ ],
}
);
- my $body = "ID,Created,E,N,Category,Status,UserID,External Body\n";
+ my $body = "Report ID,Created,Sent to Agency,Last Updated,E,N,Category,Status,UserID,External Body,Title,Detail,Media URL,Interface Used,Council Response\n";
+ require Text::CSV;
+ my $csv = Text::CSV->new({ binary => 1 });
while ( my $report = $problems->next ) {
my $external_body;
my $body_name = "";
if ( $external_body = $report->body($c) ) {
- $body_name = $external_body->name;
+ $body_name = $external_body->name || '[Unknown body]';
}
- $body .= join( ',',
- $report->id, $report->created,
+
+ my $detail = $report->detail;
+ my $public_response = $report->get_extra_metadata('public_response') || '';
+
+ # replace newlines with HTML <br/> element
+ $detail =~ s{\r?\n}{ <br/> }g;
+ $public_response =~ s{\r?\n}{ <br/> }g;
+
+ my @columns = (
+ $report->id,
+ $report->created,
+ $report->whensent,
+ $report->lastupdate,
$report->local_coords, $report->category,
$report->state, $report->user_id,
- "\"$body_name\"" )
- . "\n";
+ $body_name,
+ $report->title,
+ $detail,
+ $c->cobrand->base_url . $report->get_photo_params->{url},
+ $report->service || 'Web interface',
+ $public_response,
+ );
+ if ($csv->combine(@columns)) {
+ $body .= $csv->string . "\n";
+ }
+ else {
+ $body .= sprintf "{{error emitting CSV line: %s}}\n", $csv->error_diag;
+ }
}
$c->res->content_type('text/csv; charset=utf-8');
+ $c->res->header('Content-Disposition' => 'attachment; filename=stats.csv');
$c->res->body($body);
}
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 93dc16811..bfe87009d 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -681,6 +681,10 @@ sub local_coords {
my ($x, $y) = Geo::Coordinates::CH1903::from_latlon($self->latitude, $self->longitude);
return ( int($x+0.5), int($y+0.5) );
}
+ else {
+ # return a dummy value until this function is implemented. useful for testing.
+ return (0, 0);
+ }
}
=head2 update_from_open311_service_request
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 31aceab28..90a92fb44 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -651,7 +651,7 @@ subtest "test stats" => sub {
my $export_count = get_export_rows_count($mech);
if (defined $export_count) {
is $export_count - $EXISTING_REPORT_COUNT, 3, 'Correct number of reports';
- $mech->content_contains(',fixed - council,');
+ $mech->content_contains('fixed - council');
$mech->content_contains(',hidden,');
}
diff --git a/templates/web/base/open311/index.html b/templates/web/base/open311/index.html
index df36bcfc9..502b1a69a 100644
--- a/templates/web/base/open311/index.html
+++ b/templates/web/base/open311/index.html
@@ -95,7 +95,7 @@ for council problem-reporting systems.</p>
<ul>
-[% jurisdiction_id = 'fiksgatami.no' %]
+[% jurisdiction_id = c.cobrand.jurisdiction_id_example %]
[% examples = [
{
url = c.cobrand.base_url _ "/open311/v2/discovery.xml?jurisdiction_id=$jurisdiction_id",