diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 25 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 124 | ||||
-rw-r--r-- | templates/web/base/admin/update_edit.html | 23 | ||||
-rw-r--r-- | templates/web/base/questionnaire/index.html | 28 | ||||
-rw-r--r-- | templates/web/base/report/update-form.html | 39 | ||||
-rw-r--r-- | templates/web/bromley/report/display.html | 39 | ||||
-rw-r--r-- | templates/web/eastsussex/report/update-form.html | 39 |
7 files changed, 218 insertions, 99 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index c42916acb..686d23aa1 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -683,7 +683,7 @@ sub report_edit : Path('report_edit') : Args(1) { } if (my $rotate_photo_param = $self->_get_rotate_photo_param($c)) { - $self->rotate_photo($c, @$rotate_photo_param); + $self->rotate_photo($c, $problem, @$rotate_photo_param); if ( $c->cobrand->moniker eq 'zurich' ) { # Clicking the photo rotation buttons should do nothing # except for rotating the photo, so return the user @@ -975,6 +975,11 @@ sub update_edit : Path('update_edit') : Args(1) { $c->stash->{update} = $update; + if (my $rotate_photo_param = $self->_get_rotate_photo_param($c)) { + $self->rotate_photo($c, $update, @$rotate_photo_param); + return 1; + } + $c->forward('check_email_for_abuse', [ $update->user->email ] ); if ( $c->get_param('banuser') ) { @@ -1004,13 +1009,14 @@ sub update_edit : Path('update_edit') : Args(1) { || $c->get_param('anonymous') ne $update->anonymous || $c->get_param('text') ne $update->text ) { $edited = 1; - } + } - if ( $c->get_param('remove_photo') ) { - $update->photo(undef); + my $remove_photo_param = $self->_get_remove_photo_param($c); + if ($remove_photo_param) { + $self->remove_photo($c, $update, $remove_photo_param); } - if ( $c->get_param('remove_photo') || $new_state eq 'hidden' ) { + if ( $remove_photo_param || $new_state eq 'hidden' ) { unlink glob FixMyStreet->path_to( 'web', 'photo', 'c', $update->id . '.*' ); } @@ -1489,21 +1495,20 @@ sub _get_rotate_photo_param { my $key = first { /^rotate_photo/ } keys %{ $c->req->params } or return; my ($index) = $key =~ /(\d+)$/; my $direction = $c->get_param($key); - return [ $index || 0, $key, $direction ]; + return [ $index || 0, $direction ]; } sub rotate_photo : Private { - my ( $self, $c, $index, $key, $direction ) = @_; + my ( $self, $c, $object, $index, $direction ) = @_; return unless $direction eq _('Rotate Left') or $direction eq _('Rotate Right'); - my $problem = $c->stash->{problem}; - my $fileid = $problem->get_photoset->rotate_image( + my $fileid = $object->get_photoset->rotate_image( $index, $direction eq _('Rotate Left') ? -90 : 90 ) or return; - $problem->update({ photo => $fileid }); + $object->update({ photo => $fileid }); return 1; } diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 4f55a387b..f9f5189e5 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -199,7 +199,9 @@ for my $test ( rznvy => '', update => '', name => '', - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', fixed => undef, add_alert => 1, may_show_name => undef, @@ -216,7 +218,9 @@ for my $test ( rznvy => 'test', update => '', name => '', - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', fixed => undef, add_alert => 1, may_show_name => undef, @@ -233,7 +237,9 @@ for my $test ( rznvy => 'test @ example. com', update => '', name => '', - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', fixed => undef, add_alert => 1, may_show_name => undef, @@ -252,7 +258,9 @@ for my $test ( rznvy => 'test@EXAMPLE.COM', update => '', name => '', - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', fixed => undef, add_alert => 1, may_show_name => undef, @@ -292,7 +300,9 @@ for my $test ( rznvy => '', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, remember_me => undef, @@ -316,7 +326,9 @@ for my $test ( rznvy => '', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, remember_me => undef, @@ -417,7 +429,9 @@ for my $test ( rznvy => '', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, remember_me => undef, @@ -502,7 +516,9 @@ subtest 'check non authority user cannot change set state' => sub { name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'this is a forbidden update', state => 'fixed - council', }, @@ -530,7 +546,9 @@ for my $state ( qw/unconfirmed hidden partial/ ) { name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'this is a forbidden update', state => $state, }, @@ -553,7 +571,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to investigating', state => 'investigating', }, @@ -565,7 +585,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to in progress', state => 'in progress', }, @@ -577,7 +599,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to fixed', state => 'fixed', }, @@ -589,7 +613,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to action scheduled', state => 'action scheduled', }, @@ -601,7 +627,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to unable to fix', state => 'unable to fix', }, @@ -613,7 +641,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to internal referral', state => 'internal referral', }, @@ -626,7 +656,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to not responsible', state => 'not responsible', }, @@ -639,7 +671,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to duplicate', state => 'duplicate', }, @@ -652,7 +686,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to internal referral', state => 'internal referral', }, @@ -665,7 +701,9 @@ for my $test ( name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Set state to fixed', state => 'fixed', }, @@ -783,7 +821,9 @@ subtest "check comment with no status change has not status in meta" => sub { name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Comment that does not change state', }, }, @@ -813,7 +853,9 @@ subtest "check comment with no status change has not status in meta" => sub { name => $user->name, may_show_name => 1, add_alert => undef, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => 'Comment that sets state to investigating', state => 'investigating', }, @@ -1059,7 +1101,9 @@ for my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1069,7 +1113,7 @@ for my $test ( update => 'update from a registered user', add_alert => undef, fixed => undef, - photo => [ [ $sample_file, undef, Content_Type => 'image/jpeg' ], 1 ], + photo1 => [ [ $sample_file, undef, Content_Type => 'image/jpeg' ], 1 ], }, changed => { update => 'Update from a registered user' @@ -1085,7 +1129,9 @@ for my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1111,7 +1157,9 @@ for my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1136,7 +1184,9 @@ for my $test ( name => 'Commenter', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1161,7 +1211,9 @@ for my $test ( name => 'Commenter', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', }, email => 'commenter@example.com', @@ -1217,7 +1269,7 @@ for my $test ( my $update = $report->comments->first; ok $update, 'found update'; - $mech->content_contains("/photo/c/" . $update->id . ".0.jpeg") if $test->{fields}->{photo}; + $mech->content_contains("/photo/c/" . $update->id . ".0.jpeg") if $test->{fields}->{photo1}; if ( !defined( $test->{endstate_banner} ) ) { is $mech->extract_problem_banner->{text}, undef, 'endstate banner'; @@ -1252,7 +1304,9 @@ foreach my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1278,7 +1332,9 @@ foreach my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1305,7 +1361,9 @@ foreach my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1778,7 +1836,9 @@ for my $test ( my %standard_fields = ( name => $report->user->name, update => 'update text', - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', may_show_name => 1, add_alert => 1, ); diff --git a/templates/web/base/admin/update_edit.html b/templates/web/base/admin/update_edit.html index 54e6d52d2..a956bb2cb 100644 --- a/templates/web/base/admin/update_edit.html +++ b/templates/web/base/admin/update_edit.html @@ -51,11 +51,26 @@ <li>[% loc('Created:') %] [% PROCESS format_time time=update.created %]</li> [% IF update.photo %] -[% photo = update.photos.first %] -<li><img alt="Photo of this update" src="[% c.cobrand.base_url %][% photo.url_temp %]"> -<input type="checkbox" id="remove_photo" name="remove_photo" value="1"> -<label for="remove_photo" class="inline">[% loc("Remove photo (can't be undone!)") %]</label></li> +<li> +<ul> + [% FOR photo IN update.photos %] + <li> + <div class="update-img"> + <a href="[% c.cobrand.base_url %][% photo.url_temp_full %]" rel="fancy"> + <img alt="Photo of this update" src="[% c.cobrand.base_url %][% photo.url_temp %]"> + <span>zoom</span> + </a> + </div> + <input type="submit" name="rotate_photo_[% loop.index %]" value="[% loc('Rotate Left') %]"> + <input type="submit" name="rotate_photo_[% loop.index %]" value="[% loc('Rotate Right') %]"> + <input type="checkbox" id="remove_photo_[% loop.index %]" name="remove_photo_[% loop.index %]" value="1"> + <label class="inline" for="remove_photo_[% loop.index %]">[% loc("Remove photo (can't be undone!)") %]</label></li> + </li> + [% END %] +</ul> +</li> [% END %] + </ul> <input type="submit" name="Submit changes" value="[% loc('Submit changes') %]" ></form> diff --git a/templates/web/base/questionnaire/index.html b/templates/web/base/questionnaire/index.html index ab3bde9ad..82f0534f4 100644 --- a/templates/web/base/questionnaire/index.html +++ b/templates/web/base/questionnaire/index.html @@ -71,15 +71,27 @@ <p><textarea name="update" rows="7" cols="30" placeholder="[% loc('What was your experience of getting the problem fixed?') %]">[% update | html %]</textarea></p> [% IF c.cobrand.allow_photo_upload %] -<p id="fileupload_normalUI"> - [% IF upload_fileid %] - <img align="right" src="/photo/[% upload_fileid %].temp.jpeg" alt=""> - <p>[% loc('You have already attached a photo to this report, attaching another one will replace it.') %]</p> - <input type="hidden" name="upload_fileid" value="[% upload_fileid %]"> + <input type="hidden" name="upload_fileid" value="[% upload_fileid %]"> + <label for="form_photo">[% loc('Photo') %]</label> + + [% IF field_errors.photo %] + <p class='form-error'>[% field_errors.photo %]</p> + [% END %] + + <div id="form_photos"> + [% IF upload_fileid %] + <script> + fixmystreet.uploaded_files = "[% upload_fileid %]".split(','); + </script> + <p>[% loc('You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed).') %]</p> + [% FOREACH id IN upload_fileid.split(',') %] + <img align="right" src="/photo/[% id %].temp.jpeg" alt=""> + [% END %] [% END %] - <label for="form_photo">[% loc('Photo:') %]</label> - <input type="file" name="photo" id="form_photo"> -</p> + <input type="file" name="photo1" id="form_photo"> + <input type="file" name="photo2" id="form_photo2"> + <input type="file" name="photo3" id="form_photo3"> + </div> [% END %] [% IF c.cobrand.moniker != 'emptyhomes' %] diff --git a/templates/web/base/report/update-form.html b/templates/web/base/report/update-form.html index be93ca82e..8c812cd08 100644 --- a/templates/web/base/report/update-form.html +++ b/templates/web/base/report/update-form.html @@ -16,6 +16,30 @@ <input type="hidden" name="submit_update" value="1"> <input type="hidden" name="id" value="[% problem.id | html %]"> + [% IF c.cobrand.allow_photo_upload %] + <input type="hidden" name="upload_fileid" value="[% upload_fileid %]"> + <label for="form_photo">[% loc('Photo') %]</label> + + [% IF field_errors.photo %] + <p class='form-error'>[% field_errors.photo %]</p> + [% END %] + + <div id="form_photos"> + [% IF upload_fileid %] + <script> + fixmystreet.uploaded_files = "[% upload_fileid %]".split(','); + </script> + <p>[% loc('You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed).') %]</p> + [% FOREACH id IN upload_fileid.split(',') %] + <img align="right" src="/photo/[% id %].temp.jpeg" alt=""> + [% END %] + [% END %] + <input type="file" name="photo1" id="form_photo"> + <input type="file" name="photo2" id="form_photo2"> + <input type="file" name="photo3" id="form_photo3"> + </div> + [% END %] + <label for="form_update">[% loc( 'Update' ) %]</label> [% IF field_errors.update %] <div class='form-error'>[% field_errors.update %]</div> @@ -49,21 +73,6 @@ [% END %] [% END %] - [% IF c.cobrand.allow_photo_upload %] - <div id="fileupload_normalUI"> - [% IF upload_fileid %] - <img align="right" src="/photo/[% upload_fileid %].temp.jpeg" alt=""> - <p>[% loc('You have already attached a photo to this update, attaching another one will replace it.') %]</p> - <input type="hidden" name="upload_fileid" value="[% upload_fileid %]"> - [% END %] - <label for="form_photo">[% loc('Photo') %]</label> - [% IF field_errors.photo %] - <p class='form-error'>[% field_errors.photo %]</p> - [% END %] - <input type="file" name="photo" id="form_photo"> - </div> - [% END %] - [% IF c.user_exists %] [% INCLUDE name %] diff --git a/templates/web/bromley/report/display.html b/templates/web/bromley/report/display.html index 75b7700a5..c9b0e9847 100644 --- a/templates/web/bromley/report/display.html +++ b/templates/web/bromley/report/display.html @@ -60,6 +60,30 @@ <input type="hidden" name="submit_update" value="1"> <input type="hidden" name="id" value="[% problem.id | html %]"> + [% IF c.cobrand.allow_photo_upload %] + <input type="hidden" name="upload_fileid" value="[% upload_fileid %]"> + <label for="form_photo">[% loc('Photo') %]</label> + + [% IF field_errors.photo %] + <p class='form-error'>[% field_errors.photo %]</p> + [% END %] + + <div id="form_photos"> + [% IF upload_fileid %] + <script> + fixmystreet.uploaded_files = "[% upload_fileid %]".split(','); + </script> + <p>[% loc('You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed).') %]</p> + [% FOREACH id IN upload_fileid.split(',') %] + <img align="right" src="/photo/[% id %].temp.jpeg" alt=""> + [% END %] + [% END %] + <input type="file" name="photo1" id="form_photo"> + <input type="file" name="photo2" id="form_photo2"> + <input type="file" name="photo3" id="form_photo3"> + </div> + [% END %] + <label for="form_update">[% loc( 'Update' ) %]</label> [% IF field_errors.update %] <div class='form-error'>[% field_errors.update %]</div> @@ -98,21 +122,6 @@ [% END %] [% END %] - [% IF c.cobrand.allow_photo_upload %] - <div id="fileupload_normalUI"> - [% IF upload_fileid %] - <img align="right" src="/photo/[% upload_fileid %].temp.jpeg" alt=""> - <p>[% loc('You have already attached a photo to this update, attaching another one will replace it.') %]</p> - <input type="hidden" name="upload_fileid" value="[% upload_fileid %]"> - [% END %] - <label for="form_photo">[% loc('Photo') %]</label> - [% IF field_errors.photo %] - <p class='form-error'>[% field_errors.photo %]</p> - [% END %] - <input type="file" name="photo" id="form_photo"> - </div> - [% END %] - [% IF c.user_exists %] [% INCLUDE name %] diff --git a/templates/web/eastsussex/report/update-form.html b/templates/web/eastsussex/report/update-form.html index af966f417..55d79a930 100644 --- a/templates/web/eastsussex/report/update-form.html +++ b/templates/web/eastsussex/report/update-form.html @@ -60,6 +60,30 @@ <input type="hidden" name="submit_update" value="1"> <input type="hidden" name="id" value="[% problem.id | html %]"> + [% IF c.cobrand.allow_photo_upload %] + <input type="hidden" name="upload_fileid" value="[% upload_fileid %]"> + <label for="form_photo">[% loc('Photo') %]</label> + + [% IF field_errors.photo %] + <p class='form-error'>[% field_errors.photo %]</p> + [% END %] + + <div id="form_photos"> + [% IF upload_fileid %] + <script> + fixmystreet.uploaded_files = "[% upload_fileid %]".split(','); + </script> + <p>[% loc('You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed).') %]</p> + [% FOREACH id IN upload_fileid.split(',') %] + <img align="right" src="/photo/[% id %].temp.jpeg" alt=""> + [% END %] + [% END %] + <input type="file" name="photo1" id="form_photo"> + <input type="file" name="photo2" id="form_photo2"> + <input type="file" name="photo3" id="form_photo3"> + </div> + [% END %] + <label for="form_update">[% loc( 'Update:' ) %] <span class="label-warning public-warning"> [% loc('public') %] @@ -97,21 +121,6 @@ [% END %] [% END %] - [% IF c.cobrand.allow_photo_upload %] - <div id="fileupload_normalUI"> - [% IF upload_fileid %] - <img align="right" src="/photo/[% upload_fileid %].temp.jpeg" alt=""> - <p>[% loc('You have already attached a photo to this update, attaching another one will replace it.') %]</p> - <input type="hidden" name="upload_fileid" value="[% upload_fileid %]"> - [% END %] - <label for="form_photo">[% loc('Photo') %]</label> - [% IF field_errors.photo %] - <p class='form-error'>[% field_errors.photo %]</p> - [% END %] - <input type="file" name="photo" id="form_photo"> - </div> - [% END %] - [% IF c.user_exists %] [% INCLUDE name %] |