aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Alert.pm36
-rw-r--r--t/app/controller/alert.t23
-rw-r--r--templates/web/default/alert/list.html8
3 files changed, 67 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm
index 116c02a67..212ceb81a 100644
--- a/perllib/FixMyStreet/App/Controller/Alert.pm
+++ b/perllib/FixMyStreet/App/Controller/Alert.pm
@@ -140,6 +140,42 @@ sub list :Path('list') :Args(0) {
$c->stash->{rss_feed_20k} = $c->cobrand->uri($rss_feed.'/20', $c->fake_q);
}
+=head2 rss
+
+Redirects to relevant RSS feed
+
+=cut
+
+sub rss :Path('rss') :Args(0) {
+ my ($self, $c) = @_;
+ my $feed = $c->req->params->{feed};
+
+ unless ( $feed ) {
+ $c->stash->{errors} = [ _( 'Please select the feed you want' ) ];
+ $c->go( 'list' );
+ }
+
+ my $extra_params = $c->cobrand->extra_params($c->fake_q);
+ my $url;
+ if ($feed =~ /^area:(?:\d+:)+(.*)$/) {
+ (my $id = $1) =~ tr{:_}{/+};
+ $url = $c->cobrand->base_url() . '/rss/area/' . $id;
+ $c->res->redirect( $url );
+ } elsif ($feed =~ /^(?:council|ward):(?:\d+:)+(.*)$/) {
+ (my $id = $1) =~ tr{:_}{/+};
+ $url = $c->cobrand->base_url() . '/rss/reports/' . $id;
+ $c->res->redirect( $url );
+ } elsif ($feed =~ /^local:([\d\.-]+):([\d\.-]+)$/) {
+ (my $id = $1) =~ tr{:_}{/+};
+ $url = $c->cobrand->base_url() . '/rss/l/' . $id;
+ $c->res->redirect( $url );
+ } else {
+ $c->stash->{errors} = [ _( 'Illegal feed selection' ) ];
+ $c->go( 'list' );
+ }
+}
+
+
=head2 prettify_pc
This will canonicalise and prettify the postcode and stick a pretty_pc and pretty_pc_text in the stash.
diff --git a/t/app/controller/alert.t b/t/app/controller/alert.t
index 9b10070b2..f3b705650 100644
--- a/t/app/controller/alert.t
+++ b/t/app/controller/alert.t
@@ -44,4 +44,27 @@ $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');
+
+$mech->get_ok('/alert/rss?type=local&pc=ky16+8yg&rss=Give+me+an+RSS+feed&rznvy=' );
+$mech->content_contains('Please select the feed you want');
+
+$mech->get_ok('/alert/rss?feed=invalid:1000:A_Locationtype=local&pc=ky16+8yg&rss=Give+me+an+RSS+feed&rznvy=');
+$mech->content_contains('Illegal feed selection');
+
+TODO: {
+ local $TODO = 'not implemented rss feeds yet';
+
+ $mech->get_ok('/alert/rss?feed=area:1000:A_Location');
+ $mech->uri->path('/rss/area/A+Location');
+
+ $mech->get_ok('/alert/rss?feed=area:1000:1001:A_Location:Diff_Location');
+ $mech->uri->path('/rss/area/A+Location/Diff+Location');
+
+ $mech->get_ok('/alert/rss?feed=council:1000:A_Location');
+ $mech->uri->path('/rss/reports/A+Location');
+
+ $mech->get_ok('/alert/rss?feed=ward:1000:1001:A_Location:Diff_Location');
+ $mech->uri->path('/rss/ward/A+Location/Diff+Location');
+}
+
done_testing();
diff --git a/templates/web/default/alert/list.html b/templates/web/default/alert/list.html
index a839d58d6..3673d6db3 100644
--- a/templates/web/default/alert/list.html
+++ b/templates/web/default/alert/list.html
@@ -22,6 +22,14 @@
[% loc('Select which type of alert you\'d like and click the button for an RSS feed, or enter your email address to subscribe to an email alert') %]
</p>
+ [% IF errors %]
+ <ul class="error">
+ [% FOREACH error IN errors %]
+ <li>[% error %]</li>
+ [% END %]
+ </ul>
+ [% END %]
+
<p>
[% loc('The simplest alert is our geographic one') %]
</p>