diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 28 | ||||
-rw-r--r-- | templates/web/default/report/display.html | 48 |
2 files changed, 40 insertions, 36 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index ccdfa8a54..86c84f14c 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -86,20 +86,26 @@ Load user from the database or prepare a new one. sub process_user : Private { my ( $self, $c ) = @_; - # FIXME - If user already logged in use them regardless + my $update_user; + if ( $c->user ) { - # 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; - # cleanup the email address - my $email = $params{rznvy} ? lc $params{rznvy} : ''; - $email =~ s{\s+}{}g; + } else { - my $update_user = $c->model('DB::User')->find_or_new( { email => $email } ); - $update_user->name( Utils::trim_text( $params{name} ) ) - if $params{name}; + # Extract all the params to a hash to make them easier to work with + my %params = # + map { $_ => scalar $c->req->param($_) } # + ( 'rznvy', '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 } ); + $update_user->name( Utils::trim_text( $params{name} ) ); + + } $c->stash->{update_user} = $update_user; diff --git a/templates/web/default/report/display.html b/templates/web/default/report/display.html index a22cf4df8..13610f132 100644 --- a/templates/web/default/report/display.html +++ b/templates/web/default/report/display.html @@ -77,25 +77,6 @@ <input type="hidden" name="submit_update" value="1"> <input type="hidden" name="id" value="[% problem.id | html %]"> - <div> - <label for="form_name">[% loc( 'Name:') %]</label> - <input type="text" name="name" id="form_name" value="[% update.name || c.user.name | html %]" size="20"> [% loc( '(optional)' ) %] - </div> - - <div class="checkbox"> - <input type="checkbox" name="may_show_name" id="form_may_show_name" value="1"[% ' checked' UNLESS update.anonymous %]> - <label for="form_may_show_name">[% loc('Show my name publicly') %]</label> - <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 %] - <div class="form-field"> - <label for="form_rznvy">[% loc('Email' ) %]</label> - <input type="text" name="rznvy" id="form_rznvy" value="[% update.user.email || c.user.email | html %]" size="20"> - </div> - [% IF field_errors.update %] <div class='form-error'>[% field_errors.update %]</div> [% END %] @@ -104,7 +85,6 @@ <textarea name="update" id="form_update" rows="7" cols="30">[% update.text | html %]</textarea> </div> - [% IF problem.state != 'fixed' %] <div class="checkbox"> <input type="checkbox" name="fixed" id="form_fixed" value="1"[% ' checked' IF update.mark_fixed %]> @@ -112,7 +92,6 @@ </div> [% END %] - [% IF c.cobrand.allow_photo_upload %] [% IF photo_error %] <div class='form-error'>[% photo_error %]</div> @@ -123,25 +102,44 @@ <input type="hidden" name="upload_fileid" value="[% upload_fileid %]"> [% END %] <label for="form_photo">[% loc('Photo:') %]</label> - <input type="file" name="photo" id="form_photo"> + <input type="file" name="photo" id="form_photo" style="width:20em"> </div> [% END %] + <div> + <label for="form_name">[% loc( 'Name:') %]</label> + <input type="text" name="name" id="form_name" value="[% update.name || c.user.name | html %]" size="20"> + </div> + + <div class="checkbox"> + <input type="checkbox" name="may_show_name" id="form_may_show_name" value="1"[% ' checked' UNLESS update.anonymous %]> + <label for="form_may_show_name">[% loc('Show my name publicly') %]</label> + <small>[% loc('(we never show your email)') %]</small> + </div> + +[% IF NOT c.user %] + + [% IF field_errors.email %] + <div class='form-error'>[% field_errors.email %]</div> + [% END %] + <div class="form-field"> + <label for="form_rznvy">[% loc('Email' ) %]</label> + <input type="text" name="rznvy" id="form_rznvy" value="[% update.user.email || c.user.email | html %]" size="20"> + </div> + +[% END %] <div class="checkbox"> <input type="checkbox" name="add_alert" id="form_add_alert" value="1"[% ' checked' IF add_alert %]> <label for="form_add_alert">[% loc( 'Alert me to future updates' ) %]</label> </div> - <div class="checkbox"> <input type="submit" id="update_post" value="[% loc('Post') %]"> </div> - [% cobrand_update_fields %] - </form> </div> |