diff options
author | Matthew Somerville <matthew@mysociety.org> | 2014-11-18 17:05:39 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2014-11-18 17:25:53 +0000 |
commit | e039f86ec38a36486f6bb61c332192d9dc71acdb (patch) | |
tree | 8d1458eb30bd5dab870e08ea6c6f67255cdff407 | |
parent | 57fcd59af03f823528f71c03c8f8043f4fee63ca (diff) |
Show logged in message as success, not error.
Fixes #357.
Also consolidate almost-identical fill_in_details.html template
(for #344).
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 3 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 6 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 9 | ||||
-rw-r--r-- | templates/web/base/report/display.html | 4 | ||||
-rw-r--r-- | templates/web/base/report/new/fill_in_details.html | 48 | ||||
-rw-r--r-- | templates/web/bromley/report/display.html | 3 | ||||
-rw-r--r-- | templates/web/fixmystreet/report/display.html | 4 | ||||
-rw-r--r-- | templates/web/fixmystreet/report/new/fill_in_details.html | 36 | ||||
-rw-r--r-- | web/cobrands/sass/_base.scss | 7 |
10 files changed, 58 insertions, 66 deletions
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 @@ <div id="side"> +[% IF login_success %] + <p class='form-success'>[% loc('You have successfully signed in; please check and confirm your details are accurate:') %]</p> +[% 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 %] + <form action="[% c.uri_for('/report/new') %]" method="post" name="mapForm" id="mapForm"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %] class="validate"> -[% IF c.req.params.map_override %] -<input type="hidden" name="map_override" value="[% c.req.params.map_override | html %]"> -[% END %] -<input type="hidden" name="pc" value="[% pc | html %]"> + [% IF c.req.params.map_override %] + <input type="hidden" name="map_override" value="[% c.req.params.map_override | html %]"> + [% END %] + + <input type="hidden" name="pc" value="[% pc | html %]"> + [% ELSE %] + <form action="[% c.uri_for('/report/new') %]" method="post" name="mapSkippedForm"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %] class="validate"> -<input type="hidden" name="pc" value="[% pc | html %]"> -<input type="hidden" name="skipped" value="1"> + <input type="hidden" name="pc" value="[% pc | html %]"> + <input type="hidden" name="skipped" value="1"> + [% END %] -<input type="hidden" name="latitude" id="fixmystreet.latitude" value="[% short_latitude | html %]"> -<input type="hidden" name="longitude" id="fixmystreet.longitude" value="[% short_longitude | html %]"> + <input type="hidden" name="latitude" id="fixmystreet.latitude" value="[% short_latitude | html %]"> + <input type="hidden" name="longitude" id="fixmystreet.longitude" value="[% short_longitude | html %]"> -[% IF report.used_map %] - [% map_html %] - </div> - <div id="side"> -[% ELSE %] - <div id="skipped-map"> -[% END %] + [% IF report.used_map %] + [% map_html %] + </div> + <div id="side"> + [% ELSE %] + <div id="skipped-map"> + [% END %] -[% PROCESS 'report/new/fill_in_details_form.html' %] + [% IF login_success %] + <p class='form-success'>[% loc('You have successfully signed in; please check and confirm your details are accurate:') %]</p> + [% END %] -</div> + [% PROCESS 'report/new/fill_in_details_form.html' %] + + </div> </form> [% 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 @@ </div> +[% IF login_success %] + <p class='form-success'>[% loc('You have successfully signed in; please check and confirm your details are accurate:') %]</p> +[% 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 @@ </div> +[% IF login_success %] + <p class='form-success'>[% loc('You have successfully signed in; please check and confirm your details are accurate:') %]</p> +[% 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 %] - -<form action="[% c.uri_for('/report/new') %]" method="post" name="mapForm" id="mapForm"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %] class="validate"> - [% IF c.req.params.map_override %] - <input type="hidden" name="map_override" value="[% c.req.params.map_override | html %]"> - [% END %] - - <input type="hidden" name="pc" value="[% pc | html %]"> - -[% ELSE %] - -<form action="[% c.uri_for('/report/new') %]" method="post" name="mapSkippedForm"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %] class="validate"> - <input type="hidden" name="pc" value="[% pc | html %]"> - <input type="hidden" name="skipped" value="1"> - -[% END %] - - <input type="hidden" name="latitude" id="fixmystreet.latitude" value="[% short_latitude | html %]"> - <input type="hidden" name="longitude" id="fixmystreet.longitude" value="[% short_longitude | html %]"> - - [% IF report.used_map %] - [% map_html %] - </div> - [% END %] - - [% PROCESS 'report/new/fill_in_details_form.html' %] -</form> - -[% 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, |