aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/zurich/update_report_descriptions.sql23
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm18
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm1
-rw-r--r--perllib/FixMyStreet/Cobrand/EmptyHomes.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/UK.pm2
-rw-r--r--perllib/FixMyStreet/Script/Reports.pm2
-rw-r--r--t/app/controller/reports.t5
-rw-r--r--templates/web/base/admin/body.html2
8 files changed, 33 insertions, 22 deletions
diff --git a/bin/zurich/update_report_descriptions.sql b/bin/zurich/update_report_descriptions.sql
new file mode 100644
index 000000000..13616aeac
--- /dev/null
+++ b/bin/zurich/update_report_descriptions.sql
@@ -0,0 +1,23 @@
+-- Zurich would like to update the detail text of a whole bunch
+-- of reports on the site. They've provided a CSV file with the report id
+-- and the new detail text for the reports in question.
+-- This script applies the new details to the database
+-- from the file 'report_updates.txt'. This file must be stripped
+-- of its header row or errors will occur.
+BEGIN;
+
+CREATE TEMP TABLE report_updates (id int, detail text);
+
+\copy report_updates FROM 'report_updates.txt' WITH (FORMAT CSV)
+
+UPDATE problem
+SET detail = report_updates.detail
+FROM report_updates
+WHERE problem.id = report_updates.id
+-- Only update a report if its detail field has actually changed:
+AND problem.detail != report_updates.detail;
+
+
+DROP TABLE report_updates;
+
+COMMIT;
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 027b0d5a4..02dc4dc11 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -188,15 +188,6 @@ sub rss_area_ward : Path('/rss/area') : Args(2) {
# We're checking an area here, but this function is currently doing that.
return if $c->cobrand->reports_body_check( $c, $area );
- # If we're passed an ID number (don't think this is used anywhere, it
- # certainly shouldn't be), just look that up on mapit and redirect
- if ($area =~ /^\d+$/) {
- my $council = mySociety::MaPit::call('area', $area);
- $c->detach( 'redirect_index') if $council->{error};
- $c->stash->{body} = $council;
- $c->detach( 'redirect_body' );
- }
-
# We must now have a string to check on mapit
my $areas = mySociety::MaPit::call( 'areas', $area,
type => $c->cobrand->area_types,
@@ -296,15 +287,6 @@ sub body_check : Private {
# Oslo/ kommunes sharing a name in Norway
return if $c->cobrand->reports_body_check( $c, $q_body );
- # If we're passed an ID number (don't think this is used anywhere, it
- # certainly shouldn't be), just look that up on MaPit and redirect
- if ($q_body =~ /^\d+$/) {
- my $area = mySociety::MaPit::call('area', $q_body);
- $c->detach( 'redirect_index') if $area->{error};
- $c->stash->{body} = $area;
- $c->detach( 'redirect_body' );
- }
-
# We must now have a string to check
my @bodies = $c->model('DB::Body')->search( { name => { -like => "$q_body%" } } )->all;
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index c76ee0f7d..6ba144f0d 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -625,6 +625,7 @@ sub short_name {
my ($area) = @_;
my $name = $area->{name} || $area->name;
+ $name =~ tr{/}{_};
$name = URI::Escape::uri_escape_utf8($name);
$name =~ s/%20/+/g;
return $name;
diff --git a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
index 995c39c85..70c3c9469 100644
--- a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
+++ b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
@@ -81,7 +81,7 @@ sub short_name {
$name =~ s/ (Borough|City|District|County) Council$//;
$name =~ s/ Council$//;
$name =~ s/ & / and /;
- $name =~ s{/}{_}g;
+ $name =~ tr{/}{_};
$name = URI::Escape::uri_escape_utf8($name);
$name =~ s/%20/-/g;
return $name;
diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm
index c33b39aac..0eff48b00 100644
--- a/perllib/FixMyStreet/Cobrand/UK.pm
+++ b/perllib/FixMyStreet/Cobrand/UK.pm
@@ -109,7 +109,7 @@ sub short_name {
$name =~ s/ (Borough|City|District|County) Council$//;
$name =~ s/ Council$//;
$name =~ s/ & / and /;
- $name =~ s{/}{_}g;
+ $name =~ tr{/}{_};
$name = URI::Escape::uri_escape_utf8($name);
$name =~ s/%20/+/g;
return $name;
diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm
index 58788119a..8b1ce6759 100644
--- a/perllib/FixMyStreet/Script/Reports.pm
+++ b/perllib/FixMyStreet/Script/Reports.pm
@@ -145,7 +145,7 @@ sub send(;$) {
$skip = 1;
debug_print("skipped by sender " . $sender_info->{method} . " (might be due to previous failed attempts?)", $row->id) if $debug_mode;
} else {
- debug_print("OK, adding recipient body " . $body->id . ":" . $body->name . ", " . $body->send_method, $row->id) if $debug_mode;
+ debug_print("OK, adding recipient body " . $body->id . ":" . $body->name . ", " . $sender_info->{method}, $row->id) if $debug_mode;
push @dear, $body->name;
$reporters{ $sender }->add_body( $body, $sender_info->{config} );
}
diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t
index 02625fcc7..9b446174d 100644
--- a/t/app/controller/reports.t
+++ b/t/app/controller/reports.t
@@ -12,6 +12,7 @@ $mech->create_body_ok(2514, 'Birmingham City Council');
my $body_edin_id = $mech->create_body_ok(2651, 'City of Edinburgh Council')->id;
my $body_west_id = $mech->create_body_ok(2504, 'Westminster City Council')->id;
my $body_fife_id = $mech->create_body_ok(2649, 'Fife Council')->id;
+my $body_slash_id = $mech->create_body_ok(10000, 'Electricity/Gas Council')->id;
$mech->delete_problems_for_body( $body_west_id );
$mech->delete_problems_for_body( $body_edin_id );
@@ -122,6 +123,10 @@ is scalar @$problems, 5, 'correct number of problems displayed';
FixMyStreet::override_config {
MAPIT_URL => 'http://mapit.mysociety.org/',
}, sub {
+ $mech->get_ok('/reports');
+ $mech->follow_link_ok({ url_regex => qr{/reports/Electricity_Gas\+Council} });
+ is $mech->uri->path, '/reports/Electricity_Gas+Council', 'Path is correct';
+
$mech->get_ok('/reports/City+of+Edinburgh?t=new');
};
$problems = $mech->extract_problem_list;
diff --git a/templates/web/base/admin/body.html b/templates/web/base/admin/body.html
index b46d411c2..be84c6415 100644
--- a/templates/web/base/admin/body.html
+++ b/templates/web/base/admin/body.html
@@ -24,7 +24,7 @@
[% END %]
[% END %]
<br>
- <a href="[% c.uri_for_email( '/reports/' _ body_id ) %]" class="admin-offsite-link">[% loc('List all reported problems' ) %]</a> |
+ <a href="[% c.uri_for_email(body.url(c)) %]" class="admin-offsite-link">[% loc('List all reported problems' ) %]</a> |
<a href="[% c.uri_for( 'body', body_id, { text => 1 } ) %]">[% loc('Text only version') %]</a>
</p>