diff options
-rw-r--r-- | conf/httpd.conf | 1 | ||||
-rw-r--r-- | db/alert_types.pl | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Alert.pm | 20 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Contact.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Location.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/View/Web.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Barnet.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FiksGataMi.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode.pm | 64 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map.pm | 5 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/Original.pm | 15 | ||||
-rw-r--r-- | perllib/Page.pm | 291 | ||||
-rwxr-xr-x | t/Page.t | 25 | ||||
-rw-r--r-- | t/app/controller/auth.t | 2 | ||||
-rw-r--r-- | t/app/controller/contact.t | 16 | ||||
-rw-r--r-- | templates/web/default/auth/general.html | 2 | ||||
-rw-r--r-- | templates/web/default/report/updates.html | 11 | ||||
-rwxr-xr-x | web/test.cgi | 25 |
22 files changed, 121 insertions, 392 deletions
diff --git a/conf/httpd.conf b/conf/httpd.conf index 5bdb08fd8..ab35e29cf 100644 --- a/conf/httpd.conf +++ b/conf/httpd.conf @@ -105,7 +105,6 @@ RewriteRule ^/flickr(.*) /flickr.cgi$1 [L] # RewriteRule ^/questionnaire(.*) /questionnaire.cgi$1 [L] # RewriteRule ^/reports(.*) /reports.cgi$1 [L] # RewriteRule ^/rss(.*) /rss.cgi$1 [L] -RewriteRule ^/test(.*) /test.cgi$1 [L] RewriteRule ^/jslib(.*) /jslib$1 [L,PT] diff --git a/db/alert_types.pl b/db/alert_types.pl index 7280ae3b8..115587620 100644 --- a/db/alert_types.pl +++ b/db/alert_types.pl @@ -39,6 +39,6 @@ _('The latest problems for {{COUNCIL}} within {{WARD}} ward reported by users'), # New problems within a particular voting area (ward, constituency, whatever) - _('New problems within {{NAME}}''s boundary on FixMyStreet'), - _('The latest problems within {{NAME}}''s boundary reported by users'), + _('New problems within {{NAME}}\'s boundary on FixMyStreet'), + _('The latest problems within {{NAME}}\'s boundary reported by users'), diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm index b3067abc9..b5258ae79 100644 --- a/perllib/FixMyStreet/App/Controller/Alert.pm +++ b/perllib/FixMyStreet/App/Controller/Alert.pm @@ -86,7 +86,6 @@ sub rss : Private { $c->go('list'); } - my $extra_params = $c->cobrand->extra_params( $c->fake_q ); my $url; if ( $feed =~ /^area:(?:\d+:)+(.*)$/ ) { ( my $id = $1 ) =~ tr{:_}{/+}; @@ -363,27 +362,22 @@ sub setup_coordinate_rss_feeds : Private { my $rss_feed; if ( $c->stash->{pretty_pc_text} ) { - $rss_feed = - $c->cobrand->uri( "/rss/pc/" . $c->stash->{pretty_pc_text}, - $c->fake_q ); + $rss_feed = $c->uri_for( "/rss/pc/" . $c->stash->{pretty_pc_text} ); } else { - $rss_feed = $c->cobrand->uri( + $rss_feed = $c->uri_for( sprintf( "/rss/l/%s,%s", $c->stash->{latitude}, - $c->stash->{longitude} ), - $c->fake_q + $c->stash->{longitude} ) ); } $c->stash->{rss_feed_uri} = $rss_feed; - $c->stash->{rss_feed_2k} = $c->cobrand->uri( $rss_feed . '/2', $c->fake_q ); - $c->stash->{rss_feed_5k} = $c->cobrand->uri( $rss_feed . '/5', $c->fake_q ); - $c->stash->{rss_feed_10k} = - $c->cobrand->uri( $rss_feed . '/10', $c->fake_q ); - $c->stash->{rss_feed_20k} = - $c->cobrand->uri( $rss_feed . '/20', $c->fake_q ); + $c->stash->{rss_feed_2k} = $c->uri_for( $rss_feed . '/2' ); + $c->stash->{rss_feed_5k} = $c->uri_for( $rss_feed . '/5' ); + $c->stash->{rss_feed_10k} = $c->uri_for( $rss_feed . '/10' ); + $c->stash->{rss_feed_20k} = $c->uri_for( $rss_feed . '/20' ); return 1; } diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index 4aa37aa08..c554b2bb7 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -171,7 +171,7 @@ sub display_location : Private { # get the map features my ( $on_map_all, $on_map, $around_map, $distance ) = - FixMyStreet::Map::map_features( $c->fake_q, $latitude, $longitude, + FixMyStreet::Map::map_features( $c, $latitude, $longitude, $interval ); # copy the found reports to the stash @@ -266,7 +266,7 @@ sub ajax : Path('/ajax') { # extract the data from the map my ( $pins, $on_map, $around_map, $dist ) = - FixMyStreet::Map::map_pins( $c->fake_q, $x, $y, $sx, $sy, $interval ); + FixMyStreet::Map::map_pins( $c, $x, $y, $sx, $sy, $interval ); # render templates to get the html # my $on_map_list_html = $c->forward( diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm index b179680d0..c74597f3b 100644 --- a/perllib/FixMyStreet/App/Controller/Contact.pm +++ b/perllib/FixMyStreet/App/Controller/Contact.pm @@ -101,9 +101,9 @@ sub validate : Private { my ( %field_errors, @errors ); my %required = ( - name => _('Please give your name'), - em => _('Please give your email'), - subject => _('Please give a subject'), + name => _('Please enter your name'), + em => _('Please enter your email'), + subject => _('Please enter a subject'), message => _('Please write a message') ); @@ -113,7 +113,7 @@ sub validate : Private { } unless ( $field_errors{em} ) { - $field_errors{em} = _('Please give a valid email address') + $field_errors{em} = _('Please enter a valid email address') if !mySociety::EmailUtil::is_valid_email( $c->req->param('em') ); } diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm index 76f54e7b3..c1b119074 100644 --- a/perllib/FixMyStreet/App/Controller/Location.pm +++ b/perllib/FixMyStreet/App/Controller/Location.pm @@ -65,7 +65,7 @@ sub determine_location_from_pc : Private { $c->stash->{pc} = $pc; # for template my ( $latitude, $longitude, $error ) = - eval { FixMyStreet::Geocode::lookup( $pc, $c->fake_q ) }; + eval { FixMyStreet::Geocode::lookup( $pc, $c ) }; # Check that nothing blew up if ($@) { diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 8de909738..e0a7033b9 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -326,8 +326,6 @@ sub signup_for_alerts : Private { ); $alert->confirm(); - - $alert->update; } return 1; diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm index 63aade4c9..b5f6e341d 100644 --- a/perllib/FixMyStreet/App/View/Web.pm +++ b/perllib/FixMyStreet/App/View/Web.pm @@ -104,7 +104,7 @@ Return a pretty version of the epoch. sub prettify_epoch { my ( $self, $c, $epoch, $short_bool ) = @_; - return Page::prettify_epoch( $c->req, $epoch, $short_bool ); + return Page::prettify_epoch( $epoch, $short_bool ); } =head2 add_links diff --git a/perllib/FixMyStreet/Cobrand/Barnet.pm b/perllib/FixMyStreet/Cobrand/Barnet.pm index 2081565cf..26c7c0453 100644 --- a/perllib/FixMyStreet/Cobrand/Barnet.pm +++ b/perllib/FixMyStreet/Cobrand/Barnet.pm @@ -66,7 +66,7 @@ sub all_councils_report { } sub disambiguate_location { - my ( $self, $s, $q ) = @_; + my ( $self, $s ) = @_; $s = "ll=51.612832,-0.218169&spn=0.0563,0.09&$s"; return $s; } diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 022aff833..0613d0d6e 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -285,14 +285,6 @@ includes any disambiguating information available sub disambiguate_location { "$_[1]&gl=uk" } -=head2 prettify_epoch - -Parameter is EPOCHTIME - -=cut - -sub prettify_epoch { 0 } - =head2 form_elements Parameters are FORM_NAME, QUERY. Return HTML for any extra needed elements for diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm index 267be6958..a5b71e46b 100644 --- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm +++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm @@ -22,7 +22,7 @@ sub enter_postcode_text { # Is also adding language parameter sub disambiguate_location { - my ( $self, $s, $q ) = @_; + my ( $self, $s ) = @_; $s = "hl=no&gl=no&$s"; return $s; } diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 6a5b01906..c3b387710 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -278,7 +278,7 @@ sub meta_line { my ( $problem, $c ) = @_; my $date_time = - Page::prettify_epoch( $c->req, $problem->confirmed_local->epoch ); + Page::prettify_epoch( $problem->confirmed_local->epoch ); my $meta = ''; # FIXME Should be in cobrand diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm index cbfa3c4e7..9419a91f7 100644 --- a/perllib/FixMyStreet/Geocode.pm +++ b/perllib/FixMyStreet/Geocode.pm @@ -38,14 +38,14 @@ BEGIN { # Northern Ireland). The information in the query may be used by cobranded versions # of the site to diambiguate locations. sub lookup { - my ($s, $q) = @_; + my ($s, $c) = @_; my ($latitude, $longitude, $error); if (mySociety::Config::get('COUNTRY') eq 'GB') { if ($s =~ /^\d+$/) { $error = 'FixMyStreet is a UK-based website that currently works in England, Scotland, and Wales. Please enter either a postcode, or a Great British street name and area.'; } elsif (mySociety::PostcodeUtil::is_valid_postcode($s)) { my $location = mySociety::MaPit::call('postcode', $s); - unless ($error = Page::mapit_check_error($location)) { + unless ($error = mapit_check_error($location)) { $latitude = $location->{wgs84_lat}; $longitude = $location->{wgs84_lon}; } @@ -53,20 +53,20 @@ sub lookup { } elsif (mySociety::Config::get('COUNTRY') eq 'NO') { if ($s =~ /^\d{4}$/) { my $location = mySociety::MaPit::call('postcode', $s); - unless ($error = Page::mapit_check_error($location)) { + unless ($error = mapit_check_error($location)) { $latitude = $location->{wgs84_lat}; $longitude = $location->{wgs84_lon}; } } } unless ($error || defined $latitude) { - ($latitude, $longitude, $error) = FixMyStreet::Geocode::string($s, $q); + ($latitude, $longitude, $error) = FixMyStreet::Geocode::string($s, $c); } return ($latitude, $longitude, $error); } sub geocoded_string_coordinates { - my ($js, $q) = @_; + my ( $js ) = @_; my ($latitude, $longitude, $error); my ($accuracy) = $js =~ /"Accuracy" *: *(\d)/; if ($accuracy < 4) { @@ -89,18 +89,18 @@ sub geocoded_string_coordinates { } sub results_check { - my $q = shift; + my $c = shift; my ($error, @valid_locations); foreach (@_) { next unless /"address" *: *"(.*?)"/s; my $address = $1; - next unless Cobrand::geocoded_string_check(Page::get_cobrand($q), $address, $q); + next unless $c->cobrand->geocoded_string_check( $address ); next if $address =~ /BT\d/; push (@$error, $address); push (@valid_locations, $_); } if (scalar @valid_locations == 1) { - return geocoded_string_coordinates($valid_locations[0], $q); + return geocoded_string_coordinates( $valid_locations[0] ); } $error = _('Sorry, we could not find that location.') unless $error; return (undef, undef, $error); @@ -112,12 +112,12 @@ sub results_check { # an array of matches if there are more than one. The information in the query # may be used to disambiguate the location in cobranded versions of the site. sub string { - my ($s, $q) = @_; + my ($s, $c) = @_; $s = lc($s); $s =~ s/[^-&\w ']/ /g; $s =~ s/\s+/ /g; $s = URI::Escape::uri_escape_utf8($s); - $s = Cobrand::disambiguate_location(Page::get_cobrand($q), "q=$s", $q); + $s = $c->cobrand->disambiguate_location( "q=$s" ); $s =~ s/%20/+/g; my $url = 'http://maps.google.com/maps/geo?' . $s; my $cache_dir = mySociety::Config::get('GEO_CACHE'); @@ -151,42 +151,32 @@ sub string { } elsif ($js !~ /"code" *: *200/) { $error = _('Sorry, we could not find that location.'); } elsif ($js =~ /}, *{/) { # Multiple - return results_check($q, (split /}, *{/, $js)); + return results_check($c, (split /}, *{/, $js)); } elsif ($js =~ /BT\d/) { # Northern Ireland, hopefully $error = _("We do not cover Northern Ireland, I'm afraid, as our licence doesn't include any maps for the region."); } else { - return results_check($q, $js); + return results_check($c, $js); } return (undef, undef, $error); } -# list_choices -# Prints response if there's more than one possible result -sub list_choices { - my ($choices, $page, $q) = @_; - my $url; - my $cobrand = Page::get_cobrand($q); - my $message = _('We found more than one match for that location. We show up to ten matches, please try a different search if yours is not here.'); - my $out = '<p>' . $message . '</p>'; - my $choice_list = '<ul>'; - foreach my $choice (@$choices) { - $choice = decode_utf8($choice); - $choice =~ s/, United Kingdom//; - $choice =~ s/, UK//; - $url = Cobrand::url($cobrand, NewURL($q, -retain => 1, -url => $page, 'pc' => $choice), $q); - $url =~ s/%20/+/g; - $choice_list .= '<li><a href="' . $url . '">' . $choice . "</a></li>\n"; +sub mapit_check_error { + my $location = shift; + if ($location->{error}) { + return _('That postcode was not recognised, sorry.') if $location->{code} =~ /^4/; + return $location->{error}; } - $choice_list .= '</ul>'; - $out .= $choice_list; - my %vars = (message => $message, - choice_list => $choice_list, - header => _('More than one match'), - url_home => Cobrand::url($cobrand, '/', $q)); - my $cobrand_choice = Page::template_include('geocode-choice', $q, Page::template_root($q), %vars); - return $cobrand_choice if $cobrand_choice; - return $out; + if (mySociety::Config::get('COUNTRY') eq 'GB') { + my $island = $location->{coordsyst}; + if (!$island) { + return _("Sorry, that appears to be a Crown dependency postcode, which we don't cover."); + } + if ($island eq 'I') { + return _("We do not cover Northern Ireland, I'm afraid, as our licence doesn't include any maps for the region."); + } + } + return 0; } 1; diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm index 279f799e4..fc3f318c2 100644 --- a/perllib/FixMyStreet/Map.pm +++ b/perllib/FixMyStreet/Map.pm @@ -64,7 +64,7 @@ sub display_map { } sub map_features { - my ( $q, $lat, $lon, $interval ) = @_; + my ( $c, $lat, $lon, $interval ) = @_; # TODO - be smarter about calculating the surrounding square # use deltas that are roughly 500m in the UK - so we get a 1 sq km search box @@ -78,8 +78,7 @@ sub map_features { my $max_lon = $lon + $lon_delta; # list of problems around map can be limited, but should show all pins - my $around_limit # - = Cobrand::on_map_list_limit( Page::get_cobrand($q) ) || undef; + my $around_limit = $c->cobrand->on_map_list_limit || undef; my @around_args = ( $min_lat, $max_lat, $min_lon, $max_lon, $interval ); my $around_map_list = Problems::around_map( @around_args, $around_limit ); diff --git a/perllib/FixMyStreet/Map/Tilma/Original.pm b/perllib/FixMyStreet/Map/Tilma/Original.pm index e1ab34393..75177f3af 100644 --- a/perllib/FixMyStreet/Map/Tilma/Original.pm +++ b/perllib/FixMyStreet/Map/Tilma/Original.pm @@ -83,29 +83,28 @@ sub display_map { } sub display_pin { - my ($q, $px, $py, $col, $id, $title, $num) = @_; + my ($c, $px, $py, $col, $id, $title, $num) = @_; $num = '' if !$num || $num > 9; - my $host = Page::base_url_with_lang($q, undef); + my $host = $c->cobrand->base_url_with_lang; my %cols = (red=>'R', green=>'G', blue=>'B', purple=>'P'); my $out = '<img class="pin" src="' . $host . '/i/pin' . $cols{$col} . $num . '.gif" alt="' . _('Problem') . '" style="top:' . ($py-59) . 'px; left:' . ($px) . 'px; position: absolute;">'; return $out unless $id; - my $cobrand = Page::get_cobrand($q); - my $url = Cobrand::url($cobrand, NewURL($q, -url => '/report/' . $id), $q); + my $url = $c->uri_for( '/report/' . $id ); $out = '<a title="' . ent($title) . '" href="' . $url . '">' . $out . '</a>'; return $out; } sub map_pins { - my ($self, $q, $x, $y, $sx, $sy, $interval) = @_; + my ($self, $c, $x, $y, $sx, $sy, $interval) = @_; my $e = tile_to_os($x); my $n = tile_to_os($y); my ( $lat, $lon ) = Utils::convert_en_to_latlon( $e, $n ); my ( $around_map, $around_map_list, $nearby, $dist ) = - FixMyStreet::Map::map_features( $q, $lat, $lon, $interval ); + FixMyStreet::Map::map_features( $c, $lat, $lon, $interval ); my $pins = ''; foreach (@$around_map) { @@ -114,7 +113,7 @@ sub map_pins { my $px = os_to_px($_->{easting}, $sx); my $py = os_to_px($_->{northing}, $sy, 1); my $col = $_->{state} eq 'fixed' ? 'green' : 'red'; - $pins .= display_pin($q, $px, $py, $col, $_->{id}, $_->{title}); + $pins .= display_pin($c, $px, $py, $col, $_->{id}, $_->{title}); } foreach (@$nearby) { @@ -123,7 +122,7 @@ sub map_pins { my $px = os_to_px($_->{easting}, $sx); my $py = os_to_px($_->{northing}, $sy, 1); my $col = $_->{state} eq 'fixed' ? 'green' : 'red'; - $pins .= display_pin($q, $px, $py, $col, $_->{id}, $_->{title}); + $pins .= display_pin($c, $px, $py, $col, $_->{id}, $_->{title}); } return ($pins, $around_map_list, $nearby, $dist); diff --git a/perllib/Page.pm b/perllib/Page.pm index 27424d02e..4db72bbdb 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -14,7 +14,6 @@ package Page; use strict; use Carp; use mySociety::CGIFast qw(-no_xhtml); -use Data::Dumper; use Encode; use Error qw(:try); use File::Slurp; @@ -32,7 +31,7 @@ use Problems; use Cobrand; use mySociety::Config; -use mySociety::DBHandle qw/dbh select_all/; +use mySociety::DBHandle qw/dbh/; use mySociety::Email; use mySociety::EvEl; use mySociety::Locale; @@ -472,55 +471,52 @@ sub send_email { # send_confirmation_email TO (NAME) TEMPLATE-NAME PARAMETERS # TEMPLATE-NAME is currently one of problem, update, alert, tms -sub send_confirmation_email { - my ($q, $recipient_email_address, $name, $thing, %h) = @_; - - my $file_thing = $thing; - $file_thing = 'empty property' if $q->{site} eq 'emptyhomes' && $thing eq 'problem'; # Needs to be in English - my $template = "$file_thing-confirm"; - - send_email($q, $recipient_email_address, $name, $template, %h); - - my ($action, $worry); - if ($thing eq 'problem') { - $action = _('your problem will not be posted'); - $worry = _("we'll hang on to your problem report while you're checking your email."); - } elsif ($thing eq 'update') { - $action = _('your update will not be posted'); - $worry = _("we'll hang on to your update while you're checking your email."); - } elsif ($thing eq 'alert') { - $action = _('your alert will not be activated'); - $worry = _("we'll hang on to your alert while you're checking your email."); - } elsif ($thing eq 'tms') { - $action = 'your expression of interest will not be registered'; - $worry = "we'll hang on to your expression of interest while you're checking your email."; - } - - my $out = sprintf(_(<<EOF), $action, $worry); -<h1>Nearly Done! Now check your email...</h1> -<p>The confirmation email <strong>may</strong> take a few minutes to arrive — <em>please</em> be patient.</p> -<p>If you use web-based email or have 'junk mail' filters, you may wish to check your bulk/spam mail folders: sometimes, our messages are marked that way.</p> -<p>You must now click the link in the email we've just sent you — -if you do not, %s.</p> -<p>(Don't worry — %s)</p> -EOF - - my $cobrand = get_cobrand($q); - my %vars = ( - action => $action, - worry => $worry, - url_home => Cobrand::url($cobrand, '/', $q), - ); - my $cobrand_email = Page::template_include('check-email', $q, Page::template_root($q), %vars); - return $cobrand_email if $cobrand_email; - return $out; -} +#sub send_confirmation_email { +# my ($q, $recipient_email_address, $name, $thing, %h) = @_; +# +# my $file_thing = $thing; +# $file_thing = 'empty property' if $q->{site} eq 'emptyhomes' && $thing eq 'problem'; # Needs to be in English +# my $template = "$file_thing-confirm"; +# +# send_email($q, $recipient_email_address, $name, $template, %h); +# +# my ($action, $worry); +# if ($thing eq 'problem') { +# $action = _('your problem will not be posted'); +# $worry = _("we'll hang on to your problem report while you're checking your email."); +# } elsif ($thing eq 'update') { +# $action = _('your update will not be posted'); +# $worry = _("we'll hang on to your update while you're checking your email."); +# } elsif ($thing eq 'alert') { +# $action = _('your alert will not be activated'); +# $worry = _("we'll hang on to your alert while you're checking your email."); +# } elsif ($thing eq 'tms') { +# $action = 'your expression of interest will not be registered'; +# $worry = "we'll hang on to your expression of interest while you're checking your email."; +# } +# +# my $out = sprintf(_(<<EOF), $action, $worry); +#<h1>Nearly Done! Now check your email...</h1> +#<p>The confirmation email <strong>may</strong> take a few minutes to arrive — <em>please</em> be patient.</p> +#<p>If you use web-based email or have 'junk mail' filters, you may wish to check your bulk/spam mail folders: sometimes, our messages are marked that way.</p> +#<p>You must now click the link in the email we've just sent you — +#if you do not, %s.</p> +#<p>(Don't worry — %s)</p> +#EOF +# +# my $cobrand = get_cobrand($q); +# my %vars = ( +# action => $action, +# worry => $worry, +# url_home => Cobrand::url($cobrand, '/', $q), +# ); +# my $cobrand_email = Page::template_include('check-email', $q, Page::template_root($q), %vars); +# return $cobrand_email if $cobrand_email; +# return $out; +#} sub prettify_epoch { - my ($q, $s, $short) = @_; - my $cobrand = get_cobrand($q); - my $cobrand_datetime = Cobrand::prettify_epoch($cobrand, $s); - return $cobrand_datetime if ($cobrand_datetime); + my ($s, $short) = @_; my @s = localtime($s); my $tt = strftime('%H:%M', @s); my @t = localtime(); @@ -567,197 +563,6 @@ sub _part { } } -# sub display_problem_meta_line($$) { -# my ($q, $problem) = @_; -# my $out = ''; -# my $date_time = prettify_epoch($q, $problem->{time}); -# if ($q->{site} eq 'emptyhomes') { -# my $category = _($problem->{category}); -# utf8::decode($category); # So that Welsh to Welsh doesn't encode already-encoded UTF-8 -# if ($problem->{anonymous}) { -# $out .= sprintf(_('%s, reported anonymously at %s'), ent($category), $date_time); -# } else { -# $out .= sprintf(_('%s, reported by %s at %s'), ent($category), ent($problem->{name}), $date_time); -# } -# } else { -# if ($problem->{service} && $problem->{category} && $problem->{category} ne _('Other') && $problem->{anonymous}) { -# $out .= sprintf(_('Reported by %s in the %s category anonymously at %s'), ent($problem->{service}), ent($problem->{category}), $date_time); -# } elsif ($problem->{service} && $problem->{category} && $problem->{category} ne _('Other')) { -# $out .= sprintf(_('Reported by %s in the %s category by %s at %s'), ent($problem->{service}), ent($problem->{category}), ent($problem->{name}), $date_time); -# } elsif ($problem->{service} && $problem->{anonymous}) { -# $out .= sprintf(_('Reported by %s anonymously at %s'), ent($problem->{service}), $date_time); -# } elsif ($problem->{service}) { -# $out .= sprintf(_('Reported by %s by %s at %s'), ent($problem->{service}), ent($problem->{name}), $date_time); -# } elsif ($problem->{category} && $problem->{category} ne _('Other') && $problem->{anonymous}) { -# $out .= sprintf(_('Reported in the %s category anonymously at %s'), ent($problem->{category}), $date_time); -# } elsif ($problem->{category} && $problem->{category} ne _('Other')) { -# $out .= sprintf(_('Reported in the %s category by %s at %s'), ent($problem->{category}), ent($problem->{name}), $date_time); -# } elsif ($problem->{anonymous}) { -# $out .= sprintf(_('Reported anonymously at %s'), $date_time); -# } else { -# $out .= sprintf(_('Reported by %s at %s'), ent($problem->{name}), $date_time); -# } -# } -# my $cobrand = get_cobrand($q); -# $out .= Cobrand::extra_problem_meta_text($cobrand, $problem); -# $out .= '; ' . _('the map was not used so pin location may be inaccurate') unless ($problem->{used_map}); -# if ($problem->{council}) { -# if ($problem->{whensent}) { -# my $body; -# if ($problem->{external_body}) { -# $body = $problem->{external_body}; -# } else { -# $problem->{council} =~ s/\|.*//g; -# my @councils = split /,/, $problem->{council}; -# my $areas_info = mySociety::MaPit::call('areas', \@councils); -# $body = join(' and ', map { $areas_info->{$_}->{name} } @councils); -# } -# $out .= '<small class="council_sent_info">'; -# $out .= $q->br() . sprintf(_('Sent to %s %s later'), $body, prettify_duration($problem->{whensent}, 'minute')); -# $out .= '</small>'; -# } -# } else { -# $out .= $q->br() . $q->small(_('Not reported to council')); -# } -# return $out; -# } - -sub display_problem_detail($) { - my $problem = shift; - (my $detail = $problem->{detail}) =~ s/\r//g; - my $out = ''; - foreach (split /\n{2,}/, $detail) { - $out .= '<p>' . ent($_) . '</p>'; - } - return $out; -} - -sub display_problem_photo($$) { - my ($q, $problem) = @_; - my $cobrand = get_cobrand($q); - my $display_photos = Cobrand::allow_photo_display($cobrand); - if ($display_photos && $problem->{photo}) { - my $dims = Image::Size::html_imgsize(\$problem->{photo}); - return "<p align='center'><img alt='' $dims src='/photo?id=$problem->{id}'></p>"; - } - return ''; -} - -# Display information about problem -sub display_problem_text($$) { - my ($q, $problem) = @_; - - my $out = $q->h1(ent($problem->{title})); - $out .= '<p><em>'; - $out .= display_problem_meta_line($q, $problem); - $out .= '</em></p>'; - $out .= display_problem_detail($problem); - $out .= display_problem_photo($q, $problem); - return $out; -} - -# Display updates -sub display_problem_updates($$) { - my ($id, $q) = @_; - my $cobrand = get_cobrand($q); - my $updates = select_all( - "select id, name, extract(epoch from confirmed) as confirmed, text, - mark_fixed, mark_open, photo, cobrand - from comment where problem_id = ? and state='confirmed' - order by confirmed", $id); - my $out = ''; - if (@$updates) { - $out .= '<div id="updates">'; - $out .= '<h2 class="problem-update-list-header">' . _('Updates') . '</h2>'; - foreach my $row (@$updates) { - $out .= "<div><div class=\"problem-update\"><p><a name=\"update_$row->{id}\"></a><em>"; - if ($row->{name}) { - $out .= sprintf(_('Posted by %s at %s'), ent($row->{name}), prettify_epoch($q, $row->{confirmed})); - } else { - $out .= sprintf(_('Posted anonymously at %s'), prettify_epoch($q, $row->{confirmed})); - } - $out .= Cobrand::extra_update_meta_text($cobrand, $row); - $out .= ', ' . _('marked as fixed') if ($row->{mark_fixed}); - $out .= ', ' . _('reopened') if ($row->{mark_open}); - $out .= '</em></p>'; - - my $allow_update_reporting = Cobrand::allow_update_reporting($cobrand); - if ($allow_update_reporting) { - my $contact = '/contact?id=' . $id . ';update_id='. $row->{id}; - my $contact_url = Cobrand::url($cobrand, $contact, $q); - $out .= '<p>'; - $out .= $q->a({rel => 'nofollow', class => 'unsuitable-problem', href => $contact_url}, _('Offensive? Unsuitable? Tell us')); - $out .= '</p>'; - } - $out .= '</div>'; - $out .= '<div class="update-text">'; - my $text = $row->{text}; - $text =~ s/\r//g; - foreach (split /\n{2,}/, $text) { - $out .= '<p>' . ent($_) . '</p>'; - } - my $cobrand = get_cobrand($q); - my $display_photos = Cobrand::allow_photo_display($cobrand); - if ($display_photos && $row->{photo}) { - my $dims = Image::Size::html_imgsize(\$row->{photo}); - $out .= "<p><img alt='' $dims src='/photo?c=$row->{id}'></p>"; - } - $out .= '</div>'; - $out .= '</div>'; - } - $out .= '</div>'; - } - return $out; -} - -sub mapit_check_error { - my $location = shift; - if ($location->{error}) { - return _('That postcode was not recognised, sorry.') if $location->{code} =~ /^4/; - return $location->{error}; - } - if (mySociety::Config::get('COUNTRY') eq 'GB') { - my $island = $location->{coordsyst}; - if (!$island) { - return _("Sorry, that appears to be a Crown dependency postcode, which we don't cover."); - } - if ($island eq 'I') { - return _("We do not cover Northern Ireland, I'm afraid, as our licence doesn't include any maps for the region."); - } - } - return 0; -} - -sub short_name { - my ($area, $info) = @_; - # Special case Durham as it's the only place with two councils of the same name - # And some places in Norway - return 'Durham+County' if $area->{name} eq 'Durham County Council'; - return 'Durham+City' if $area->{name} eq 'Durham City Council'; - if ($area->{name} =~ /^(Os|Nes|V\xe5ler|Sande|B\xf8|Her\xf8y)$/) { - my $parent = $info->{$area->{parent_area}}->{name}; - return URI::Escape::uri_escape_utf8("$area->{name}, $parent"); - } - my $name = $area->{name}; - $name =~ s/ (Borough|City|District|County) Council$//; - $name =~ s/ Council$//; - $name =~ s/ & / and /; - $name = URI::Escape::uri_escape_utf8($name); - $name =~ s/%20/+/g; - return $name; -} - -sub check_photo { - my ($q, $fh) = @_; - my $ct = $q->uploadInfo($fh)->{'Content-Type'}; - my $cd = $q->uploadInfo($fh)->{'Content-Disposition'}; - # Must delete photo param, otherwise display functions get confused - $q->delete('photo'); - return _('Please upload a JPEG image only') unless - ($ct eq 'image/jpeg' || $ct eq 'image/pjpeg'); - return ''; -} - sub process_photo { my $fh = shift; my $import = shift; @@ -793,10 +598,4 @@ sub process_photo { return $photo; } -sub scambs_categories { - return ('Abandoned vehicles', 'Discarded hypodermic needles', - 'Dog fouling', 'Flytipping', 'Graffiti', 'Lighting (e.g. security lights)', - 'Litter', 'Neighbourhood noise'); -} - 1; @@ -11,7 +11,7 @@ use strict; use warnings; -use Test::More tests => 13; +use Test::More tests => 8; use Test::Exception; use FindBin; @@ -36,28 +36,6 @@ sub set_lang($) { mySociety::Locale::change(); } -sub test_geocode_string() { - my %params = (); - my $q = new MockQuery( 'nosite', \%params ); - - # geocode a straightforward string, expect success - my ( $latitude, $longitude, $error ) = - FixMyStreet::Geocode::string( 'Buckingham Palace', $q ); - is( $latitude, 51.4949261, 'example easting generated' ); - is( $longitude, -0.1461924, 'example northing generated' ); - is( $error, undef, 'should not generate error for simple example' ); - - # expect a failure message for Northern Ireland - ( $latitude, $longitude, $error ) = - FixMyStreet::Geocode::string( 'Falls Road, Belfast', $q ); - is( - $error, - "We do not cover Northern Ireland, I'm afraid, as our licence doesn't " - . "include any maps for the region.", - 'error message produced for NI location' - ); -} - sub test_header() { my $q = mock_query(); my $html; @@ -104,4 +82,3 @@ sub test_base_url_with_lang { ok(test_base_url_with_lang() == 1, 'Ran all tests for base_url_with_lang'); ok(test_footer() == 1, 'Ran all tests for the footer function'); ok(test_header() == 1, 'Ran all tests for the header function'); -ok(test_geocode_string() == 1, 'Ran all tests for the geocode_string function'); diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t index 9f08c8aa9..9a466832b 100644 --- a/t/app/controller/auth.t +++ b/t/app/controller/auth.t @@ -24,7 +24,7 @@ $mech->not_logged_in_ok; $mech->get_ok('/auth'); for my $test ( - [ '' => 'enter an email address' ], + [ '' => 'enter your email' ], [ 'not an email' => 'check your email address is correct' ], [ 'bob@foo' => 'check your email address is correct' ], [ 'bob@foonaoedudnueu.co.uk' => 'check your email address is correct' ], diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t index 9808ef762..bbb3a0f83 100644 --- a/t/app/controller/contact.t +++ b/t/app/controller/contact.t @@ -133,9 +133,9 @@ for my $test ( page_errors => [ 'There were problems with your report. Please see below.', ], field_errors => [ - 'Please give your name', - 'Please give your email', - 'Please give a subject', + 'Please enter your name', + 'Please enter your email', + 'Please enter a subject', 'Please write a message', ] }, @@ -149,9 +149,9 @@ for my $test ( page_errors => [ 'There were problems with your report. Please see below.', ], field_errors => [ - 'Please give your name', - 'Please give a valid email address', - 'Please give a subject', + 'Please enter your name', + 'Please enter a valid email address', + 'Please enter a subject', 'Please write a message', ] }, @@ -164,7 +164,7 @@ for my $test ( }, page_errors => [ 'There were problems with your report. Please see below.', ], - field_errors => [ 'Please give a subject', 'Please write a message', ] + field_errors => [ 'Please enter a subject', 'Please write a message', ] }, { fields => { @@ -186,7 +186,7 @@ for my $test ( }, page_errors => [ 'There were problems with your report. Please see below.', ], - field_errors => [ 'Please give a subject', 'Please write a message', ] + field_errors => [ 'Please enter a subject', 'Please write a message', ] }, { fields => { diff --git a/templates/web/default/auth/general.html b/templates/web/default/auth/general.html index 3d80a1049..32ea03177 100644 --- a/templates/web/default/auth/general.html +++ b/templates/web/default/auth/general.html @@ -10,7 +10,7 @@ # other keys include fqdn, mxcheck if you'd like to write a custom error message errors = { - missing => loc('Please enter an email address'), + missing => loc('Please enter your email'), other => loc('Please check your email address is correct') }; diff --git a/templates/web/default/report/updates.html b/templates/web/default/report/updates.html index b7f44c5ae..910430114 100644 --- a/templates/web/default/report/updates.html +++ b/templates/web/default/report/updates.html @@ -9,12 +9,19 @@ [%- ELSE %] [% tprintf( loc( 'Posted by %s at %s' ), update.name, prettify_epoch( update.confirmed_local.epoch ) ) | html -%] [%- END -%] - [%- # extra cobrand meta data -%] + [%- c.cobrand.extra_update_meta_text(update) -%] [%- ", " _ loc( 'marked as fixed' ) IF update.mark_fixed %] [%- ", " _ loc( 'reopened' ) IF update.mark_open %] </em></p> + + [% IF c.cobrand.allow_update_reporting %] + <p> + <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> + </p> + [% END %] + </div> - [%# update reporting %] + <div class="update-text"> [% add_links( update.text ) | html_para %] diff --git a/web/test.cgi b/web/test.cgi deleted file mode 100755 index c9b36e6b7..000000000 --- a/web/test.cgi +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/perl -w -I../perllib - -# test.cgi -# Part of test suite to force an error to check error handling works. -# -# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. -# Email: matthew@mysociety.org. WWW: http://www.mysociety.org -# -# $Id: test.cgi,v 1.1 2009-07-15 20:51:21 matthew Exp $ - -use strict; -use Standard; - -sub main { - my $q = shift; - - print $q->header(-charset => 'utf-8', -content_type => 'text/plain'); - if ($q->param('error')) { - print 10 / 0; # Cause an error by dividing by zero. - } - print "Success"; -} - -Page::do_fastcgi(\&main); - |