From e039f86ec38a36486f6bb61c332192d9dc71acdb Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 18 Nov 2014 17:05:39 +0000 Subject: Show logged in message as success, not error. Fixes #357. Also consolidate almost-identical fill_in_details.html template (for #344). --- perllib/FixMyStreet/App/Controller/Report/New.pm | 4 +- .../FixMyStreet/App/Controller/Report/Update.pm | 3 +- t/app/controller/report_new.t | 6 +-- t/app/controller/report_updates.t | 9 ++-- templates/web/base/report/display.html | 4 ++ templates/web/base/report/new/fill_in_details.html | 48 +++++++++++++--------- templates/web/bromley/report/display.html | 3 ++ templates/web/fixmystreet/report/display.html | 4 ++ .../fixmystreet/report/new/fill_in_details.html | 36 ---------------- web/cobrands/sass/_base.scss | 7 ++++ 10 files changed, 58 insertions(+), 66 deletions(-) delete mode 100644 templates/web/fixmystreet/report/new/fill_in_details.html diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 1e9f83aec..ed5be4e99 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -759,7 +759,7 @@ sub process_user : Private { $report->user( $user ); $report->name( $user->name ); $c->stash->{check_name} = 1; - $c->stash->{field_errors}->{name} = _('You have successfully signed in; please check and confirm your details are accurate:'); + $c->stash->{login_success} = 1; $c->log->info($user->id . ' logged in during problem creation'); return 1; } @@ -984,7 +984,7 @@ sub check_for_errors : Private { } # all good if no errors - return 1 unless scalar keys %field_errors; + return 1 unless scalar keys %field_errors || $c->stash->{login_success}; $c->stash->{field_errors} = \%field_errors; diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index bc79cafd3..b97420238 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -137,7 +137,7 @@ sub process_user : Private { my $user = $c->user->obj; $update->user( $user ); $update->name( $user->name ); - $c->stash->{field_errors}->{name} = _('You have successfully signed in; please check and confirm your details are accurate:'); + $c->stash->{login_success} = 1; return 1; } @@ -290,6 +290,7 @@ sub check_for_errors : Private { # all good if no errors return 1 unless ( scalar keys %field_errors + || $c->stash->{login_success} || ( $c->stash->{errors} && scalar @{ $c->stash->{errors} } ) ); $c->stash->{field_errors} = \%field_errors; diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 92bc54ba4..44e075f1e 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -728,10 +728,8 @@ subtest "test report creation for a user who is signing in as they report" => su "submit good details" ); - # check that we got the errors expected - is_deeply $mech->page_errors, [ - 'You have successfully signed in; please check and confirm your details are accurate:', - ], "check there were errors"; + # check that we got the message expected + $mech->content_contains( 'You have successfully signed in; please check and confirm your details are accurate:' ); # Now submit with a name $mech->submit_form_ok( diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 17947a212..99c53ef01 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -932,9 +932,7 @@ for my $test ( add_alert => undef, password_sign_in => 'secret2', }, - field_errors => [ - 'You have successfully signed in; please check and confirm your details are accurate:', - ], + message => 'You have successfully signed in; please check and confirm your details are accurate:', } ) { subtest $test->{desc} => sub { @@ -955,7 +953,10 @@ for my $test ( 'submit update' ); - is_deeply $mech->page_errors, $test->{field_errors}, 'check there were errors'; + $mech->content_contains($test->{message}) if $test->{message}; + + is_deeply $mech->page_errors, $test->{field_errors}, 'check there were errors' + if $test->{field_errors}; SKIP: { skip( "Incorrect password", 5 ) unless $test->{form_values}{password_sign_in} eq $pw; diff --git a/templates/web/base/report/display.html b/templates/web/base/report/display.html index fd7580ac1..a7181942f 100644 --- a/templates/web/base/report/display.html +++ b/templates/web/base/report/display.html @@ -16,6 +16,10 @@
+[% IF login_success %] +

