aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Alert.pm78
-rw-r--r--t/app/controller/alert.t9
-rw-r--r--templates/web/default/alert/list.html25
3 files changed, 74 insertions, 38 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm
index e434c4931..c1b164a7c 100644
--- a/perllib/FixMyStreet/App/Controller/Alert.pm
+++ b/perllib/FixMyStreet/App/Controller/Alert.pm
@@ -196,6 +196,7 @@ sub prettify_pc : Private {
sub council_options : Private {
my ( $self, $c ) = @_;
+
if ( $c->config->{COUNTRY} eq 'NO' ) {
# my ($options, $options_start, $options_end);
# if (mySociety::Config::get('COUNTRY') eq 'NO') {
@@ -243,50 +244,15 @@ sub council_options : Private {
#
# }
#
-# } elsif (keys %$areas == 2) {
} elsif( keys %{ $c->stash->{ all_councils } } == 2 ) {
$c->log->debug( 'one tier council' );
-#
-# # One-tier council
-# my (@options, $council, $ward);
-# foreach (values %$areas) {
-# if ($councils{$_->{type}}) {
-# $council = $_;
-# } else {
-# $ward = $_;
-# }
-# }
-# my $council_name = $council->{name};
-# my $ward_name = $ward->{name};
-# push @options, [ 'council', $council->{id}, Page::short_name($council),
-# sprintf(_("Problems within %s"), $council_name) ];
-# push @options, [ 'ward', $council->{id}.':'.$ward->{id}, Page::short_name($council) . '/'
-# . Page::short_name($ward), sprintf(_("Problems within %s ward"), $ward_name) ];
-#
-# $options_start = "<div><ul id='rss_feed'>";
-# $options = alert_list_options($q, @options);
-# $options_end = "</ul>";
-#
-# } elsif (keys %$areas == 1) {
+ $c->forward('generate_council_and_ward_options');
} elsif( keys %{ $c->stash->{ all_councils } } == 1 ) {
$c->log->debug( 'one tier council. no ward' );
-#
-# # One-tier council, no ward
-# my (@options, $council);
-# foreach (values %$areas) {
-# $council = $_;
-# }
-# my $council_name = $council->{name};
-# push @options, [ 'council', $council->{id}, Page::short_name($council),
-# sprintf(_("Problems within %s"), $council_name) ];
-#
-# $options_start = "<div><ul id='rss_feed'>";
-# $options = alert_list_options($q, @options);
-# $options_end = "</ul>";
-#
-# } elsif (keys %$areas == 4) {
+ $c->forward('generate_council_and_ward_options');
} elsif( keys %{ $c->stash->{ all_councils } } == 4 ) {
$c->log->debug( 'two tier council' );
+ $c->stash->{two_tier_council} = 1;
#
# # Two-tier council
# my (@options, $county, $district, $c_ward, $d_ward);
@@ -342,6 +308,42 @@ sub council_options : Private {
}
}
+sub generate_council_and_ward_options : Private {
+ my ( $self, $c ) = @_;
+
+ my %councils = map { $_ => 1 } $c->cobrand->area_types();
+
+ my (@options, $council, $ward);
+ foreach (values %{ $c->stash->{all_councils} }) {
+ if ($councils{$_->{type}}) {
+ $council = $_;
+ $council->{short_name} = Page::short_name( $council );
+ ( $council->{id_name} = $council->{short_name} ) =~ tr/+/_/;
+ } else {
+ $ward = $_;
+ $ward->{short_name} = Page::short_name( $ward );
+ ( $ward->{id_name} = $ward->{short_name} ) =~ tr/+/_/;
+ }
+ }
+
+ push @options,
+ {
+ type => 'council',
+ id => sprintf( 'council:%s:%s', $council->{id}, $council->{id_name} ),
+ text => sprintf( _('Problems within %s'), $council->{name}),
+ uri => $c->cobrand->uri( '/rss/reports/' . $council->{short_name} ),
+ };
+ push @options,
+ {
+ type => 'ward',
+ id => sprintf( 'ward:%s:%s:%s:%s', $council->{id}, $ward->{id}, $council->{id_name}, $ward->{id_name} ),
+ text => sprintf( _('Problems within %s ward'), $ward->{name}),
+ uri => $c->cobrand->uri( '/rss/reports/' . $council->{short_name} . '/' . $ward->{short_name} ),
+ } if $ward;
+
+ $c->stash->{options} = \@options;
+}
+
sub choose : Private {
my ( $self, $c ) = @_;
$c->stash->{template} = 'alert/choose.html';
diff --git a/t/app/controller/alert.t b/t/app/controller/alert.t
index ceb1a3554..9b10070b2 100644
--- a/t/app/controller/alert.t
+++ b/t/app/controller/alert.t
@@ -29,10 +29,19 @@ $mech->content_contains('rss/pc/EH991SP/2');
$mech->content_contains('rss/pc/EH991SP/5');
$mech->content_contains('rss/pc/EH991SP/10');
$mech->content_contains('rss/pc/EH991SP/20');
+$mech->content_contains('Problems within City of Edinburgh');
+$mech->content_contains('Problems within City Centre ward');
+$mech->content_contains('/rss/reports/City+of+Edinburgh');
+$mech->content_contains('/rss/reports/City+of+Edinburgh/City+Centre');
+$mech->content_contains('council:2651:City_of_Edinburgh');
+$mech->content_contains('ward:2651:20728:City_of_Edinburgh:City_Centre');
$mech->get_ok('/alert/list?pc=High Street');
$mech->content_contains('We found more than one match for that location');
$mech->get_ok('/alert/list?pc=');
$mech->content_contains('hat location does not appear to be covered by a council');
+
+$mech->get_ok('/alert/list?pc=GL502PR');
+$mech->content_contains('Problems within the boundary of');
done_testing();
diff --git a/templates/web/default/alert/list.html b/templates/web/default/alert/list.html
index 0e5c660f6..3aeabf2b5 100644
--- a/templates/web/default/alert/list.html
+++ b/templates/web/default/alert/list.html
@@ -36,9 +36,34 @@
<p id="rss_local_alt">
[% loc('(alternatively the RSS feed can be customised, within') %]
<a href="[% rss_feed_2k %]">2km</a> / <a href="[% rss_feed_5k %]">5km</a> / <a href="[% rss_feed_10k %]">10km</a> / <a href="[% rss_feed_20k %]">20km</a>)
+ </p>
+
+ <p>
+ [% loc("Or you can subscribe to an alert based upon what ward or council you’re in:") %]
+ </p>
+ [% IF two_tier_council %]
+ <div id="rss_feed">
+ <p><strong>
+ [% loc('Problems within the boundary of:') %]
+ </strong></p>
+ <ul>
+ [% ELSE %]
+ <div><ul id="rss_feed">
+ [% END %]
[%# FIXME errors here %]
+ [% FOREACH option IN options %]
+ <li>
+ <input type="radio" name="feed" id="[% option.id %]" value="[% option.id %]">
+ <label for="[% option.id %]">[% option.text %]</label>
+ <a href="[% option.uri %]"><img src="/i/feed.png" width="16" height="16"
+title="RSS feed of [% option.text %]" alt="RSS feed" border="0"></a>
+ </li>
+ [% END %]
+</ul>
+</div>
+
[%# FIXME rss options here %]
<p>