aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm21
-rw-r--r--perllib/FixMyStreet/Map/OSM/MapQuest.pm33
-rw-r--r--perllib/Utils.pm2
-rw-r--r--t/utils.t25
-rw-r--r--templates/web/default/report/update.html22
-rw-r--r--templates/web/default/report/updates.html52
-rw-r--r--templates/web/fixmystreet/report/update.html28
-rw-r--r--templates/web/fixmystreet/report/updates.html36
-rw-r--r--web/js/map-OpenStreetMap.js22
9 files changed, 162 insertions, 79 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 59e3a4410..afe180c29 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -51,7 +51,7 @@ sub display : Path('') : Args(1) {
return $c->res->redirect( $c->uri_for($1), 301 );
}
- $c->forward('load_problem_or_display_error', [ $id ] );
+ $c->forward( 'load_problem_or_display_error', [ $id ] );
$c->forward( 'load_updates' );
$c->forward( 'format_problem_for_display' );
}
@@ -88,7 +88,24 @@ sub load_updates : Private {
{ order_by => 'confirmed' }
);
- $c->stash->{updates} = $updates;
+ my $questionnaires = $c->model('DB::Questionnaire')->search(
+ {
+ problem_id => $c->stash->{problem}->id,
+ whenanswered => { '!=', undef },
+ old_state => 'confirmed', new_state => 'confirmed',
+ },
+ { order_by => 'whenanswered' }
+ );
+
+ my @combined;
+ while (my $update = $updates->next) {
+ push @combined, [ $update->confirmed, $update ];
+ }
+ while (my $update = $questionnaires->next) {
+ push @combined, [ $update->whenanswered, $update ];
+ }
+ @combined = map { $_->[1] } sort { $a->[0] <=> $b->[0] } @combined;
+ $c->stash->{updates} = \@combined;
return 1;
}
diff --git a/perllib/FixMyStreet/Map/OSM/MapQuest.pm b/perllib/FixMyStreet/Map/OSM/MapQuest.pm
new file mode 100644
index 000000000..9cf6de01f
--- /dev/null
+++ b/perllib/FixMyStreet/Map/OSM/MapQuest.pm
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+#
+# FixMyStreet:Map::OSM::CycleMap
+# OSM CycleMap maps on FixMyStreet.
+#
+# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+
+package FixMyStreet::Map::OSM::MapQuest;
+use base 'FixMyStreet::Map::OSM';
+
+use strict;
+
+sub map_type {
+ return 'OpenLayers.Layer.OSM.MapQuestOpen';
+}
+
+sub map_tiles {
+ my ($self, $x, $y, $z) = @_;
+ my $tile_url = $self->base_tile_url();
+ return [
+ "http://otile1.$tile_url/$z/" . ($x - 1) . "/" . ($y - 1) . ".png",
+ "http://otile2.$tile_url/$z/$x/" . ($y - 1) . ".png",
+ "http://otile3.$tile_url/$z/" . ($x - 1) . "/$y.png",
+ "http://otile4.$tile_url/$z/$x/$y.png",
+ ];
+}
+
+sub base_tile_url {
+ return 'mqcdn.com/tiles/1.0.0/osm/';
+}
+
+1;
diff --git a/perllib/Utils.pm b/perllib/Utils.pm
index 954561a08..4e64836c6 100644
--- a/perllib/Utils.pm
+++ b/perllib/Utils.pm
@@ -190,7 +190,7 @@ sub cleanup_text {
for ($input) {
# shit -> poo
- s{\bdog\s*shit\b}{dog poo}ig;
+ s{\bdog\s*shite*?\b}{dog poo}ig;
# 'portakabin' to '[portable cabin]' (and variations)
s{\b(porta)\s*([ck]abin|loo)\b}{[$1ble $2]}ig;
diff --git a/t/utils.t b/t/utils.t
index 385c482ed..8ff9266fd 100644
--- a/t/utils.t
+++ b/t/utils.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More;
use FindBin;
use lib "$FindBin::Bin/../perllib";
@@ -39,3 +39,26 @@ foreach my $test (@convert_en_to_latlon_tests) {
[ $lat, $lon ], #
"convert ($e,$n) to ($lat,$lon)";
}
+
+my @cleanup_tests = (
+ [ 'dog shit', 'Dog poo', 'dog poo' ],
+ [ 'dog shit', 'Dog poo', 'with spaces' ],
+ [ 'dog shite', 'Dog poo', 'with extra e' ],
+ [ 'there is dog shit here', 'There is dog poo here', 'with surrounding text' ],
+ [ 'portacabin', '[portable cabin]', 'cabin' ],
+ [ 'portaloo', '[portable loo]', 'loo' ],
+ [ 'porta loo', '[portable loo]', 'with spaces' ],
+ [ ' this is a report ', 'This is a report', 'leading and trailing spaces' ],
+ [ 'This is a report ', 'This is a report', 'spaces in the middle' ],
+ [ 'I AM SHOUTING AT YOU', 'I am shouting at you', 'all shouting' ],
+ [ 'I am EMPHASISING something', 'I am EMPHASISING something', 'some shouting' ],
+ [ "This has new\n\n\nlines in it", 'This has new Lines in it', 'no new lines' ],
+);
+
+foreach my $test ( @cleanup_tests ) {
+ is Utils::cleanup_text( $test->[0]), $test->[1], $test->[2];
+}
+
+is Utils::cleanup_text( "This has new\n\n\nlines in it", { allow_multiline => 1 } ), "This has new\n\nLines in it", 'new lines allowed';
+
+done_testing();
diff --git a/templates/web/default/report/update.html b/templates/web/default/report/update.html
new file mode 100644
index 000000000..048968eae
--- /dev/null
+++ b/templates/web/default/report/update.html
@@ -0,0 +1,22 @@
+[% IF loop.first %]
+<div id="updates">
+ <h2 class="problem-update-list-header">[% loc('Updates') %]</h2>
+[% END %]
+ <div><div class="problem-update"><p><a name="update_[% update.id %]"></a><em>
+ [% INCLUDE meta_line %]
+ </em></p></div>
+[% IF NOT update.whenanswered %]
+ <div class="update-text">
+ [% add_links( update.text ) | html_para %]
+
+ [% INCLUDE 'report/photo.html' object=update %]
+
+ [% IF c.cobrand.allow_update_reporting %]
+ <p align="right">
+ <small><a rel="nofollow" class="unsuitable-problem" href="[% c.uri_for( '/contact', { id => update.problem_id, update_id => update.id } ) %]">[% loc('Offensive? Unsuitable? Tell us') %]</a></small>
+ </p>
+ [% END %]
+ </div>
+[% END %]
+ </div>
+[% '</div>' IF loop.last %]
diff --git a/templates/web/default/report/updates.html b/templates/web/default/report/updates.html
index 4fd3c75d4..374a7c570 100644
--- a/templates/web/default/report/updates.html
+++ b/templates/web/default/report/updates.html
@@ -1,36 +1,26 @@
-[% FOREACH update IN updates.all %]
-[% IF loop.first %]
-<div id="updates">
- <h2 class="problem-update-list-header">[% loc('Updates') %]</h2>
+[% FOREACH update IN updates %]
+[% INCLUDE 'report/update.html' %]
[% END %]
- <div><div class="problem-update"><p><a name="update_[% update.id %]"></a><em>
- [% IF update.anonymous || update.name == '' %]
- [% tprintf( loc( 'Posted anonymously at %s' ), prettify_epoch( update.confirmed_local.epoch ) ) -%]
- [%- ELSIF update.user.from_council %]
- [% user_name = update.user.name | html %]
- [% tprintf( loc( 'Posted by %s (<strong>%s</strong>) at %s' ), user_name, update.user.council, prettify_epoch( update.confirmed_local.epoch ) ) -%]
- [%- ELSE %]
- [% tprintf( loc( 'Posted by %s at %s' ), update.name, prettify_epoch( update.confirmed_local.epoch ) ) | html -%]
- [%- END -%]
- [%- c.cobrand.extra_update_meta_text(update) -%]
- [%- ", " _ loc( 'marked as fixed' ) IF update.mark_fixed %]
- [%- ", " _ loc( 'reopened' ) IF update.mark_open %]
- [%- ", " _ tprintf(loc( 'marked as %s' ), update.meta_problem_state) IF update.problem_state %]
- </em></p>
- </div>
+[% BLOCK meta_line %]
- <div class="update-text">
- [% add_links( update.text ) | html_para %]
+ [% IF update.whenanswered %]
+ [%# A questionnaire update, currently saying report is still open %]
+ [% tprintf( loc( 'Still open, via questionnaire, %s' ), prettify_epoch( update.whenanswered_local.epoch ) ) %]
+ [% RETURN %]
+ [% END %]
- [% INCLUDE 'report/photo.html' object=update %]
-
- [% IF c.cobrand.allow_update_reporting %]
- <p align="right">
- <small><a rel="nofollow" class="unsuitable-problem" href="[% c.uri_for( '/contact', { id => update.problem_id, update_id => update.id } ) %]">[% loc('Offensive? Unsuitable? Tell us') %]</a></small>
- </p>
- [% END %]
- </div>
- </div>
-[% '</div>' IF loop.last %]
+ [% IF update.anonymous || update.name == '' %]
+ [% tprintf( loc( 'Posted anonymously at %s' ), prettify_epoch( update.confirmed_local.epoch ) ) -%]
+ [%- ELSIF update.user.from_council %]
+ [% user_name = update.user.name | html %]
+ [% tprintf( loc( 'Posted by %s (<strong>%s</strong>) at %s' ), user_name, update.user.council, prettify_epoch( update.confirmed_local.epoch ) ) -%]
+ [%- ELSE %]
+ [% tprintf( loc( 'Posted by %s at %s' ), update.name, prettify_epoch( update.confirmed_local.epoch ) ) | html -%]
+ [%- END -%]
+ [%- c.cobrand.extra_update_meta_text(update) -%]
+ [%- ", " _ loc( 'marked as fixed' ) IF update.mark_fixed %]
+ [%- ", " _ loc( 'reopened' ) IF update.mark_open %]
+ [%- ", " _ tprintf(loc( 'marked as %s' ), update.meta_problem_state) IF update.problem_state %]
[% END %]
+
diff --git a/templates/web/fixmystreet/report/update.html b/templates/web/fixmystreet/report/update.html
new file mode 100644
index 000000000..0803ac758
--- /dev/null
+++ b/templates/web/fixmystreet/report/update.html
@@ -0,0 +1,28 @@
+[% IF loop.first %]
+<section class="full-width">
+ <h4 class="static-with-rule">[% loc('Updates') %]</h4>
+ <ul class="issue-list">
+[% END %]
+ <li>
+ <div class="update-wrap">
+ [% IF update.whenanswered %]
+ <div class="update-text">
+ <p class="meta-2"> [% INCLUDE meta_line %] </p>
+ </div>
+ [% ELSE %]
+ <div class="update-text">
+ [% add_links( update.text ) | html_para %]
+
+ <p class="meta-2">
+ <a name="update_[% update.id %]"></a>
+ [% INCLUDE meta_line %]
+ </p>
+ </div>
+ [% INCLUDE 'report/photo.html' object=update %]
+ [% END %]
+ </div>
+ </li>
+[% IF loop.last %]
+ </ul>
+</section>
+[% END %]
diff --git a/templates/web/fixmystreet/report/updates.html b/templates/web/fixmystreet/report/updates.html
deleted file mode 100644
index 508e2aacc..000000000
--- a/templates/web/fixmystreet/report/updates.html
+++ /dev/null
@@ -1,36 +0,0 @@
-[% FOREACH update IN updates.all %]
-[% IF loop.first %]
-<section class="full-width">
- <h4 class="static-with-rule">[% loc('Updates') %]</h4>
- <ul class="issue-list">
-[% END %]
- <li>
- <div class="update-wrap">
- <div class="update-text">
- [% add_links( update.text ) | html_para %]
-
- <p class="meta-2">
- <a name="update_[% update.id %]"></a>
- [% IF update.anonymous || update.name == '' %]
- [% tprintf( loc( 'Posted anonymously at %s' ), prettify_epoch( update.confirmed_local.epoch ) ) -%]
- [%- ELSIF update.user.from_council %]
- [% user_name = update.user.name | html %]
- [% tprintf( loc( 'Posted by %s (<strong>%s</strong>) at %s' ), user_name, update.user.council, prettify_epoch( update.confirmed_local.epoch ) ) -%]
- [%- ELSE %]
- [% tprintf( loc( 'Posted by %s at %s' ), update.name, prettify_epoch( update.confirmed_local.epoch ) ) | html -%]
- [%- END -%]
- [%- c.cobrand.extra_update_meta_text(update) -%]
- [%- ", " _ loc( 'marked as fixed' ) IF update.mark_fixed %]
- [%- ", " _ loc( 'reopened' ) IF update.mark_open %]
- [%- ", " _ tprintf(loc( 'marked as %s' ), update.meta_problem_state) IF update.problem_state %]
- </p>
- </div>
-
- [% INCLUDE 'report/photo.html' object=update %]
- </div>
- </li>
-[% IF loop.last %]
- </ul>
-</section>
-[% END %]
-[% END %] \ No newline at end of file
diff --git a/web/js/map-OpenStreetMap.js b/web/js/map-OpenStreetMap.js
index 50f159635..54bf95964 100644
--- a/web/js/map-OpenStreetMap.js
+++ b/web/js/map-OpenStreetMap.js
@@ -79,14 +79,14 @@ OpenLayers.Layer.OSM.Mapnik = OpenLayers.Class(OpenLayers.Layer.OSM, {
});
/**
- * Class: OpenLayers.Layer.OSM.Osmarender
+ * Class: OpenLayers.Layer.OSM.MapQuestOpen
*
* Inherits from:
* - <OpenLayers.Layer.OSM>
*/
-OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, {
+OpenLayers.Layer.OSM.MapQuestOpen = OpenLayers.Class(OpenLayers.Layer.OSM, {
/**
- * Constructor: OpenLayers.Layer.OSM.Osmarender
+ * Constructor: OpenLayers.Layer.OSM.MapQuestOpen
*
* Parameters:
* name - {String}
@@ -94,16 +94,22 @@ OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, {
*/
initialize: function(name, options) {
var url = [
- "http://a.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
- "http://b.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png",
- "http://c.tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"
+ "http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
+ "http://otile2.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
+ "http://otile3.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png",
+ "http://otile4.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png"
];
- options = OpenLayers.Util.extend({ numZoomLevels: 18, buffer: 0 }, options);
+ options = OpenLayers.Util.extend({
+ /* Below line added to OSM's file in order to allow minimum zoom level */
+ maxResolution: 156543.0339/Math.pow(2, options.zoomOffset || 0),
+ numZoomLevels: 19,
+ buffer: 0
+ }, options);
var newArguments = [name, url, options];
OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
},
- CLASS_NAME: "OpenLayers.Layer.OSM.Osmarender"
+ CLASS_NAME: "OpenLayers.Layer.OSM.MapQuestOpen"
});
/**