aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2011-06-24 12:34:42 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-06-24 12:34:42 +0100
commitcc8b152ee383e8b596926e3f2cab39557b353bcc (patch)
tree776bc8c296d1af57f2d481166b4166c441d4cd1d
parentedf59d8605000c4363ce4d79f270559c522bc63e (diff)
Don't show email field on reporting if logged in.
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm33
-rw-r--r--t/app/controller/report_import.t8
-rw-r--r--t/app/controller/report_new.t1
-rw-r--r--templates/web/default/report/display.html2
-rw-r--r--templates/web/default/report/new/fill_in_details.html18
6 files changed, 29 insertions, 35 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 130eee858..44a7fa6bc 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -564,7 +564,7 @@ sub process_user : Private {
unless $report->user;
# set the user's name and phone (if given)
- $report->user->name( Utils::trim_text( $params{name} ) );
+ $report->user->name( Utils::trim_text( $params{name} ) ) if $params{name};
$report->user->phone( Utils::trim_text( $params{phone} ) );
return 1;
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index d84fda1bf..d586035bc 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -21,8 +21,8 @@ sub report_update : Path : Args(0) {
my ( $self, $c ) = @_;
$c->forward( '/report/load_problem_or_display_error', [ $c->req->param('id') ] )
- && $c->forward('process_user')
&& $c->forward('process_update')
+ && $c->forward('process_user')
&& $c->forward('/report/new/process_photo')
&& $c->forward('check_for_errors')
or $c->go( '/report/display', [ $c->req->param('id') ] );
@@ -86,28 +86,24 @@ Load user from the database or prepare a new one.
sub process_user : Private {
my ( $self, $c ) = @_;
- my $update_user;
- if ( $c->user ) {
-
- $update_user = $c->user->obj;
-
- } else {
+ my $update = $c->stash->{update};
- # Extract all the params to a hash to make them easier to work with
- my %params = #
- map { $_ => scalar $c->req->param($_) } #
- ( 'rznvy', 'name' );
+ $update->user( $c->user->obj ) if $c->user;
- # cleanup the email address
- my $email = $params{rznvy} ? lc $params{rznvy} : '';
- $email =~ s{\s+}{}g;
+ # Extract all the params to a hash to make them easier to work with
+ my %params = #
+ map { $_ => scalar $c->req->param($_) } #
+ ( 'rznvy', 'name' );
- $update_user = $c->model('DB::User')->find_or_new( { email => $email } );
- $update_user->name( Utils::trim_text( $params{name} ) );
+ # cleanup the email address
+ my $email = $params{rznvy} ? lc $params{rznvy} : '';
+ $email =~ s{\s+}{}g;
- }
+ $update->user( $c->model('DB::User')->find_or_new( { email => $email } ) )
+ unless $update->user;
- $c->stash->{update_user} = $update_user;
+ $update->user->name( Utils::trim_text( $params{name} ) )
+ if $params{name};
return 1;
}
@@ -142,7 +138,6 @@ sub process_update : Private {
text => $params{update},
name => $name,
problem => $c->stash->{problem},
- user => $c->stash->{update_user},
state => 'unconfirmed',
mark_fixed => $params{fixed} ? 1 : 0,
cobrand => $c->cobrand->moniker,
diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t
index 154de13d8..ba73b2555 100644
--- a/t/app/controller/report_import.t
+++ b/t/app/controller/report_import.t
@@ -119,7 +119,6 @@ subtest "Submit a correct entry" => sub {
is_deeply $mech->visible_form_values,
{
name => 'Test User',
- email => 'test@example.com',
title => 'Test report',
detail => 'This is a test report',
photo => '',
@@ -134,7 +133,6 @@ subtest "Submit a correct entry" => sub {
{
with_fields => {
name => 'New Test User',
- email => 'test@example.com',
title => 'New Test report',
detail => 'This is a test report',
phone => '01234 567 890',
@@ -193,14 +191,13 @@ subtest "Submit a correct entry (with location)" => sub {
# go to the token url
$mech->get_ok($token_url);
- # check that we are on '/around'
- is $mech->uri->path, '/report/new', "sent to /around";
+ # check that we are on '/report/new'
+ is $mech->uri->path, '/report/new', "sent to /report/new";
# check that fields are prefilled for us
is_deeply $mech->visible_form_values,
{
name => 'Test User ll',
- email => 'test-ll@example.com',
title => 'Test report ll',
detail => 'This is a test report ll',
photo => '',
@@ -215,7 +212,6 @@ subtest "Submit a correct entry (with location)" => sub {
{
with_fields => {
name => 'New Test User ll',
- email => 'test-ll@example.com',
title => 'New Test report ll',
detail => 'This is a test report ll',
phone => '01234 567 890',
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 01c29ecf4..3e486d22c 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -406,7 +406,6 @@ foreach my $test (
title => '',
detail => '',
may_show_name => '1',
- email => $test_email,
name => 'Test User',
phone => '01234 567 890',
photo => '',
diff --git a/templates/web/default/report/display.html b/templates/web/default/report/display.html
index 13610f132..40c5f081f 100644
--- a/templates/web/default/report/display.html
+++ b/templates/web/default/report/display.html
@@ -117,7 +117,7 @@
<small>[% loc('(we never show your email)') %]</small>
</div>
-[% IF NOT c.user %]
+[% IF NOT c.user_exists %]
[% IF field_errors.email %]
<div class='form-error'>[% field_errors.email %]</div>
diff --git a/templates/web/default/report/new/fill_in_details.html b/templates/web/default/report/new/fill_in_details.html
index 48407bb45..4a40dd707 100644
--- a/templates/web/default/report/new/fill_in_details.html
+++ b/templates/web/default/report/new/fill_in_details.html
@@ -141,14 +141,18 @@
<small>[% loc('(we never show your email address or phone number)') %]</small>
</div>
-[% IF field_errors.email %]
- <div class='form-error'>[% field_errors.email %]</div>
-[% END %]
+[% IF NOT c.user_exists %]
-<div class="form-field">
- <label for="form_email">[% loc('Email:') %]</label>
- <input type="text" value="[% report.user.email | html %]" name="email" id="form_email" size="25">
-</div>
+ [% IF field_errors.email %]
+ <div class='form-error'>[% field_errors.email %]</div>
+ [% END %]
+
+ <div class="form-field">
+ <label for="form_email">[% loc('Email:') %]</label>
+ <input type="text" value="[% report.user.email | html %]" name="email" id="form_email" size="25">
+ </div>
+
+[% END %]
<div>
<label for="form_phone">[% loc('Phone:') %]</label>