aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-05-18 20:48:20 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-07-12 17:18:12 +0100
commitbd6ecb98fd3ad6f1602b0ea5593dea0bd96f8193 (patch)
treea1cce8ad3698756b4eae47c202d514c963bdf6ae
parente9aa5cbe89f9e37e9adf4e36e2b3a987ebb9147e (diff)
Factor code so it's only given in one place.
-rw-r--r--perllib/FixMyStreet/Cobrand/Barnet.pm81
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm17
-rw-r--r--templates/web/barnet/index.html100
3 files changed, 24 insertions, 174 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Barnet.pm b/perllib/FixMyStreet/Cobrand/Barnet.pm
index b3876a2c6..d33204521 100644
--- a/perllib/FixMyStreet/Cobrand/Barnet.pm
+++ b/perllib/FixMyStreet/Cobrand/Barnet.pm
@@ -1,14 +1,20 @@
package FixMyStreet::Cobrand::Barnet;
-use base 'FixMyStreet::Cobrand::UKCouncils';
+use mro 'c3';
+use parent 'FixMyStreet::Cobrand::FixMyStreet';
+use parent 'FixMyStreet::Cobrand::UKCouncils';
use strict;
use warnings;
+# As parent FixMyStreet has blank. XXX Do this better?
+sub restriction {
+ return { cobrand => 'barnet' };
+}
+
sub council_id { return 2489; }
sub council_area { return 'Barnet'; }
sub council_name { return 'Barnet Council'; }
sub council_url { return 'barnet'; }
-sub all_reports_style { return 'detailed'; }
sub path_to_web_templates {
my $self = shift;
@@ -29,77 +35,6 @@ sub disambiguate_location {
};
}
-sub generate_problem_banner {
- my ( $self, $problem ) = @_;
-
- my $banner = {};
- if ( $problem->is_open && time() - $problem->lastupdate_local->epoch > 8 * 7 * 24 * 60 * 60 )
- {
- $banner->{id} = 'unknown';
- $banner->{text} = _('Unknown');
- }
- if ($problem->is_fixed) {
- $banner->{id} = 'fixed';
- $banner->{text} = _('Fixed');
- }
- if ($problem->is_closed) {
- $banner->{id} = 'closed';
- $banner->{text} = _('Closed');
- }
-
- if ( grep { $problem->state eq $_ } ( 'investigating', 'in progress', 'planned' ) ) {
- $banner->{id} = 'progress';
- $banner->{text} = _('In progress');
- }
-
- return $banner;
-}
-
-sub council_rss_alert_options {
- my $self = shift;
- my $all_councils = shift;
- my $c = shift;
-
- my %councils = map { $_ => 1 } $self->area_types();
-
- my $num_councils = scalar keys %$all_councils;
-
- my ( @options, @reported_to_options );
- if ( $num_councils == 1 or $num_councils == 2 ) {
- my ($council, $ward);
- foreach (values %$all_councils) {
- if ($councils{$_->{type}}) {
- $council = $_;
- $council->{short_name} = $self->short_name( $council );
- ( $council->{id_name} = $council->{short_name} ) =~ tr/+/_/;
- } else {
- $ward = $_;
- $ward->{short_name} = $self->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 => 'All problems within the council.',
- rss_text => sprintf( _('RSS feed of problems within %s'), $council->{name}),
- uri => $c->uri_for( '/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} ),
- rss_text => sprintf( _('RSS feed of problems within %s ward'), $ward->{name}),
- text => sprintf( _('Problems within %s ward'), $ward->{name}),
- uri => $c->uri_for( '/rss/reports/' . $council->{short_name} . '/' . $ward->{short_name} ),
- } if $ward;
- }
-
- return ( \@options, @reported_to_options ? \@reported_to_options : undef );
-}
-
sub example_places {
return [ 'N11 1NP', 'Wood St' ];
}
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 2943c9ac4..5e8c9cb53 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -755,6 +755,13 @@ sub short_name {
}
+=item is_council
+
+For UK sub-cobrands, to specify various alternations needed for them.
+
+=cut
+sub is_council { 0; }
+
=item council_rss_alert_options
Generate a set of options for council rss alerts.
@@ -787,11 +794,18 @@ sub council_rss_alert_options {
$council->{name} = 'London Borough of Bromley'
if $council->{name} eq 'Bromley Council';
+ my $council_text;
+ if ( $c->cobrand->is_council ) {
+ $council_text = 'All problems within the council';
+ } else {
+ $council_text = sprintf( _('Problems within %s'), $council->{name});
+ }
+
push @options,
{
type => 'council',
id => sprintf( 'council:%s:%s', $council->{id}, $council->{id_name} ),
- text => sprintf( _('Problems within %s'), $council->{name}),
+ text => $council_text,
rss_text => sprintf( _('RSS feed of problems within %s'), $council->{name}),
uri => $c->uri_for( '/rss/reports/' . $council->{short_name} ),
};
@@ -803,6 +817,7 @@ sub council_rss_alert_options {
text => sprintf( _('Problems within %s ward'), $ward->{name}),
uri => $c->uri_for( '/rss/reports/' . $council->{short_name} . '/' . $ward->{short_name} ),
} if $ward;
+
} elsif ( $num_councils == 4 ) {
# # Two-tier council
my ($county, $district, $c_ward, $d_ward);
diff --git a/templates/web/barnet/index.html b/templates/web/barnet/index.html
deleted file mode 100644
index 82600625e..000000000
--- a/templates/web/barnet/index.html
+++ /dev/null
@@ -1,100 +0,0 @@
-[%# Assumes fixmystreet cobrand is using FMS map template - for bonus points preload all the right map elements. %]
-[% map_js = BLOCK %]
-<script>
-yepnope.addPrefix( 'preload', function ( resource ) {
- resource.noexec = true;
- return resource;
-});
-Modernizr.load({
- load: [
- "preload![% version('/js/OpenLayers.fixmystreet.js') %]",
- "preload![% version('/js/map-OpenLayers.js') %]",
- "preload![% version('/js/map-bing-ol.js') %]",
- "preload![% version('/js/jquery.ba-hashchange.min.js') %]"
- ]
-});
-</script>
-[% END %]
-
-[% pre_container_extra = BLOCK %]
-<div id="front-main">
- <div id="front-main-container">
- <h1>[% loc('Report, view, or discuss local problems') %]</h1>
-
- <h2>[% loc('(like graffiti, fly tipping, broken paving slabs, or street lighting)') %]</h2>
-
- [%
- question
- = c.cobrand.enter_postcode_text()
- || loc("Enter a nearby GB postcode, or street name and area");
- %]
-
- <form action="[% c.uri_for('/around') %]" method="get" name="postcodeForm" id="postcodeForm">
- <label for="pc">[% question %]:</label>
- <div>
- <input type="text" name="pc" value="" id="pc" size="10" maxlength="200" placeholder="[% tprintf(loc('e.g. ā€˜%s’ or ā€˜%s’'), c.cobrand.example_places) %]">
- <input type="submit" value="[% loc('Go') %]" id="submit">
- </div>
- </form>
- </div>
-</div>
-[% END %]
-
-[% INCLUDE 'header.html', title => '' , bodyclass => 'frontpage fullwidthpage' %]
-
-[% IF error %]
- <p class="error">[% error %]</p>
-[% END %]
-
-<div class="tablewrapper">
- <div id="front-howto">
- <h2>[% loc('How to report a problem') %]</h2>
-
- <ol class="big-numbers">
- <li>[% question %]</li>
- <li>[% loc('Locate the problem on a map of the area') %]</li>
- <li>[% loc('Enter details of the problem') %]</li>
- </ol>
-
- <section class="full-width">
- [% INCLUDE "front/stats.html" %]
- [% TRY %][% INCLUDE "front/tips.html" %][% CATCH file %][% END %]
- </section>
- </div>
-
-
- [%
- recent_photos = c.cobrand.recent_photos('front', 5);
- %]
-
- [% IF recent_photos.size %]
- <div id="front-recently">
- <h2>[% loc('Recently reported problems') %]</h2>
-
- <section class="full-width">
- <ul class="issue-list-a">
- [% FOREACH p IN recent_photos %]
- <li>
- <a href="/report/[% p.id %]">
- <div class="text">
- <h4>[% p.title | html %]</h4>
- <small>[% prettify_epoch( p.confirmed_local.epoch, 1 ) %]</small>
- </div>
- <div class="img">
- <img alt="[% p.title | html %]" title="[% p.title | html %]" height="60" width="90" src="/photo/[% p.id %].fp.jpeg">
- </div>
- </a>
- </li>
- [% END %]
- </ul>
- </section>
-
- </div>
- [% END %]
-</div>
-
-
-<!-- [% TRY %][% INCLUDE 'front/news.html' %][% CATCH file %][% END %] -->
-
-
-[% INCLUDE 'footer.html' pagefooter = 'yes' %]