[% loc('You have successfully signed in; please check and confirm your details are accurate:') %]

+[% END %] + [% INCLUDE 'report/banner.html' %] [% INCLUDE 'report/_main.html' %] diff --git a/templates/web/base/report/new/fill_in_details.html b/templates/web/base/report/new/fill_in_details.html index 22d1ee739..1b8a866fc 100644 --- a/templates/web/base/report/new/fill_in_details.html +++ b/templates/web/base/report/new/fill_in_details.html @@ -1,35 +1,45 @@ [% + SET bodyclass = ''; + SET bodyclass = 'mappage' IF report.used_map; PROCESS "maps/${map.type}.html" IF report.used_map; - INCLUDE 'header.html', title => loc('Reporting a problem') + INCLUDE 'header.html', title => loc('Reporting a problem'); %] [% IF report.used_map %] +
-[% IF c.req.params.map_override %] - -[% END %] - + [% IF c.req.params.map_override %] + + [% END %] + + + [% ELSE %] + - - + + + [% END %] - - + + -[% IF report.used_map %] - [% map_html %] -
-
-[% ELSE %] -
-[% END %] + [% IF report.used_map %] + [% map_html %] +
+
+ [% ELSE %] +
+ [% END %] -[% PROCESS 'report/new/fill_in_details_form.html' %] + [% IF login_success %] +

[% loc('You have successfully signed in; please check and confirm your details are accurate:') %]

+ [% END %] -
+ [% PROCESS 'report/new/fill_in_details_form.html' %] + +
[% INCLUDE 'footer.html' %] - diff --git a/templates/web/bromley/report/display.html b/templates/web/bromley/report/display.html index 60edd0e79..f30b4b86d 100644 --- a/templates/web/bromley/report/display.html +++ b/templates/web/bromley/report/display.html @@ -14,6 +14,9 @@
+[% IF login_success %] +

[% loc('You have successfully signed in; please check and confirm your details are accurate:') %]

+[% END %] [% INCLUDE 'report/banner.html' %] [% INCLUDE 'report/_main.html' %] diff --git a/templates/web/fixmystreet/report/display.html b/templates/web/fixmystreet/report/display.html index 2b150f768..3534572c6 100644 --- a/templates/web/fixmystreet/report/display.html +++ b/templates/web/fixmystreet/report/display.html @@ -20,6 +20,10 @@ +[% IF login_success %] +

[% loc('You have successfully signed in; please check and confirm your details are accurate:') %]

+[% END %] + [% INCLUDE 'report/banner.html' %] [% INCLUDE 'report/_main.html' %] diff --git a/templates/web/fixmystreet/report/new/fill_in_details.html b/templates/web/fixmystreet/report/new/fill_in_details.html deleted file mode 100644 index 8cf0dfdd9..000000000 --- a/templates/web/fixmystreet/report/new/fill_in_details.html +++ /dev/null @@ -1,36 +0,0 @@ -[% - SET bodyclass = ''; - SET bodyclass = 'mappage' IF report.used_map; - PROCESS "maps/${map.type}.html" IF report.used_map; - INCLUDE 'header.html', title => loc('Reporting a problem'); -%] - -[% IF report.used_map %] - -
- [% IF c.req.params.map_override %] - - [% END %] - - - -[% ELSE %] - - - - - -[% END %] - - - - - [% IF report.used_map %] - [% map_html %] - - [% END %] - - [% PROCESS 'report/new/fill_in_details_form.html' %] -
- -[% INCLUDE 'footer.html' %] diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss index 7ed4bb0a5..d50d31e3e 100644 --- a/web/cobrands/sass/_base.scss +++ b/web/cobrands/sass/_base.scss @@ -395,6 +395,13 @@ ul.error { @include border-radius(0.25em); } +.form-success { + background: #009900; + color: #fff; + padding: 0 0.5em; + @include border-radius(0.25em); +} + // don't display valid error boxes as now the page jump // won't be until the user submits, which is fine div.label-valid, -- cgit v1.2.3