aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cypress/cypress/integration/simple_spec.js17
-rw-r--r--.travis.yml2
-rw-r--r--CHANGELOG.md1
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm19
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm14
-rw-r--r--perllib/FixMyStreet/Script/Reports.pm3
-rw-r--r--t/app/controller/report_as_other.t31
-rwxr-xr-xtemplates/web/base/around/display_location.html6
-rw-r--r--templates/web/fixmystreet.com/around/_report_banner.html6
-rw-r--r--templates/web/fixmystreet.com/around/postcode_form.html34
-rw-r--r--templates/web/fixmystreet.com/header_extra.html16
-rw-r--r--web/cobrands/fixmystreet.com/base.scss88
-rw-r--r--web/cobrands/fixmystreet.com/layout.scss29
13 files changed, 241 insertions, 25 deletions
diff --git a/.cypress/cypress/integration/simple_spec.js b/.cypress/cypress/integration/simple_spec.js
index fe0867c76..30f2a0218 100644
--- a/.cypress/cypress/integration/simple_spec.js
+++ b/.cypress/cypress/integration/simple_spec.js
@@ -1,17 +1,22 @@
-describe('My First Test', function() {
- it('Visits the home page', function() {
+describe('Clicking the map', function() {
+ before(function(){
cy.visit('/');
cy.contains('Go');
cy.get('[name=pc]').type('BS10 5EE');
- cy.get('#postcodeForm').submit();
+ cy.get('[name=pc]').parents('form').submit();
+ });
+
+ it('allows me to report a new problem', function() {
cy.url().should('include', '/around');
cy.get('#map_box').click(200, 200);
cy.get('[name=title]').type('Title');
cy.get('[name=detail]').type('Detail');
cy.get('[name=username]').type('user@example.org');
cy.get('[name=password_sign_in]').type('password');
- cy.get('form').submit();
- cy.get('form').submit();
+ cy.get('[name=password_sign_in]').parents('form').submit();
+ cy.get('#map_sidebar').should('contain', 'check and confirm your details');
+ cy.get('#map_sidebar').parents('form').submit();
+ cy.get('body').should('contain', 'Thank you for reporting this issue');
});
});
@@ -19,7 +24,7 @@ describe('Clicking the "big green banner" on a map page', function() {
before(function() {
cy.visit('/');
cy.get('[name=pc]').type('BS10 5EE');
- cy.get('#postcodeForm').submit();
+ cy.get('[name=pc]').parents('form').submit();
cy.get('.big-green-banner').click();
});
diff --git a/.travis.yml b/.travis.yml
index de3ec7b29..fbe8ad240 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -55,7 +55,7 @@ before_script:
- 'if [ "$TRAVIS_PERL_VERSION" = "5.24" ]; then export HARNESS_PERL_SWITCHES="-MDevel::Cover=+ignore,local/lib/perl5,commonlib,perllib/Catalyst/[^A],perllib/DBIx,perllib/Email,perllib/Template,^t"; fi'
script:
- 'if [ "$CYPRESS" = "0" ]; then script/test --jobs 3 t; fi'
- - 'if [ "$CYPRESS" = "1" ]; then PATH=$(npm bin):$PATH bin/browser-tests run --record; fi'
+ - 'if [ "$CYPRESS" = "1" ]; then PATH=$(npm bin):$PATH bin/browser-tests run ${CYPRESS_RECORD_KEY:+--record}; fi'
after_success:
- .travis/after_script
- 'if [ "$TRAVIS_PERL_VERSION" = "5.24" ]; then cover --report codecov; fi'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b922ad5e8..613883ff3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,7 @@
- Inspectors can set non_public status of reports. #1992
- Default start date is shown on the dashboard.
- Users with 'user_edit' permission can search for users/reports. #2027
+ - Don't send sent-report emails to as-body/as-anonymous reports.
- Development improvements:
- Add HTML email previewer.
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index e4e82f091..a41aeb6ea 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -1300,9 +1300,17 @@ sub save_user_and_report : Private {
if ( $c->cobrand->never_confirm_reports ) {
$report->user->update_or_insert;
$report->confirm();
- } elsif ( $c->forward('created_as_someone_else', [ $c->stash->{bodies} ]) ) {
- # If created on behalf of someone else, we automatically confirm it,
- # but we don't want to update the user account
+ # If created on behalf of someone else, we automatically confirm it,
+ # but we don't want to update the user account
+ } elsif ($c->stash->{contributing_as_another_user}) {
+ $report->set_extra_metadata( contributed_as => 'another_user');
+ $report->set_extra_metadata( contributed_by => $c->user->id );
+ $report->confirm();
+ } elsif ($c->stash->{contributing_as_body}) {
+ $report->set_extra_metadata( contributed_as => 'body' );
+ $report->confirm();
+ } elsif ($c->stash->{contributing_as_anonymous_user}) {
+ $report->set_extra_metadata( contributed_as => 'anonymous_user' );
$report->confirm();
} elsif ( !$report->user->in_storage ) {
# User does not exist.
@@ -1342,11 +1350,6 @@ sub save_user_and_report : Private {
return 1;
}
-sub created_as_someone_else : Private {
- my ($self, $c, $bodies) = @_;
- return $c->stash->{contributing_as_another_user} || $c->stash->{contributing_as_body} || $c->stash->{contributing_as_anonymous_user};
-}
-
=head2 generate_map
Add the html needed to for the map to the stash.
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index 99eae8659..9d97688c5 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -444,9 +444,17 @@ sub save_update : Private {
if ( $c->cobrand->never_confirm_updates ) {
$update->user->update_or_insert;
$update->confirm();
- } elsif ( $c->forward('/report/new/created_as_someone_else', [ $update->problem->bodies_str ]) ) {
- # If created on behalf of someone else, we automatically confirm it,
- # but we don't want to update the user account
+ # If created on behalf of someone else, we automatically confirm it,
+ # but we don't want to update the user account
+ } elsif ($c->stash->{contributing_as_another_user}) {
+ $update->set_extra_metadata( contributed_as => 'another_user');
+ $update->set_extra_metadata( contributed_by => $c->user->id );
+ $update->confirm();
+ } elsif ($c->stash->{contributing_as_body}) {
+ $update->set_extra_metadata( contributed_as => 'body' );
+ $update->confirm();
+ } elsif ($c->stash->{contributing_as_anonymous_user}) {
+ $update->set_extra_metadata( contributed_as => 'anonymous_user' );
$update->confirm();
} elsif ( !$update->user->in_storage ) {
# User does not exist.
diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm
index b8c3d6d0d..1d19ee283 100644
--- a/perllib/FixMyStreet/Script/Reports.pm
+++ b/perllib/FixMyStreet/Script/Reports.pm
@@ -294,6 +294,9 @@ sub _send_report_sent_email {
# Don't send 'report sent' text
return unless $row->user->email_verified;
+ my $contributed_as = $row->get_extra_metadata('contributed_as') || '';
+ return if $contributed_as eq 'body' || $contributed_as eq 'anonymous_user';
+
FixMyStreet::Email::send_cron(
$row->result_source->schema,
'confirm_report_sent.txt',
diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t
index e8f65eb7b..367d9a1d4 100644
--- a/t/app/controller/report_as_other.t
+++ b/t/app/controller/report_as_other.t
@@ -1,5 +1,6 @@
use FixMyStreet::TestMech;
use FixMyStreet::App;
+use FixMyStreet::Script::Reports;
# disable info logs for this test run
FixMyStreet::App->log->disable('info');
@@ -15,7 +16,7 @@ my $test_email = 'body-user@example.net';
my $user = $mech->log_in_ok($test_email);
$user->update({ from_body => $body->id, name => 'Body User' });
-my ($report_to_update) = $mech->create_problems_for_body(1, $body->id, 'Title');
+my ($report_to_update) = $mech->create_problems_for_body(1, $body->id, 'Title', { category => 'Potholes' });
subtest "Body user, no permissions, no special reporting tools shown" => sub {
start_report();
@@ -100,6 +101,9 @@ subtest "Body user, has permission to add report as another user with landline n
};
subtest "Body user, has permission to add report as another (existing) user with email" => sub {
+ FixMyStreet::Script::Reports::send();
+ $mech->clear_emails_ok;
+
$mech->create_user_ok('existing@example.net', name => 'Existing User');
my $report = add_report(
'contribute_as_another_user',
@@ -116,6 +120,15 @@ subtest "Body user, has permission to add report as another (existing) user with
isnt $report->user->id, $user->id, 'user does not match';
like $mech->get_text_body_from_email, qr/Your report to Oxfordshire County Council has been logged/;
push @users, $report->user;
+
+ my $send_confirmation_mail_override = Sub::Override->new(
+ "FixMyStreet::Cobrand::Default::report_sent_confirmation_email",
+ sub { return 1; }
+ );
+ FixMyStreet::Script::Reports::send();
+ $mech->email_count_is(2);
+ $mech->clear_emails_ok;
+ $send_confirmation_mail_override->restore();
};
subtest "Body user, has permission to add report as another (existing) user with phone" => sub {
@@ -138,6 +151,9 @@ subtest "Body user, has permission to add report as another (existing) user with
};
subtest "Body user, has permission to add report as anonymous user" => sub {
+ FixMyStreet::Script::Reports::send();
+ $mech->clear_emails_ok;
+
my $report = add_report(
'contribute_as_anonymous_user',
form_as => 'anonymous_user',
@@ -149,6 +165,19 @@ subtest "Body user, has permission to add report as anonymous user" => sub {
is $report->user->name, 'Body User', 'user name unchanged';
is $report->user->id, $user->id, 'user matches';
is $report->anonymous, 1, 'report anonymous';
+
+ my $send_confirmation_mail_override = Sub::Override->new(
+ "FixMyStreet::Cobrand::Default::report_sent_confirmation_email",
+ sub { return 1; }
+ );
+
+ FixMyStreet::Script::Reports::send();
+ # No report sent email is sent
+ $mech->email_count_is(1);
+ my $email = $mech->get_email;
+ like $email->header('Subject'), qr/Problem Report: Test Report/, 'report email title correct';
+ $mech->clear_emails_ok;
+ $send_confirmation_mail_override->restore();
};
subtest "Body user, has permission to add update as council" => sub {
diff --git a/templates/web/base/around/display_location.html b/templates/web/base/around/display_location.html
index 029435cf2..c97612beb 100755
--- a/templates/web/base/around/display_location.html
+++ b/templates/web/base/around/display_location.html
@@ -73,6 +73,12 @@
<a href="/">[% loc('Home') %]</a>
<span>[% loc('Place pin on map') %]</span>
</div>
+
+ [% IF c.config.BASE_URL == "https://www.fixmystreet.com" %]
+ <h1 class="big-green-banner banner-position-variant-1">
+ [% loc( 'Click map to report a problem' ) %]
+ </h1>
+ [% END %]
</div>
diff --git a/templates/web/fixmystreet.com/around/_report_banner.html b/templates/web/fixmystreet.com/around/_report_banner.html
new file mode 100644
index 000000000..08cd7ed05
--- /dev/null
+++ b/templates/web/fixmystreet.com/around/_report_banner.html
@@ -0,0 +1,6 @@
+<h1 class="big-green-banner banner-position-variant-0">
+ [% loc( 'Click map to report a problem' ) %]
+</h1>
+<a id="skip-this-step" href="[% url_skip %]" rel="nofollow">
+ [% loc("Can't see the map? <em>Skip this step</em>") %]
+</a>
diff --git a/templates/web/fixmystreet.com/around/postcode_form.html b/templates/web/fixmystreet.com/around/postcode_form.html
new file mode 100644
index 000000000..c1d3198c0
--- /dev/null
+++ b/templates/web/fixmystreet.com/around/postcode_form.html
@@ -0,0 +1,34 @@
+<div id="front-main">
+ <div id="front-main-container">
+ [% UNLESS possible_location_matches %]
+ [% INCLUDE 'around/intro.html' %]
+ [% END %]
+
+ [%
+ question = c.cobrand.enter_postcode_text || loc('Enter a nearby street name and area');
+ %]
+
+ <form action="[% c.uri_for('/around') %]" method="get" name="postcodeForm" class="js-geolocate postcode-form-test">
+ <label for="pc">[% question %]:</label>
+ <input type="text" name="pc" value="[% pc | html %]" id="pc" size="10" maxlength="200" placeholder="[% tprintf(loc('e.g. ā€˜%s’ or ā€˜%s’'), c.cobrand.example_places) %]" class="postcode-form-test__postcode">
+ <a href="[% c.uri_for('/around') %]" id="geolocate_link" class="btn btn--geolocate">[% loc('or locate me automatically') %]</a>
+
+ [%# Form will be submitted via this button when user presses Enter key %]
+ <button type="submit" class="visuallyhidden" aria-hidden="true" tabindex="-1">Go</button>
+
+ <div class="postcode-form-test__buttons">
+ [%# We can now segment users in Google Analytics by looking at "intent" query string param %]
+ <button type="submit" name="intent" value="report" class="btn">[% loc('Report a new problem') %]</button>
+ <button type="submit" name="intent" value="browse" class="btn">[% loc('Show problems') %]</button>
+ </div>
+
+ [% IF partial_token %]
+ <input type="hidden" name="partial" value="[% partial_token.token %]">
+ [% END %]
+
+ [% IF c.user_exists AND c.user.categories.size %]
+ <input type="hidden" name="filter_category" value="[% c.user.categories.join(",") | html %]">
+ [% END %]
+ </form>
+ </div>
+</div>
diff --git a/templates/web/fixmystreet.com/header_extra.html b/templates/web/fixmystreet.com/header_extra.html
index 5292d4804..146c3f79e 100644
--- a/templates/web/fixmystreet.com/header_extra.html
+++ b/templates/web/fixmystreet.com/header_extra.html
@@ -2,6 +2,22 @@
<link rel="prefetch" href="[% version('/vendor/OpenLayers.Projection.OrdnanceSurvey.js') %]">
[% END %]
+[% IF bodyclass.match('mappage') AND c.config.BASE_URL == "https://www.fixmystreet.com" %]
+<script src="//www.google-analytics.com/cx/api.js?experiment=jydOGgMrQRaWedSNoiW-SQ"></script>
+<script nonce="[% csp_nonce %]">
+ var variation = typeof cxApi !== "undefined" ? cxApi.chooseVariation() : 0,
+ docElement = document.documentElement,
+ className = docElement.className;
+ docElement.className = className + ' banner-position-variant-' + variation;
+</script>
+<style>
+ html .banner-position-variant-1 { display: none !important; }
+ html.banner-position-variant-1 .banner-position-variant-0 { display: none !important; }
+ html.banner-position-variant-1 .banner-position-variant-1 { display: block !important; }
+ html.banner-position-variant-1 #side .big-green-banner ~ section.full-width { margin-top: -1em; }
+</style>
+[% END %]
+
[% IF bodyclass.match('frontpage') %]
<link rel="prefetch" href="[% version('/cobrands/fixmystreet.com/js.js') %]">
[% END %]
diff --git a/web/cobrands/fixmystreet.com/base.scss b/web/cobrands/fixmystreet.com/base.scss
index 0cc23c539..b78d5ce5b 100644
--- a/web/cobrands/fixmystreet.com/base.scss
+++ b/web/cobrands/fixmystreet.com/base.scss
@@ -49,6 +49,30 @@ svg|g.site-logo__svg {
@include svg-background-image("/cobrands/fixmystreet/images/site-logo");
}
+// Big green banner A/B test.
+#map_box .big-green-banner {
+ position: absolute;
+ left: 50%;
+ bottom: 80px; // above #sub_map_links
+ transform: translateX(-50%);
+ margin: 0;
+ font-size: 1.2em;
+ line-height: 1.3em;
+ padding: 0.6em 1em 0.5em;
+ border-radius: 5px; // match .big-hide-pins-link
+ background-image: none; // remove "arrow" image
+
+ @media (min-width: 64em) {
+ bottom: 32px; // match #sub_map_links
+ left: calc( ( 100% - 220px ) / 2 );
+ max-width: calc( 100% - 300px );
+ }
+
+ @media (min-width: 82em) {
+ left: 50%;
+ }
+}
+
.next-steps {
margin: 0 -1em; // counteract padding on parent
background-color: #faf7e2;
@@ -299,3 +323,67 @@ html.lazyload .js-lazyload {
margin-bottom: 0;
}
}
+
+.postcode-form-test {
+ margin: 0 -1em;
+ padding: 1em;
+ background-color: $primary;
+ color: $primary_text;
+
+ label {
+ margin: 0;
+ }
+
+ // Lots of !important flags here to overpower
+ // selectors like `#front-main a#geolocate_link` and
+ // `body.fullwidthpage #front-main a#geolocate_link`
+ // in the core and fixmystreet.com styles.
+ #geolocate_link {
+ background: transparent !important;
+ border: none;
+ height: auto !important;
+ margin-top: 0 !important;
+ padding: 1em !important;
+
+ &:before {
+ vertical-align: -0.3em;
+ }
+ }
+}
+
+// Overloaded selector to beat input[type="text"]
+input.postcode-form-test__postcode {
+ max-width: 100%;
+ width: 30em;
+ margin: 0.5em auto 0 auto;
+ padding: 0.75em;
+ border: 1px solid darken($primary, 10%);
+ box-shadow: 0 1px 1px rgba(#000, 0.2);
+}
+
+.postcode-form-test__buttons {
+ margin: 1em -10px 0 -10px;
+
+ // Browsers without flex support will just lay out the buttons
+ // side-by-side, breaking onto two lines at narrow widths.
+ @include flex-container();
+ @include justify-content(center);
+
+ $btn-blue: #469bfc;
+
+ .btn {
+ color: #fff !important;
+ background: $btn-blue;
+ background-image: linear-gradient($btn-blue, darken($btn-blue, 5%));
+ border: none;
+ border-radius: 2px;
+ text-shadow: 0 1px 1px rgba(0,0,0,0.2);
+ box-shadow: 0 1px 1px rgba(0,0,0,0.2);
+ margin: 0 10px 10px 10px;
+
+ &:hover, &:focus {
+ background-color: darken($btn-blue, 5%);
+ background-image: linear-gradient(darken($btn-blue, 5%), darken($btn-blue, 10%));
+ }
+ }
+}
diff --git a/web/cobrands/fixmystreet.com/layout.scss b/web/cobrands/fixmystreet.com/layout.scss
index 0e37c9723..9c7f575a2 100644
--- a/web/cobrands/fixmystreet.com/layout.scss
+++ b/web/cobrands/fixmystreet.com/layout.scss
@@ -53,6 +53,8 @@
font-style: normal;
}
+$body-font: MuseoSans, Helmet, Freesans, sans-serif;
+
/* Opera has a bug (from around 10.5 upwards to current 11.6) with showing the
* table caption *at all* if the header is set to a font-face :( */
noindex:-o-prefocus, #site-header {
@@ -122,17 +124,17 @@ body.fullwidthpage {
h1 {
font-size: 3em;
font-weight: bold;
- font-family: MuseoSans,Helmet,Freesans,sans-serif;
+ font-family: $body-font;
}
h2 {
- font-family: MuseoSans,Helmet,Freesans,sans-serif;
+ font-family: $body-font;
}
#postcodeForm {
div {
font-size: 1.3em;
width: 24em;
label {
- font-family: MuseoSans,Helmet,Freesans,sans-serif;
+ font-family: $body-font;
}
input#pc {
color: #777;
@@ -147,13 +149,13 @@ body.fullwidthpage {
font-size: 1.1em;
height: 2.4em;
width: 3.5em;
- font-family: MuseoSans,Helmet,Freesans,sans-serif;
+ font-family: $body-font;
font-weight: bold;
}
}
}
a#geolocate_link {
- font-family: MuseoSans,Helmet,Freesans,sans-serif;
+ font-family: $body-font;
background: url(images/locate-me.png) $left 0 no-repeat;
height: 34px;
padding-#{$left}: 24px;
@@ -169,6 +171,21 @@ body.fullwidthpage {
}
}
+.postcode-form-test {
+ background: transparent;
+ padding-top: 1.5em;
+}
+
+// Overloaded selector to beat input[type="text"]
+input.postcode-form-test__postcode {
+ max-width: 25em; // down from 27em, now that "GO" button has gone
+ font-size: 1.2em;
+}
+
+.postcode-form-test__buttons .btn {
+ font-size: 1.2em;
+}
+
body.frontpage {
#site-logo {
margin: 2em 0;
@@ -207,7 +224,7 @@ body.frontpage {
}
.next-steps__step {
- font-family: MuseoSans,Helmet,Freesans,sans-serif;
+ font-family: $body-font;
float: $left;
width: 33%;
padding: 1.8em;