aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/Cobrand/FiksGataMi.pm11
-rw-r--r--perllib/FixMyStreet/Cobrand/UK.pm13
-rw-r--r--perllib/FixMyStreet/Script/Alerts.pm5
-rw-r--r--perllib/FixMyStreet/TestMech.pm7
4 files changed, 27 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
index 306ad358a..74af9cb7d 100644
--- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
+++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
@@ -125,6 +125,9 @@ sub council_rss_alert_options {
}
}
+ my $body_kommune = FixMyStreet::DB->resultset('Body')->for_areas($kommune->{id})->first;
+ my $body_fylke = FixMyStreet::DB->resultset('Body')->for_areas($fylke->{id})->first;
+
if ( $fylke->{id} == 3 ) { # Oslo
my $short_name = $self->short_name($fylke, $all_councils);
( my $id_name = $short_name ) =~ tr/+/_/;
@@ -132,7 +135,7 @@ sub council_rss_alert_options {
push @options,
{
type => 'council',
- id => sprintf( 'council:%s:%s', $fylke->{id}, $id_name ),
+ id => sprintf( 'council:%s:%s', $body_fylke->id, $id_name ),
rss_text =>
sprintf( _('RSS feed of problems within %s'), $fylke->{name} ),
text => sprintf( _('Problems within %s'), $fylke->{name} ),
@@ -167,7 +170,7 @@ sub council_rss_alert_options {
push @reported_to_options,
{
type => 'council',
- id => sprintf( 'council:%s:%s', $kommune->{id}, $id_kommune_name ),
+ id => sprintf( 'council:%s:%s', $body_kommune->id, $id_kommune_name ),
rss_text =>
sprintf( _('RSS feed of %s'), $kommune->{name} ),
text => $kommune->{name},
@@ -175,11 +178,11 @@ sub council_rss_alert_options {
},
{
type => 'council',
- id => sprintf( 'council:%s:%s', $fylke->{id}, $id_fylke_name ),
+ id => sprintf( 'council:%s:%s', $body_fylke->id, $id_fylke_name ),
rss_text =>
sprintf( _('RSS feed of %s'), $fylke->{name} ),
text => $fylke->{name},
- uri => $c->uri_for( '/rss/reports/', $short_fylke_name ),
+ uri => $c->uri_for( '/rss/reports', $short_fylke_name ),
};
}
diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm
index f7b71b0ae..ebedf8711 100644
--- a/perllib/FixMyStreet/Cobrand/UK.pm
+++ b/perllib/FixMyStreet/Cobrand/UK.pm
@@ -190,9 +190,11 @@ sub council_rss_alert_options {
my ( @options, @reported_to_options );
if ( $num_councils == 1 or $num_councils == 2 ) {
my ($council, $ward);
+ my $body = FixMyStreet::DB->resultset('Body')->active->search({ name => { '!=' => 'TfL' } })->for_areas(keys %$all_areas)->first;
foreach (values %$all_areas) {
if ($councils{$_->{type}}) {
$council = $_;
+ $council->{id} = $body->id; # Want to use body ID, not MapIt area ID
$council->{short_name} = $self->short_name( $council );
( $council->{id_name} = $council->{short_name} ) =~ tr/+/_/;
} else {
@@ -247,6 +249,9 @@ sub council_rss_alert_options {
my $county_name = $county->{name};
my $c_ward_name = $c_ward->{name};
+ my $body_dis = FixMyStreet::DB->resultset('Body')->active->for_areas($district->{id})->first;
+ my $body_cty = FixMyStreet::DB->resultset('Body')->active->for_areas($county->{id})->first;
+
push @options, {
type => 'area',
id => sprintf( 'area:%s:%s', $district->{id}, $district->{id_name} ),
@@ -275,25 +280,25 @@ sub council_rss_alert_options {
push @reported_to_options, {
type => 'council',
- id => sprintf( 'council:%s:%s', $district->{id}, $district->{id_name} ),
+ id => sprintf( 'council:%s:%s', $body_dis->id, $district->{id_name} ),
text => sprintf( _('Reports sent to %s'), $district->{name} ),
rss_text => sprintf( _('RSS feed of %s'), $district->{name}),
uri => $c->uri_for( '/rss/reports/' . $district->{short_name} ),
}, {
type => 'ward',
- id => sprintf( 'ward:%s:%s:%s:%s', $district->{id}, $d_ward->{id}, $district->{id_name}, $d_ward->{id_name} ),
+ id => sprintf( 'ward:%s:%s:%s:%s', $body_dis->id, $d_ward->{id}, $district->{id_name}, $d_ward->{id_name} ),
rss_text => sprintf( _('RSS feed of %s, within %s ward'), $district->{name}, $d_ward->{name}),
text => sprintf( _('Reports sent to %s, within %s ward'), $district->{name}, $d_ward->{name}),
uri => $c->uri_for( '/rss/reports/' . $district->{short_name} . '/' . $d_ward->{short_name} ),
}, {
type => 'council',
- id => sprintf( 'council:%s:%s', $county->{id}, $county->{id_name} ),
+ id => sprintf( 'council:%s:%s', $body_cty->id, $county->{id_name} ),
text => sprintf( _('Reports sent to %s'), $county->{name} ),
rss_text => sprintf( _('RSS feed of %s'), $county->{name}),
uri => $c->uri_for( '/rss/reports/' . $county->{short_name} ),
}, {
type => 'ward',
- id => sprintf( 'ward:%s:%s:%s:%s', $county->{id}, $c_ward->{id}, $county->{id_name}, $c_ward->{id_name} ),
+ id => sprintf( 'ward:%s:%s:%s:%s', $body_cty->id, $c_ward->{id}, $county->{id_name}, $c_ward->{id_name} ),
rss_text => sprintf( _('RSS feed of %s, within %s ward'), $county->{name}, $c_ward->{name}),
text => sprintf( _('Reports sent to %s, within %s ward'), $county->{name}, $c_ward->{name}),
uri => $c->uri_for( '/rss/reports/' . $county->{short_name} . '/' . $c_ward->{short_name} ),
diff --git a/perllib/FixMyStreet/Script/Alerts.pm b/perllib/FixMyStreet/Script/Alerts.pm
index 4b5641f9e..a0c25a8fc 100644
--- a/perllib/FixMyStreet/Script/Alerts.pm
+++ b/perllib/FixMyStreet/Script/Alerts.pm
@@ -185,9 +185,12 @@ sub send() {
# Get a report object for its photo and static map
$data{report} = $schema->resultset('Problem')->find({ id => $row->{id} });
}
- if ($ref eq 'area_problems' || $ref eq 'council_problems' || $ref eq 'ward_problems') {
+ if ($ref eq 'area_problems') {
my $va_info = mySociety::MaPit::call('area', $row->{alert_parameter});
$data{area_name} = $va_info->{name};
+ } elsif ($ref eq 'council_problems' || $ref eq 'ward_problems') {
+ my $body = FixMyStreet::DB->resultset('Body')->find({ id => $row->{alert_parameter} });
+ $data{area_name} = $body->name;
}
if ($ref eq 'ward_problems') {
my $va_info = mySociety::MaPit::call('area', $row->{alert_parameter2});
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm
index c5b72a7cf..e7fc573c0 100644
--- a/perllib/FixMyStreet/TestMech.pm
+++ b/perllib/FixMyStreet/TestMech.pm
@@ -10,6 +10,7 @@ sub import {
Test::More->export_to_level(1);
}
+use Encode;
use Test::WWW::Mechanize::Catalyst 'FixMyStreet::App';
use t::Mock::MapIt;
use Test::More;
@@ -743,4 +744,10 @@ sub create_comment_for_problem {
FixMyStreet::App->model('DB::Comment')->create($params);
}
+
+sub encoded_content {
+ my $self = shift;
+ return encode_utf8($self->content);
+}
+
1;