diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Problem.pm | 35 | ||||
-rw-r--r-- | perllib/Memcached.pm | 17 | ||||
-rw-r--r-- | perllib/Open311/GetServiceRequestUpdates.pm | 3 | ||||
-rw-r--r-- | t/cobrand/fixmystreet.t | 6 | ||||
-rwxr-xr-x | templates/web/buckinghamshire/about/faq-en-gb.html (renamed from templates/web/buckinghamshire/about/faq.html) | 0 | ||||
-rw-r--r-- | templates/web/fixmystreet.com/about/council-dashboard.html | 20 | ||||
-rw-r--r-- | web/cobrands/fixmystreet.com/base.scss | 6 |
10 files changed, 42 insertions, 54 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f0a20f43..d5f650411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Improved cursor/display of the new report pin. #2038 - Asset layers can be attached to more than one category each. #2049 - Cobrands hook to remove phone number field. #2049 + - Check recent reports for any hidden since cached. #2053 - Bugfixes: - Stop asset layers obscuring marker layer. #1999 - Don't delete hidden field values when inspecting reports. #1999 diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 15a220644..037458538 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -413,6 +413,8 @@ sub summary : Private { my ($self, $c) = @_; my $dashboard = $c->forward('load_dashboard_data'); + $c->log->info($c->user->email . ' viewed ' . $c->req->uri->path_query) if $c->user_exists; + eval { my $data = path(FixMyStreet->path_to('../data/all-reports-dashboard.json'))->slurp_utf8; $data = decode_json($data); diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm index 591234877..6c826ec01 100644 --- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm +++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm @@ -136,7 +136,7 @@ sub about_hook { $c->stash->{form_name} = $c->get_param('name') || ''; $c->stash->{email} = $c->get_param('username') || ''; if ($c->user_exists) { - my $body = _user_to_body($c); + my $body = $c->user->from_body || _user_to_body($c); if ($body) { $c->stash->{body} = $body; $c->stash->{wards} = [ { name => 'summary' } ]; @@ -152,9 +152,7 @@ sub about_hook { $c->stash->{template} = 'auth/general.html'; $c->detach('/auth/general'); } else { - $c->stash->{no_body_found} = 1; - $c->set_param('em', $email); # What the contact form wants - $c->detach('/contact/submit'); + $c->stash->{error} = 'bad_email'; } } } diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index ebc6e6c1b..e262cb63e 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -132,34 +132,25 @@ sub _recent { }; my $probs; - my $new = 0; - if (defined $lat) { - my $dist2 = $dist; # Create a copy of the variable to stop it being stringified into a locale in the next line! - $key .= ":$lat:$lon:$dist2"; - $probs = Memcached::get($key); - unless ($probs) { - $attrs->{bind} = [ $lat, $lon, $dist ]; - $attrs->{join} = 'nearby'; - $probs = [ mySociety::Locale::in_gb_locale { - $rs->search( $query, $attrs )->all; - } ]; - $new = 1; - } + if (defined $lat) { # No caching + $attrs->{bind} = [ $lat, $lon, $dist ]; + $attrs->{join} = 'nearby'; + $probs = [ mySociety::Locale::in_gb_locale { + $rs->search( $query, $attrs )->all; + } ]; } else { $probs = Memcached::get($key); - unless ($probs) { + if ($probs) { + # Need to reattach schema so that confirmed column gets reinflated. + $probs->[0]->result_source->schema( $rs->result_source->schema ) if $probs->[0]; + # Catch any cached ones since hidden + $probs = [ grep { ! $_->is_hidden } @$probs ]; + } else { $probs = [ $rs->search( $query, $attrs )->all ]; - $new = 1; + Memcached::set($key, $probs, 3600); } } - if ( $new ) { - Memcached::set($key, $probs, 3600); - } else { - # Need to reattach schema so that confirmed column gets reinflated. - $probs->[0]->result_source->schema( $rs->result_source->schema ) if $probs->[0]; - } - return $probs; } diff --git a/perllib/Memcached.pm b/perllib/Memcached.pm index b612dd5ac..150594a01 100644 --- a/perllib/Memcached.pm +++ b/perllib/Memcached.pm @@ -4,39 +4,34 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: Memcached.pm,v 1.3 2008-10-10 15:57:28 matthew Exp $ -# package Memcached; use strict; +use warnings; use Cache::Memcached; my ($memcache, $namespace); sub set_namespace { $namespace = shift; - $namespace = 'fms' if $namespace eq 'fixmystreet'; } -sub cache_connect { - $memcache = new Cache::Memcached { +sub instance { + return $memcache //= Cache::Memcached->new({ 'servers' => [ '127.0.0.1:11211' ], 'namespace' => $namespace, 'debug' => 0, 'compress_threshold' => 10_000, - }; + }); } sub get { - cache_connect() unless $memcache; - $memcache->get(@_); + instance->get(@_); } sub set { - cache_connect() unless $memcache; - $memcache->set(@_); + instance->set(@_); } 1; diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm index 661b039b0..cee1a629f 100644 --- a/perllib/Open311/GetServiceRequestUpdates.pm +++ b/perllib/Open311/GetServiceRequestUpdates.pm @@ -141,7 +141,8 @@ sub update_comments { # if the comment is older than the last update # do not change the status of the problem as it's # tricky to determine the right thing to do. - if ( $comment->created > $p->lastupdate ) { + # Allow the same time in case report/update created at same time (in external system) + if ( $comment->created >= $p->lastupdate ) { # don't update state unless it's an allowed state and it's # actually changing the state of the problem if ( FixMyStreet::DB::Result::Problem->visible_states()->{$state} && $p->state ne $state && diff --git a/t/cobrand/fixmystreet.t b/t/cobrand/fixmystreet.t index 30d5765a2..57ab51198 100644 --- a/t/cobrand/fixmystreet.t +++ b/t/cobrand/fixmystreet.t @@ -18,6 +18,9 @@ FixMyStreet::override_config { $data = FixMyStreet::Script::UpdateAllReports::generate_dashboard($body); }; +FixMyStreet::App->log->disable('info'); +END { FixMyStreet::App->log->enable('info'); } + FixMyStreet::override_config { MAPIT_URL => 'http://mapit.uk/', TEST_DASHBOARD_DATA => $data, @@ -29,8 +32,7 @@ FixMyStreet::override_config { is $mech->uri->path, '/about/council-dashboard'; $mech->submit_form_ok({ with_fields => { username => 'someone@somewhere.example.org' }}); - $mech->content_contains('We will be in touch'); - # XXX Check email arrives + $mech->content_contains('did not recognise your email'); $mech->log_in_ok('someone@somewhere.example.org'); $mech->get_ok('/reports/Birmingham/summary'); diff --git a/templates/web/buckinghamshire/about/faq.html b/templates/web/buckinghamshire/about/faq-en-gb.html index 54aaa4fcd..54aaa4fcd 100755 --- a/templates/web/buckinghamshire/about/faq.html +++ b/templates/web/buckinghamshire/about/faq-en-gb.html diff --git a/templates/web/fixmystreet.com/about/council-dashboard.html b/templates/web/fixmystreet.com/about/council-dashboard.html index 84b71480f..1d4bca18d 100644 --- a/templates/web/fixmystreet.com/about/council-dashboard.html +++ b/templates/web/fixmystreet.com/about/council-dashboard.html @@ -2,15 +2,6 @@ title = 'Dashboard :: Request Access', bodyclass = 'fullwidthpage' %] -[% IF no_body_found %] - -<div class="confirmation-header confirmation-header--inbox"> - <h1>Thanks!</h1> - <p>We will be in touch with a confirmation link soon.</p> -</div> - -[% ELSE %] - <div class="council-dashboard-login"> <form method="post"> @@ -31,14 +22,19 @@ <label for="demo-email">Contact email</label> <span class="required">required</span> <input class="form-control" type="email" name="username" id="demo-email" required value="[% email | html %]"> - <p class="form-note">Ending in .gov.uk, or other official council domain</p> + <p class="form-note"> + [% IF error == 'bad_email' %]<strong>[% END ~%] + Ending in .gov.uk, or other official council domain + [% IF error == 'bad_email' %]– please <a href="/contact?name=[% form_name | uri %]&em=[% email | uri %]">contact us</a> + if we did not recognise your email</strong>[% END ~%] + </p> </div> <div class="form-group submit-group"> <input type="hidden" name="r" value="about/council-dashboard"> <input type="hidden" name="extra.referer" value="[% c.req.headers.referer | html %]"> <input type="hidden" name="subject" value="Council dashboard request"> <input type="hidden" name="message" value="Filled in the council dashboard form"> - <input type="hidden" name="recipient" value="bettercities"> + <input type="hidden" name="recipient" value="business"> <input type="hidden" name="dest" value="from_council"> <input type="submit" value="Request access" class="btn"> </div> @@ -47,6 +43,4 @@ </div> -[% END %] - [% INCLUDE footer.html %] diff --git a/web/cobrands/fixmystreet.com/base.scss b/web/cobrands/fixmystreet.com/base.scss index 484c39716..9d263d865 100644 --- a/web/cobrands/fixmystreet.com/base.scss +++ b/web/cobrands/fixmystreet.com/base.scss @@ -476,6 +476,10 @@ input.postcode-form-test__postcode { background: #b2b2b2 url(/cobrands/fixmystreet.com/images/dashboard-teaser-blurred.jpg) 0 0 no-repeat; background-size: 100%; + strong { + color: #c00; + } + form { max-width: 24em; padding: 2em; @@ -515,4 +519,4 @@ input.postcode-form-test__postcode { & > :last-child { margin-bottom: 0; } -}
\ No newline at end of file +} |