diff options
41 files changed, 680 insertions, 823 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 0fc87c2f6..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 @@ -790,11 +790,12 @@ sub report_edit : Path('report_edit') : Args(1) { } # Deal with photos - if ( $c->get_param('remove_photo') ) { - $problem->photo(undef); + my $remove_photo_param = $self->_get_remove_photo_param($c); + if ($remove_photo_param) { + $self->remove_photo($c, $problem, $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', $problem->id . '.*' ); } @@ -974,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') ) { @@ -1003,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 . '.*' ); } @@ -1488,22 +1495,48 @@ 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($c)->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; +} + +=head2 remove_photo + +Remove a photo from a report +=cut + +# Returns index of photo(s) to remove, if any +sub _get_remove_photo_param { + my ($self, $c) = @_; + + return 'ALL' if $c->get_param('remove_photo'); + + my @keys = map { /(\d+)$/ } grep { /^remove_photo_/ } keys %{ $c->req->params } or return; + return \@keys; +} + +sub remove_photo : Private { + my ($self, $c, $object, $keys) = @_; + if ($keys eq 'ALL') { + $object->photo(undef); + } else { + my $fileids = $object->get_photoset->remove_images($keys); + $object->photo($fileids); + } return 1; } diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm index f4866cc26..df4cab2d8 100644 --- a/perllib/FixMyStreet/App/Controller/Photo.pm +++ b/perllib/FixMyStreet/App/Controller/Photo.pm @@ -4,11 +4,9 @@ use namespace::autoclean; BEGIN {extends 'Catalyst::Controller'; } -use DateTime::Format::HTTP; -use Digest::SHA qw(sha1_hex); +use JSON; use File::Path; use File::Slurp; -use Path::Class; use FixMyStreet::App::Model::PhotoSet; use if !$ENV{TRAVIS}, 'Image::Magick'; @@ -35,16 +33,12 @@ sub during :LocalRegex('^([0-9a-f]{40})\.(temp|fulltemp)\.jpeg$') { my ( $self, $c ) = @_; my ( $hash, $size ) = @{ $c->req->captures }; - my $file = file( $c->config->{UPLOAD_DIR}, "$hash.jpeg" ); - my $photo = $file->slurp; + my $photoset = FixMyStreet::App::Model::PhotoSet->new({ + data_items => [ $hash ] + }); - if ( $size eq 'temp' ) { - if ( $c->cobrand->default_photo_resize ) { - $photo = _shrink( $photo, $c->cobrand->default_photo_resize ); - } else { - $photo = _shrink( $photo, '250x250' ); - } - } + $size = $size eq 'temp' ? 'default' : 'full'; + my $photo = $photoset->get_image_data(size => $size, default => $c->cobrand->default_photo_resize); $c->forward( 'output', [ $photo ] ); } @@ -73,29 +67,9 @@ sub index :LocalRegex('^(c/)?(\d+)(?:\.(\d+))?(?:\.(full|tn|fp))?\.jpeg$') { $c->detach( 'no_photo' ) unless $c->cobrand->allow_photo_display($item); # Should only be for reports, not updates my $photo; - if ($item->can('get_photoset')) { - $photo = $item->get_photoset( $c ) - ->get_image_data( num => $photo_number, size => $size ) + $photo = $item->get_photoset + ->get_image_data( num => $photo_number, size => $size, default => $c->cobrand->default_photo_resize ) or $c->detach( 'no_photo' ); - } else { - $photo = $item->photo; - # If photo field contains a hash - if (length($photo) == 40) { - my $file = file( $c->config->{UPLOAD_DIR}, "$photo.jpeg" ); - $photo = $file->slurp; - } - - if ( $size eq 'tn' ) { - $photo = _shrink( $photo, 'x100' ); - } elsif ( $size eq 'fp' ) { - $photo = _crop( $photo ); - } elsif ( $size eq 'full' ) { - } elsif ( $c->cobrand->default_photo_resize ) { - $photo = _shrink( $photo, $c->cobrand->default_photo_resize ); - } else { - $photo = _shrink( $photo, '250x250' ); - } - } $c->forward( 'output', [ $photo ] ); } @@ -116,34 +90,6 @@ sub no_photo : Private { $c->detach( '/page_error_404_not_found', [ 'No photo' ] ); } -# Shrinks a picture to the specified size, but keeping in proportion. -sub _shrink { - my ($photo, $size) = @_; - my $image = Image::Magick->new; - $image->BlobToImage($photo); - my $err = $image->Scale(geometry => "$size>"); - throw Error::Simple("resize failed: $err") if "$err"; - $image->Strip(); - my @blobs = $image->ImageToBlob(); - undef $image; - return $blobs[0]; -} - -# Shrinks a picture to 90x60, cropping so that it is exactly that. -sub _crop { - my ($photo) = @_; - my $image = Image::Magick->new; - $image->BlobToImage($photo); - my $err = $image->Resize( geometry => "90x60^" ); - throw Error::Simple("resize failed: $err") if "$err"; - $err = $image->Extent( geometry => '90x60', gravity => 'Center' ); - throw Error::Simple("resize failed: $err") if "$err"; - $image->Strip(); - my @blobs = $image->ImageToBlob(); - undef $image; - return $blobs[0]; -} - sub upload : Local { my ( $self, $c ) = @_; my @items = ( diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 4632f450d..db524ada4 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -449,7 +449,7 @@ sub initialize_report : Private { $c->stash->{partial_token} = $token if $report; # Stash the photo IDs for "already got" display - $c->stash->{upload_fileid} = $report->get_photoset($c)->data; + $c->stash->{upload_fileid} = $report->get_photoset->data; } else { # no point keeping it if it is done. diff --git a/perllib/FixMyStreet/App/Model/PhotoSet.pm b/perllib/FixMyStreet/App/Model/PhotoSet.pm index e8396b5aa..35a7e8a53 100644 --- a/perllib/FixMyStreet/App/Model/PhotoSet.pm +++ b/perllib/FixMyStreet/App/Model/PhotoSet.pm @@ -222,7 +222,7 @@ sub get_image_data { } elsif ( $size eq 'full' ) { # do nothing } else { - $photo = _shrink( $photo, $self->c->cobrand->default_photo_resize || '250x250' ); + $photo = _shrink( $photo, $args{default} || '250x250' ); } return $photo; @@ -239,6 +239,27 @@ sub delete_cached { ); } +sub remove_images { + my ($self, $ids) = @_; + + my @images = $self->all_images; + my $dec = 0; + for (sort { $a <=> $b } @$ids) { + splice(@images, $_ + $dec, 1); + --$dec; + } + my @items = map $_->[0], @images; + + my $new_set = (ref $self)->new({ + data_items => \@items, + object => $self->object, + }); + + $self->delete_cached(); + + return $new_set->data; # e.g. new comma-separated fileid +} + sub rotate_image { my ($self, $index, $direction) = @_; @@ -250,7 +271,6 @@ sub rotate_image { my $new_set = (ref $self)->new({ data_items => \@items, - c => $self->c, object => $self->object, }); @@ -272,11 +292,6 @@ sub _rotate_image { } - - - -# NB: These 2 subs stolen from A::C::Photo, should be purged from there! -# # Shrinks a picture to the specified size, but keeping in proportion. sub _shrink { my ($photo, $size) = @_; diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index b7c9e9f45..ea4eda8c4 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -1172,7 +1172,7 @@ sub admin_stats { $public_response =~ s{\r?\n}{ <br/> }g if $public_response; # Assemble photo URL, if report has a photo - my $media_url = $report->get_photo_params->{url} ? ($c->cobrand->base_url . $report->get_photo_params->{url}) : ''; + my $media_url = @{$report->photos} ? ($c->cobrand->base_url . $report->photos->[0]->{url}) : ''; my @columns = ( $report->id, diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 41e8cf315..3ae56591f 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -97,7 +97,6 @@ __PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); __PACKAGE__->rabx_column('extra'); use Moo; -use Utils::Photo; use namespace::clean -except => [ 'meta' ]; with 'FixMyStreet::Roles::Abuser'; @@ -148,15 +147,44 @@ sub confirm { $self->confirmed( \'current_timestamp' ); } -=head2 get_photo_params +=head2 get_photoset -Returns a hashref of details of any attached photo for use in templates. +Return a PhotoSet object for all photos attached to this field + + my $photoset = $obj->get_photoset; + print $photoset->num_images; + return $photoset->get_image_data(num => 0, size => 'full'); =cut -sub get_photo_params { +sub get_photoset { + my ($self) = @_; + my $class = 'FixMyStreet::App::Model::PhotoSet'; + eval "use $class"; + return $class->new({ + db_data => $self->photo, + object => $self, + }); +} + +sub photos { my $self = shift; - return Utils::Photo::get_photo_params($self, 'c'); + my $photoset = $self->get_photoset; + my $i = 0; + my $id = $self->id; + my @photos = map { + my $format = 'jpeg'; + my $cachebust = substr($_, 0, 8); + { + id => $_, + url_temp => "/photo/$_.temp.$format", + url_temp_full => "/photo/$_.fulltemp.$format", + url => "/photo/c/$id.$i.$format?$cachebust", + url_full => "/photo/c/$id.$i.full.$format?$cachebust", + idx => $i++, + } + } map { $_->[0] } $photoset->all_images; + return \@photos; } =head2 meta_problem_state diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 237785820..8f9e76ad6 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -160,7 +160,6 @@ __PACKAGE__->rabx_column('geocode'); use Moo; use namespace::clean -except => [ 'meta' ]; use Utils; -use Utils::Photo; with 'FixMyStreet::Roles::Abuser', 'FixMyStreet::Roles::Extra'; @@ -483,23 +482,6 @@ sub admin_url { return $cobrand->admin_base_url . '/report_edit/' . $self->id; } -=head2 get_photo_params - -Returns a hashref of details of the attached photo, if any, for use in templates. - -NB: this method doesn't currently support multiple photos gracefully. - -Use get_photoset($c) instead to do the right thing with reports with 0, 1, or more photos. - -=cut - -sub get_photo_params { - # use Carp 'cluck'; - # cluck "get_photo_params called"; # TEMPORARY die to make sure I've done right thing with Zurich templates - my $self = shift; - return Utils::Photo::get_photo_params($self, 'id'); -} - =head2 is_open Returns 1 if the problem is in a open state otherwise 0. @@ -836,7 +818,7 @@ sub as_hashref { state_t => _( $self->state ), used_map => $self->used_map, is_fixed => $self->fixed_states->{ $self->state } ? 1 : 0, - photo => $self->get_photo_params, + photos => [ map { $_->{url} } @{$self->photos} ], meta => $self->confirmed ? $self->meta_line( $c ) : '', confirmed_pp => $self->confirmed ? $c->cobrand->prettify_dt( $self->confirmed ): '', created_pp => $c->cobrand->prettify_dt( $self->created ), @@ -858,23 +840,44 @@ sub latest_moderation_log_entry { Return a PhotoSet object for all photos attached to this field - my $photoset = $obj->get_photoset( $c ); + my $photoset = $obj->get_photoset; print $photoset->num_images; return $photoset->get_image_data(num => 0, size => 'full'); =cut sub get_photoset { - my ($self, $c) = @_; + my ($self) = @_; my $class = 'FixMyStreet::App::Model::PhotoSet'; eval "use $class"; return $class->new({ - c => $c, db_data => $self->photo, object => $self, }); } +sub photos { + my $self = shift; + my $photoset = $self->get_photoset; + my $i = 0; + my $id = $self->id; + my @photos = map { + my $format = 'jpeg'; + my $cachebust = substr($_, 0, 8); + { + id => $_, + url_temp => "/photo/$_.temp.$format", + url_temp_full => "/photo/$_.fulltemp.$format", + url => "/photo/$id.$i.$format?$cachebust", + url_full => "/photo/$id.$i.full.$format?$cachebust", + url_tn => "/photo/$id.$i.tn.$format?$cachebust", + url_fp => "/photo/$id.$i.fp.$format?$cachebust", + idx => $i++, + } + } map { $_->[0] } $photoset->all_images; + return \@photos; +} + __PACKAGE__->has_many( "admin_log_entries", "FixMyStreet::DB::Result::AdminLog", diff --git a/perllib/Utils/Photo.pm b/perllib/Utils/Photo.pm deleted file mode 100644 index a1af90fe1..000000000 --- a/perllib/Utils/Photo.pm +++ /dev/null @@ -1,41 +0,0 @@ -package Utils::Photo; - -use Image::Size; - -=head2 get_photo_params - -Returns a hashref of details of any attached photo for use in templates. -Hashref contains height, width and url keys. - -=cut - -sub get_photo_params { - my ($self, $key) = @_; - - return {} unless $self->photo; - - $key = ($key eq 'id') ? '' : "/$key"; - - my $pre = "/photo$key/" . $self->id; - my $post = '.jpeg'; - my $photo = {}; - - if (length($self->photo) == 40) { - $post .= '?' . $self->photo; - $photo->{url_full} = "$pre.full$post"; - # XXX Can't use size here because {url} (currently 250px height) may be - # being used, but at this point it doesn't yet exist to find the width - # $str = FixMyStreet->config('UPLOAD_DIR') . $self->photo . '.jpeg'; - } else { - my $str = \$self->photo; - ( $photo->{width}, $photo->{height} ) = Image::Size::imgsize( $str ); - } - - $photo->{url} = "$pre$post"; - $photo->{url_tn} = "$pre.tn$post"; - $photo->{url_fp} = "$pre.fp$post"; - - return $photo; -} - -1; diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 07d72de96..42fd076c7 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -8,8 +8,9 @@ my $mech = FixMyStreet::TestMech->new; my $user = FixMyStreet::App->model('DB::User') - ->find_or_create( { email => 'test@example.com', name => 'Test User' } ); + ->find_or_create( { email => 'test@example.com' } ); ok $user, "created test user"; +$user->update({ name => 'Test User' }); my $user2 = FixMyStreet::App->model('DB::User') diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 6c6b4ca19..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', }, @@ -1049,6 +1091,9 @@ subtest 'submit an update for a registered user, creating update by email' => su $mech->delete_user( $user ); }; +my $sample_file = file(__FILE__)->parent->file("sample.jpg")->stringify; +ok -e $sample_file, "sample file $sample_file exists"; + for my $test ( { desc => 'submit update for registered user', @@ -1056,7 +1101,9 @@ for my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1066,6 +1113,7 @@ for my $test ( update => 'update from a registered user', add_alert => undef, fixed => undef, + photo1 => [ [ $sample_file, undef, Content_Type => 'image/jpeg' ], 1 ], }, changed => { update => 'Update from a registered user' @@ -1081,7 +1129,9 @@ for my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1107,7 +1157,9 @@ for my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1132,7 +1184,9 @@ for my $test ( name => 'Commenter', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1157,7 +1211,9 @@ for my $test ( name => 'Commenter', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', }, email => 'commenter@example.com', @@ -1210,6 +1266,11 @@ for my $test ( $mech->content_contains("/report/" . $report_id); $mech->get_ok("/report/" . $report_id); + my $update = $report->comments->first; + ok $update, 'found update'; + + $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'; } else { @@ -1223,8 +1284,6 @@ for my $test ( %{ $test->{changed} }, }; - my $update = $report->comments->first; - ok $update, 'found update'; is $update->text, $results->{update}, 'update text'; is $update->user->email, $test->{email}, 'update user'; is $update->state, 'confirmed', 'update confirmed'; @@ -1245,7 +1304,9 @@ foreach my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1271,7 +1332,9 @@ foreach my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1298,7 +1361,9 @@ foreach my $test ( name => 'Test User', may_show_name => 1, add_alert => 1, - photo => '', + photo1 => '', + photo2 => '', + photo3 => '', update => '', fixed => undef, }, @@ -1771,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/report_edit.html b/templates/web/base/admin/report_edit.html index d04a1a82b..c0cdead84 100644 --- a/templates/web/base/admin/report_edit.html +++ b/templates/web/base/admin/report_edit.html @@ -77,20 +77,26 @@ class="admin-offsite-link">[% problem.latitude %], [% problem.longitude %]</a> <li><label class="inline" for="non_public">[% loc('Private') %]:</label> <input type="checkbox" name="non_public"[% ' checked' IF problem.non_public %]></li> [% IF problem.photo %] -[% photo = problem.get_photo_params %] -<li><img alt="Photo of this report" height="[% photo.height %]" width="[% photo.width %]" src="[% c.cobrand.base_url %] - [%~ IF problem.photo.length == 40 ~%] - /photo/[% problem.photo %].temp.jpeg - [%~ ELSE ~%] - [% photo.url %] - [%~ END %]"> -<br> -<input type="submit" name="rotate_photo" value="[% loc('Rotate Left') %]"> -<input type="submit" name="rotate_photo" value="[% loc('Rotate Right') %]"> -<br> -<input type="checkbox" id="remove_photo" name="remove_photo" value="1"> -<label class="inline" for="remove_photo">[% loc("Remove photo (can't be undone!)") %]</label></li> +<li> +<ul> + [% FOR photo IN problem.photos %] + <li> + <div class="update-img"> + <a href="[% c.cobrand.base_url %][% photo.url_temp_full %]" rel="fancy"> + <img alt="Photo of this report" 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/admin/update_edit.html b/templates/web/base/admin/update_edit.html index 5ffce8bc4..a956bb2cb 100644 --- a/templates/web/base/admin/update_edit.html +++ b/templates/web/base/admin/update_edit.html @@ -51,16 +51,26 @@ <li>[% loc('Created:') %] [% PROCESS format_time time=update.created %]</li> [% IF update.photo %] -[% photo = update.get_photo_params %] -<li><img alt="Photo of this update" height="[% photo.height %]" width="[% photo.width %]" src="[% c.cobrand.base_url %] - [%~ IF update.photo.length == 40 ~%] - /photo/[% update.photo %].temp.jpeg - [%~ ELSE ~%] - [% photo.url %] - [%~ END ~%]"> -<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/alert/index.html b/templates/web/base/alert/index.html index 7057c83a3..4965a1103 100644 --- a/templates/web/base/alert/index.html +++ b/templates/web/base/alert/index.html @@ -39,11 +39,9 @@ within a certain distance of a particular location.', "%s is the site name"), si [% IF photos.size %] <h2>[% loc('Some photos of recent reports') %]</h2> <div class="alerts__nearby-activity__photos"> - [% FOREACH p IN photos; - photo = p.get_photo_params; - %] + [% FOREACH p IN photos %] <a href="/report/[% p.id %]"> - <img border="0" height="100" src="[% photo.url_tn %]" + <img border="0" height="100" src="[% p.photos.first.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"> </a> [% END %] diff --git a/templates/web/base/alert/list.html b/templates/web/base/alert/list.html index 289eb40af..385cd7d32 100644 --- a/templates/web/base/alert/list.html +++ b/templates/web/base/alert/list.html @@ -22,11 +22,9 @@ <div class="alerts__nearby-activity"> <h2>[% loc('Photos of recent nearby reports') %]</h2> <div class="alerts__nearby-activity__photos"> - [% FOREACH p IN photos; - photo = p.get_photo_params; - %] + [% FOREACH p IN photos %] <a href="/report/[% p.id %]"> - <img border="0" height="100" src="[% photo.url_tn %]" + <img border="0" height="100" src="[% p.photos.first.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"> </a> [% END %] 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/_item.html b/templates/web/base/report/_item.html index d79a4e9f3..6ae43f798 100644 --- a/templates/web/base/report/_item.html +++ b/templates/web/base/report/_item.html @@ -1,9 +1,7 @@ <li class="item-list__item item-list--reports__item [% item_extra_class %]"> <a href="[% c.uri_for('/report', problem.id ) %]"> - [% IF problem.photo; - photo = problem.get_photo_params - %] - <img class="img" height="60" width="90" src="[% photo.url_fp %]" alt=""> + [% IF problem.photo %] + <img class="img" height="60" width="90" src="[% problem.photos.first.url_fp %]" alt=""> [% END %] <h4>[% problem.title | html %]</h4> <small> diff --git a/templates/web/base/report/banner.html b/templates/web/base/report/banner.html index bd7798d79..188e96502 100644 --- a/templates/web/base/report/banner.html +++ b/templates/web/base/report/banner.html @@ -1,22 +1,20 @@ [% USE date %] [% BLOCK banner %] -<p class="banner" id="[% id %]"> - [% text %] -</p> + <div class="banner"> + <p id="[% id %]">[% text %]</p> + </div> [% END %] [% IF problem.is_open AND date.now - problem.lastupdate.epoch > 8 * 7 * 24 * 60 * 60 %] - [% INCLUDE banner, id = 'unknown', text = loc('This problem is old and of unknown status.') %] + [% INCLUDE banner, id = 'unknown', text = loc('Unknown') %] [% END %] [% IF problem.is_fixed %] - [% INCLUDE banner, id = 'fixed', text = loc('This problem has been fixed') %] + [% INCLUDE banner, id = 'fixed', text = loc('Fixed') %] [% END %] [% IF problem.is_closed %] - [% INCLUDE banner, id = 'closed', text = loc('This problem has been closed') %] + [% INCLUDE banner, id = 'closed', text = loc('Closed') %] [% END %] [% states = [ 'investigating', 'in progress', 'planned', 'action scheduled' ]; IF states.grep(problem.state).size %] - [% INCLUDE banner, id = 'progress', text = loc('This problem is in progress') %] + [% INCLUDE banner, id = 'progress', text = loc('In progress') %] [% END %] - - diff --git a/templates/web/base/report/display.html b/templates/web/base/report/display.html index 329614488..5f499dd6e 100644 --- a/templates/web/base/report/display.html +++ b/templates/web/base/report/display.html @@ -1,60 +1,78 @@ [% + SET bodyclass = 'mappage'; + PROCESS "report/photo-js.html"; PROCESS "maps/${map.type}.html"; problem_title = problem.title_safe _ ' - ' _ loc('Viewing a problem'); - SET rss = [ tprintf(loc('Updates to this problem, %s', "%s is the site name"), site_name), "/rss/$problem.id" ] IF c.cobrand.moniker != 'emptyhomes'; - SET robots = 'index, nofollow'; - SET robots = 'noindex, nofollow' IF c.cobrand.moniker == 'emptyhomes'; INCLUDE 'header.html' title = problem_title + rss = [ tprintf(loc('Updates to this problem, %s', "%s is the site name"), site_name), "/rss/$problem.id" ] + robots = 'index, nofollow'; %] -[% IF c.cobrand.moniker != 'emptyhomes' %] - [% map_html %] - </div> -[% END %] - -<div id="side"> +[% map_html %] +</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' %] -<p align="right"> - <small> - <a rel="nofollow" href="[% c.uri_for( '/contact', { id => problem.id } ) %]">[% loc('Offensive? Unsuitable? Tell us' ) %]</a> - </small> -</p> +[% INCLUDE 'report/_main.html' %] +[% TRY %][% INCLUDE 'report/_message_manager.html' %][% CATCH file %][% END %] -[% IF c.cobrand.moniker != 'emptyhomes' %] -<p style="padding-bottom: 0.5em; border-bottom: dotted 1px #999999;" align="right"> - <a href="[% c.uri_for( '/around', { lat => latitude, lon => longitude } ) %]">[% loc( 'More problems nearby' ) %]</a> -</p> +<div class="shadow-wrap"> + <ul id="key-tools"> + [% IF c.user_exists AND c.cobrand.users_can_hide AND c.user.belongs_to_body( c.cobrand.council_id ) %] + <li><form method="post" action="/report/delete/[% problem.id %]" id="remove-from-site-form"> + <input type="submit" id="key-tool-report-abuse" class="abuse" value="Remove from site"> + </form></li> + [% ELSIF c.cobrand.moniker != 'zurich' %] + <li><a rel="nofollow" id="key-tool-report-abuse" class="abuse" href="[% c.uri_for( '/contact', { id => problem.id } ) %]">[% loc('Report abuse' ) %]</a></li> + [% END %] + [% IF c.cobrand.moniker != 'zurich' %] + <li><a rel="nofollow" id="key-tool-report-updates" class="feed" href="[% c.uri_for( '/alert/subscribe', { id => problem.id } ) %]">[% loc('Get updates' ) %]</a></li> + [% END %] + [% IF c.cobrand.moniker == 'fixmystreet' %] + <li><a rel="nofollow" id="key-tool-report-share" class="share" href="#report-share">[% loc('Share') %]</a></li> + [% END %] + [% IF c.cobrand.moniker == 'zurich' %] + <li><a class="chevron" id="key-tool-problems-nearby" href="[% c.uri_for( '/around', { lat => latitude, lon => longitude } ) %]">[% loc( 'Problems on the map' ) %]</a></li> + [% ELSE %] + <li><a class="chevron" id="key-tool-problems-nearby" href="[% c.uri_for( '/around', { lat => latitude, lon => longitude } ) %]">[% loc( 'Problems nearby' ) %]</a></li> + [% END %] + </ul> -<div id="alert_links"> - <a rel="nofollow" id="email_alert" href="[% c.uri_for( '/alert/subscribe', { id => problem.id } ) %]">[% loc('Email me updates' ) %]</a> +[% IF c.cobrand.moniker == 'fixmystreet' %] + <div id="report-share" class="hidden-js" align="center"> + <a href="https://twitter.com/share" class="twitter-share-button" data-text="I just reported ‘[% problem.title_safe | html %]’" data-via="fixmystreet" data-related="mysociety" data-count="none" data-dnt="true">Tweet</a> +<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> + <iframe src="//www.facebook.com/plugins/like.php?href=[% c.req.uri | uri %]&send=false&layout=button_count&width=90&show_faces=false&action=like&colorscheme=light&font&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe> + </div> +[% END %] - <form action="[% c.uri_for( '/alert/subscribe' ) %]" method="post" id="email_alert_box"> +<div id="report-updates-data" class="hidden-js"> + <form action="[% c.uri_for( '/alert/subscribe' ) %]" method="post"> + <a href="[% c.uri_for( '/rss', problem.id ) %]"> + <img src="/i/feed.png" width="16" height="16" title="[% loc('RSS feed') %]" alt="[% loc('RSS feed of updates to this problem' ) %]" border="0"> + </a> <p>[% loc('Receive email when updates are left on this problem.' ) %]</p> - <label class="n" for="alert_rznvy">[% loc('Email:') %]</label> - <input type="email" name="rznvy" id="alert_rznvy" value="[% email | html %]" size="30"> + <fieldset> + <label class="hidden n" for="alert_rznvy">[% loc('Your email') %]</label> + <div class="form-txt-submit-box"> + <input type="email" name="rznvy" id="alert_rznvy" value="[% email | html %]" size="30" placeholder="[% loc('Your email') %]"> + <input class="green-btn" type="submit" value="[% loc('Subscribe') %]"> + </div> <input type="hidden" name="id" value="[% problem.id %]"> <input type="hidden" name="type" value="updates"> - <input type="submit" value="[% loc('Subscribe') %]"> + </fieldset> </form> - - <a href="[% c.uri_for( '/rss', problem.id ) %]"> - <img src="/i/feed.png" width="16" height="16" title="[% loc('RSS feed') %]" alt="[% loc('RSS feed of updates to this problem' ) %]" border="0" style="vertical-align: middle"> - </a> </div> -[% INCLUDE 'report/updates.html' %] -[% INCLUDE 'report/update-form.html' %] -[% END %] - </div> +[% TRY %][% INCLUDE 'report/sharing.html' %][% CATCH file %][% END %] +[% INCLUDE 'report/updates.html' %] +[% INCLUDE 'report/update-form.html' %] [% INCLUDE 'footer.html' %] diff --git a/templates/web/base/report/photo.html b/templates/web/base/report/photo.html index 094f677d8..9be5b6538 100644 --- a/templates/web/base/report/photo.html +++ b/templates/web/base/report/photo.html @@ -1,21 +1,9 @@ [% IF c.cobrand.allow_photo_display(object) && object.photo %] - [% IF object.can('get_photoset') %] - [% FOR photo IN object.get_photoset(c).images %] + [% FOR photo IN object.photos %] <div class="update-img"> - <a href="[% c.cobrand.base_url %]/photo/[% object.id %].[% loop.index %].full.jpeg?[% photo.0 %]" rel="fancy"> - <img alt="Photo of this report" src="[% c.cobrand.base_url %]/photo/[% object.id %].[% loop.index %].jpeg?[% photo.0 %]"> + <a href="[% c.cobrand.base_url %][% photo.url_full %]" rel="fancy"> + <img alt="Photo of this report" src="[% c.cobrand.base_url %][% photo.url %]"> <span>zoom</span></a> </div> [% END %] - [% ELSE %] - [%# e.g. comments %] - [% photo = object.get_photo_params %] - <div class="update-img"> - [% IF photo.url_full %]<a href="[% photo.url_full %]" rel="fancy">[% END %] - <img alt="Photo of this report" - [%- IF photo.height %]height="[% photo.height %]" width="[% photo.width %]"[% END -%] - src="[% photo.url %]"> - [%- IF photo.url_full %]<span>zoom</span></a>[% END %] - </div> - [% END %] [% END %] diff --git a/templates/web/base/report/update-form.html b/templates/web/base/report/update-form.html index 3115855d3..8c812cd08 100644 --- a/templates/web/base/report/update-form.html +++ b/templates/web/base/report/update-form.html @@ -1,165 +1,162 @@ +[% allow_creation = !c.cobrand.only_authed_can_create || (c.user && c.user.from_body) %] +[% IF allow_creation %] <div id="update_form"> - <h2>[% loc( 'Provide an update') %]</h2> - [% IF c.cobrand.moniker != 'emptyhomes' %] - <p> - <small>[% loc( 'Please note that updates are not sent to the council. If you leave your name it will be public. Your information will only be used in accordance with our <a href="/faq#privacy">privacy policy</a>' ) %]</small> - </p> + [% IF c.cobrand.moniker != 'emptyhomes' AND c.cobrand.moniker != 'stevenage' %] + <div class="general-notes"> + [% INCLUDE 'report/updates-sidebar-notes.html' %] + </div> [% END %] [% INCLUDE 'errors.html' %] - <form method="post" action="[% c.uri_for( '/report/update' ) %]" name="updateForm" class="fieldset validate"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %]> - - <input type="hidden" name="submit_update" value="1"> - <input type="hidden" name="id" value="[% problem.id | html %]"> - - [% IF field_errors.update %] - <div class='form-error'>[% field_errors.update %]</div> - [% END %] - <div class="form-field"> - <label for="form_update">[% loc( 'Update:' ) %]</label> - <textarea name="update" id="form_update" rows="7" cols="30" required>[% update.text | html %]</textarea> - </div> - - [% IF c.user && c.user.belongs_to_body( problem.bodies_str ) %] - <div class="form-field"> - <label for="form_state">[% loc( 'State:' ) %]</label> - <select name="state" id="form_state"> - [% FOREACH state IN [ ['confirmed', loc('Open')], ['investigating', - loc('Investigating')], ['action scheduled', loc('Action Scheduled')], - ['in progress', loc('In Progress')], ['duplicate', loc('Duplicate')], - ['unable to fix', loc('Unable to fix')], ['not responsible', loc('Not Responsible')], - ['fixed', loc('Fixed')] ] %] - <option [% 'selected ' IF state.0 == problem.state %] value="[% state.0 %]">[% state.1 %]</option> - [% END %] - </select> - </div> - [% ELSE %] - [% IF problem.is_fixed AND ((c.user_exists AND c.user.id == problem.user_id) OR alert_to_reporter) %] - <div class="checkbox"> - <input type="checkbox" name="reopen" id="form_reopen" value="1"[% ' checked' IF update.mark_open %]> - <label class="inline" for="form_reopen">[% loc('This problem has not been fixed') %]</label> - </div> - [% ELSIF !problem.is_fixed %] - <div class="checkbox"> - <input type="checkbox" name="fixed" id="form_fixed" value="1"[% ' checked' IF update.mark_fixed %]> - <label class="inline" for="form_fixed">[% loc('This problem has been fixed') %]</label> - </div> - [% END %] - [% END %] + <form method="post" action="[% c.uri_for( '/report/update' ) %]" id="form_update_form" name="updateForm" class="validate"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %]> + <fieldset> + <input type="hidden" name="submit_update" value="1"> + <input type="hidden" name="id" value="[% problem.id | html %]"> [% IF c.cobrand.allow_photo_upload %] - [% IF field_errors.photo %] - <div class='form-error'>[% field_errors.photo %]</div> - [% END %] - <div id="fileupload_normalUI"> - [% IF upload_fileid %] - <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> - <input type="file" name="photo" id="form_photo" style="width:20em"> - </div> - [% END %] - -[% IF c.user_exists %] - - [% INCLUDE name %] - - <div class="checkbox"> - <input type="submit" id="update_post" value="[% loc('Post') %]"> - </div> - -[% ELSE %] - - [% IF field_errors.email %] - <div class='form-error'>[% field_errors.email %]</div> - [% END %] - <div class="form-field"> - <label for="form_rznvy">[% loc('Your email:' ) %]</label> - <input type="email" name="rznvy" id="form_rznvy" value="[% update.user.email | html %]" size="30" required> - </div> - -<div id="form_sign_in"> - <h3>[% loc("Now to submit your update…") %]</h3> - <h2>[% tprintf(loc("Do you have a %s password?", "%s is the site name"), site_name) %]</h2> - - <div id="form_sign_in_yes"> - - [% IF field_errors.password %] - <div class='form-error'>[% field_errors.password %]</div> + <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 %] - <p> - <label class="n" for="password_sign_in">[% loc('<strong>Yes</strong> I have a password') %]</label> - <input type="password" name="password_sign_in" id="password_sign_in" value="" size="25"> - </p> - - <div class="fieldset"> - - <p> - <input type="checkbox" id="remember_me" name="remember_me" value='1'[% ' checked' IF remember_me %]> - <label class="n" for="remember_me"> - [% loc('Keep me signed in on this computer') %] - </label> - </p> - - <p> - <input type="submit" name="submit_sign_in" id="submit_sign_in" value="[% loc('Post') %]"> - </p> - - </div> - - </div> - <div id="form_sign_in_no"> - - <p>[% loc('<strong>No</strong>, let me confirm my update by email:') %]</p> + <label for="form_update">[% loc( 'Update' ) %]</label> + [% IF field_errors.update %] + <div class='form-error'>[% field_errors.update %]</div> + [% END %] + <textarea rows="7" cols="30" name="update" id="form_update" placeholder="[% loc('Please write your update here') %]" required>[% update.text | html %]</textarea> + + [% IF c.user && c.user.belongs_to_body( problem.bodies_str ) %] + <label for="form_state">[% loc( 'State' ) %]</label> + <select name="state" id="form_state"> + [% FOREACH state IN [ ['confirmed', loc('Open')], ['investigating', + loc('Investigating')], ['action scheduled', loc('Action Scheduled')], + ['in progress', loc('In Progress')], ['duplicate', loc('Duplicate')], + ['unable to fix', loc('Unable to fix')], ['not responsible', loc('Not Responsible')], + ['fixed', loc('Fixed')] ] %] + <option [% 'selected ' IF state.0 == problem.state %] value="[% state.0 %]">[% state.1 %]</option> + [% END %] + </select> + [% ELSE %] + [% IF problem.is_fixed AND ((c.user_exists AND c.user.id == problem.user_id) OR alert_to_reporter) %] + + <input type="checkbox" name="reopen" id="form_reopen" value="1"[% ' checked' IF update.mark_open %]> + <label class="inline" for="form_reopen">[% loc('This problem has not been fixed') %]</label> + + [% ELSIF !problem.is_fixed %] + + <div class="checkbox-group"> + <input type="checkbox" name="fixed" id="form_fixed" value="1"[% ' checked' IF update.mark_fixed %]> + <label class="inline" for="form_fixed">[% loc('This problem has been fixed') %]</label> + </div> + + [% END %] + [% END %] - <div class="fieldset"> + [% IF c.user_exists %] [% INCLUDE name %] + + <input class="final-submit green-btn" type="submit" id="update_post" value="[% loc('Post') %]"> + - <div class="form-field"> - <label for="password_register">[% loc('Enter a new password:') %]</label> - <input type="password" name="password_register" id="password_register" value="" size="25"> - </div> - - <p style="clear:both"><small>[% loc('Providing a password is optional, but doing so will allow you to more easily report problems, leave updates and manage your reports.') %]</small></p> - - <p> - <input type="submit" name="submit_register" id="submit_register" value="[% loc('Post') %]"> - </p> - - </div> - - </div> - -</div> + [% ELSE %] -[% END %] + <label for="form_rznvy">[% loc('Your email' ) %] + <span class="muted">([% loc('We never show your email') %])</span> + </label> + [% IF field_errors.email %] + <p class='form-error'>[% field_errors.email %]</p> + [% END %] + <input type="email" name="rznvy" id="form_rznvy" value="[% update.user.email | html %]" placeholder="[% loc('Your email address' ) %]" required> + + <div id="form_sign_in"> + <h3>[% loc("Now to submit your update…") %]</h3> + <h2>[% tprintf(loc("Do you have a %s password?", "%s is the site name"), site_name) %]</h2> + + <div id="form_sign_in_yes" class="form-box"> + <h5>[% loc('<strong>Yes</strong> I have a password') %]</h5> + + <label class="hidden-js n" for="password_sign_in">[% loc('Yes I have a password') %]</label> + [% IF field_errors.password %] + <p class='form-error'>[% field_errors.password %]</p> + [% END %] + <div class="form-txt-submit-box"> + <input type="password" name="password_sign_in" id="password_sign_in" value="" placeholder="[% loc('Your password') %]"> + <input class="green-btn" type="submit" name="submit_sign_in" id="submit_sign_in" value="[% loc('Post') %]"> + </div> + + <div class="checkbox-group"> + <input type="checkbox" id="remember_me" name="remember_me" value='1'[% ' checked' IF remember_me %]> + <label class="inline n" for="remember_me">[% loc('Keep me signed in on this computer') %]</label> + </div> + + <div class="general-notes"> + <p><strong>[% loc('Forgotten your password?') %]</strong> + [% loc('Confirm by email below, providing a new password at that point. When you confirm, your password will be updated.') %]</p> + </div> + + </div> + <div id="form_sign_in_no" class="form-box"> + <h5>[% loc('<strong>No</strong> Let me confirm my update by email') %]</h5> + + [% INCLUDE name %] + + <label for="password_register">[% loc('Password (optional)') %]</label> + + <div class="general-notes"> + <p>[% loc('Providing a password is optional, but doing so will allow you to more easily report problems, leave updates and manage your reports.') %]</p> + </div> + + <div class="form-txt-submit-box"> + <input type="password" name="password_register" id="password_register" value="" placeholder="[% loc('Enter a password') %]"> + <input class="green-btn" type="submit" name="submit_register" id="submit_register" value="[% loc('Post') %]"> + </div> + + </div> + </div> + [% END %] + </fieldset> </form> </div> +[% END %] [% BLOCK name %] + [% INCLUDE 'report/new/extra_name.html' %] + <label for="form_name">[% loc('Name') %]</label> [% IF field_errors.name %] - <div class='form-error'>[% field_errors.name %]</div> + <p class='form-error'>[% field_errors.name %]</p> [% END %] + <input type="text" + [%- IF c.cobrand.moniker.match('fixmystreet|bromley') AND problem.bodies_str == '2482' %]class="validName" [% END -%] + name="name" id="form_name" value="[% update.name || c.user.name | html %]" placeholder="[% loc('Your name') %]"> - <div> - <label for="form_name">[% loc('Your name:') %]</label> - <input type="text" name="name" id="form_name" value="[% update.name || c.user.name | html %]" size="25"> - </div> - - <div class="checkbox"> + <div class="checkbox-group"> <input type="checkbox" name="may_show_name" id="form_may_show_name" value="1"[% ' checked' IF update.anonymous==0 OR (c.cobrand.default_show_name AND update.anonymous=='') %]> - <label for="form_may_show_name">[% loc('Show my name publicly') %]</label> - <small>[% loc('(we never show your email)') %]</small> + <label class="inline" for="form_may_show_name">[% loc('Show my name publicly') %]</label> </div> - - <div class="checkbox"> + <div class="checkbox-group"> <input type="checkbox" name="add_alert" id="form_add_alert" value="1"[% ' checked' IF add_alert %]> <label class="inline" for="form_add_alert">[% loc( 'Alert me to future updates' ) %]</label> </div> diff --git a/templates/web/base/report/update.html b/templates/web/base/report/update.html index a5fd97870..66e698606 100644 --- a/templates/web/base/report/update.html +++ b/templates/web/base/report/update.html @@ -1,24 +1,70 @@ +[% moderating = c.user && c.user.has_permission_to('moderate', problem.bodies_str) %] + [% IF loop.first %] -<div id="updates"> - <h2 class="problem-update-list-header">[% loc('Updates') %]</h2> +<section class="full-width"> + <h4 class="static-with-rule">[% loc('Updates') %]</h4> + <ul class="item-list item-list--updates"> [% END %] - <div><div class="problem-update"><p><a name="update_[% update.id %]"></a><em> - [% INCLUDE meta_line %] - </em></p></div> -[% IF NOT update.whenanswered %] - - [% INCLUDE 'report/photo.html' object=update %] - - <div class="update-text"> - [% add_links( update.text ) | html_para %] - - [% IF c.cobrand.allow_update_reporting %] - <p align="right"> - <small><a rel="nofollow" class="unsuitable-problem" href="[% c.uri_for( '/contact', { id => update.problem_id, update_id => update.id } ) %]">[% loc('Offensive? Unsuitable? Tell us') %]</a></small> - </p> - [% END %] - </div> + <li class="item-list__item item-list__item--updates"> + [% IF moderating; original_update = update.moderation_original_data %] + <form method="post" action="/moderate/report/[% problem.id %]/update/[% update.id %]"> + <input type="button" class="btn moderate moderate-display" value="moderate"> + <div class="moderate-edit"> + <input type="checkbox" class="hide-document" name="update_hide"> + <label for="update_hide">Hide update completely?</label> + <br /> + <input type="checkbox" name="update_show_name" [% update.anonymous ? '' : 'checked' %]> + <label for="update_show_name">Show name publicly?</label> + [% IF update.photo or original_update.photo %] + <br /> + <input type="checkbox" name="update_show_photo" [% update.photo ? 'checked' : '' %]> + <label for="update_show_photo">Show Photo?</label> + [% END %] + </div> + [% END %] + <div class="item-list__update-wrap"> + [% IF update.whenanswered %] + <div class="item-list__update-text"> + <p class="meta-2"> [% INCLUDE meta_line %] </p> + </div> + [% ELSE %] + [% INCLUDE 'report/photo.html' object=update %] + <div class="item-list__update-text"> + <div class="moderate-display"> + [% add_links( update.text ) | html_para %] + </div> + [% IF moderating %] + <div class="moderate-edit"> + [% IF update.text != original.detail %] + <input type="checkbox" name="update_revert_detail" class="revert-textarea"> + <label for="update_revert_detail">Revert to original</label> + [% END %] + <textarea name="update_detail">[% add_links( update.text ) %]</textarea> + </div> + [% END %] + <p class="meta-2"> + <a name="update_[% update.id %]"></a> + [% INCLUDE meta_line %] + [% mlog = update.latest_moderation_log_entry(); IF mlog %] + <br /> Moderated by [% mlog.user.from_body.name %] at [% prettify_dt(mlog.whenedited) %] + [% END %] + </p> + </div> + [% END %] + </div> + [% IF moderating %] + <div class="moderate-edit"> + <label for="moderation_reason">Moderation reason:</label> + <input type="text" name="moderation_reason" + placeholder="Describe why you are moderating this"> + <input type="submit" class="red-btn" value="moderate it"> + <input type="button" class="btn cancel" value="cancel"> + </div> + </form> + [% END %] + </li> +[% IF loop.last %] + </ul> +</section> [% END %] - </div> -[% '</div>' IF loop.last %] diff --git a/templates/web/base/report/updates-sidebar-notes.html b/templates/web/base/report/updates-sidebar-notes.html new file mode 100644 index 000000000..1426e4d71 --- /dev/null +++ b/templates/web/base/report/updates-sidebar-notes.html @@ -0,0 +1,4 @@ +<p> + [% loc( 'Please note that updates are not sent to the council.' ) %] + [% loc( 'Your information will only be used in accordance with our <a href="/privacy">privacy policy</a>' ) %] +</p> diff --git a/templates/web/bromley/report/_item.html b/templates/web/bromley/report/_item.html index 3bd8a8686..2540aec98 100644 --- a/templates/web/bromley/report/_item.html +++ b/templates/web/bromley/report/_item.html @@ -1,9 +1,7 @@ <li class="item-list__item item-list--reports__item item-list__item--with-pin [% c.cobrand.pin_colour(problem) %]"> <a class="[% problem.category %]" href="[% c.uri_for('/report', problem.id ) %]"> - [% IF problem.photo; - photo = problem.get_photo_params - %] - <img class="img" height="60" width="90" src="[% photo.url_fp %]" alt=""> + [% IF problem.photo %] + <img class="img" height="60" width="90" src="[% problem.photos.first.url_fp %]" alt=""> [% END %] <span>[% problem.title | html %]</span><br /> <small>[% prettify_dt( problem.confirmed, 1 ) %] diff --git a/templates/web/bromley/report/banner.html b/templates/web/bromley/report/banner.html new file mode 100644 index 000000000..ef9379f52 --- /dev/null +++ b/templates/web/bromley/report/banner.html @@ -0,0 +1,15 @@ +[% USE date %] + +[% BLOCK banner %] + <div class="banner"> + <p id="[% id %]">[% text %]</p> + </div> +[% END %] + +[% IF problem.is_fixed %] + [% INCLUDE banner, id = 'fixed', text = loc('Fixed') %] +[% END %] + +[% IF problem.is_closed %] + [% INCLUDE banner, id = 'closed', text = loc('Closed') %] +[% END %] 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 %] diff --git a/templates/web/emptyhomes/index.html b/templates/web/emptyhomes/index.html index ca70d1d9c..1d17c3423 100644 --- a/templates/web/emptyhomes/index.html +++ b/templates/web/emptyhomes/index.html @@ -45,11 +45,9 @@ [% IF recent_photos.size %] <p id="front_photos"> - [% FOREACH p IN recent_photos; - photo = p.get_photo_params; - %] + [% FOREACH p IN recent_photos %] <a href="/report/[% p.id %]"><img border="0" height="100" - src="[% photo.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"></a> + src="[% p.photos.first.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"></a> [% END %] </p> [% END %] diff --git a/templates/web/fixamingata/report/updates-sidebar-notes.html b/templates/web/fixamingata/report/updates-sidebar-notes.html new file mode 100644 index 000000000..bb75bd1f1 --- /dev/null +++ b/templates/web/fixamingata/report/updates-sidebar-notes.html @@ -0,0 +1 @@ +<p>[% loc( 'Your information will only be used in accordance with our <a href="/privacy">privacy policy</a>' ) %]</p> diff --git a/templates/web/fixmybarangay/alert/index.html b/templates/web/fixmybarangay/alert/index.html index c168fa41b..c842a7683 100644 --- a/templates/web/fixmybarangay/alert/index.html +++ b/templates/web/fixmybarangay/alert/index.html @@ -30,11 +30,9 @@ FixMyBarangay has a RSS feeds and email alerts for local problems. <div id="alert_recent"> <aside> <h2>[% loc('Some photos of recent reports') %]</h2> - [% FOREACH p IN photos; - photo = p.get_photo_params - %] + [% FOREACH p IN photos %] <a href="/report/[% p.id %]"><img border="0" height="100" - src="[% photo.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"></a> + src="[% p.photos.first.url_tn %]" alt="[% p.title | html %]" title="[% p.title | html %]"></a> [% END %] </aside> </div> diff --git a/templates/web/fixmystreet.com/report/banner.html b/templates/web/fixmystreet.com/report/banner.html new file mode 100644 index 000000000..35d7be179 --- /dev/null +++ b/templates/web/fixmystreet.com/report/banner.html @@ -0,0 +1,28 @@ +[% USE date %] + +[% BLOCK banner %] + <div class="banner"> + <p id="[% id %]">[% text %]</p> + </div> +[% END %] + +[% IF problem.is_fixed %] + [% INCLUDE banner, id = 'fixed', text = loc('Fixed') %] +[% END %] + +[% IF problem.is_closed %] + [% INCLUDE banner, id = 'closed', text = loc('Closed') %] +[% END %] + +[% IF NOT problem.bodies_str == '2482' %] + + [% IF problem.is_open AND date.now - problem.lastupdate.epoch > 8 * 7 * 24 * 60 * 60 %] + [% INCLUDE banner, id = 'unknown', text = loc('Unknown') %] + [% END %] + + [% states = [ 'investigating', 'in progress', 'planned', 'action scheduled' ]; + IF states.grep(problem.state).size %] + [% INCLUDE banner, id = 'progress', text = loc('In progress') %] + [% END %] + +[% END %] diff --git a/templates/web/fixmystreet.com/report/updates-sidebar-notes.html b/templates/web/fixmystreet.com/report/updates-sidebar-notes.html new file mode 100644 index 000000000..276ab4106 --- /dev/null +++ b/templates/web/fixmystreet.com/report/updates-sidebar-notes.html @@ -0,0 +1,6 @@ +<p> + [% IF problem.send_method_used != 'Open311' OR ( NOT problem.bodies_str.match('2482|2347') ) %] + [% loc( 'Please note that updates are not sent to the council.' ) %] + [% END %] + [% loc( 'Your information will only be used in accordance with our <a href="/privacy">privacy policy</a>' ) %] +</p> diff --git a/templates/web/fixmystreet/report/banner.html b/templates/web/fixmystreet/report/banner.html deleted file mode 100644 index 83c780958..000000000 --- a/templates/web/fixmystreet/report/banner.html +++ /dev/null @@ -1,21 +0,0 @@ -[% USE date %] -[% BLOCK banner %] - <div class="banner"> - <p id="[% id %]">[% text %]</p> - </div> -[% END %] - -[% IF c.cobrand.moniker != 'bromley' AND problem.bodies_str != '2482' AND problem.is_open AND date.now - problem.lastupdate.epoch > 8 * 7 * 24 * 60 * 60 %] - [% INCLUDE banner, id = 'unknown', text = loc('Unknown') %] -[% END %] -[% IF problem.is_fixed %] - [% INCLUDE banner, id = 'fixed', text = loc('Fixed') %] -[% END %] -[% IF problem.is_closed %] - [% INCLUDE banner, id = 'closed', text = loc('Closed') %] -[% END %] -[% states = [ 'investigating', 'in progress', 'planned', 'action scheduled' ]; - IF c.cobrand.moniker != 'bromley' AND problem.bodies_str != '2482' && states.grep(problem.state).size %] - [% INCLUDE banner, id = 'progress', text = loc('In progress') %] -[% END %] - diff --git a/templates/web/fixmystreet/report/display.html b/templates/web/fixmystreet/report/display.html deleted file mode 100644 index 5f499dd6e..000000000 --- a/templates/web/fixmystreet/report/display.html +++ /dev/null @@ -1,78 +0,0 @@ -[% - SET bodyclass = 'mappage'; - PROCESS "report/photo-js.html"; - PROCESS "maps/${map.type}.html"; - - problem_title = problem.title_safe _ ' - ' _ loc('Viewing a problem'); - INCLUDE 'header.html' - title = problem_title - rss = [ tprintf(loc('Updates to this problem, %s', "%s is the site name"), site_name), "/rss/$problem.id" ] - robots = 'index, nofollow'; -%] - -[% map_html %] -</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' %] -[% TRY %][% INCLUDE 'report/_message_manager.html' %][% CATCH file %][% END %] - -<div class="shadow-wrap"> - <ul id="key-tools"> - [% IF c.user_exists AND c.cobrand.users_can_hide AND c.user.belongs_to_body( c.cobrand.council_id ) %] - <li><form method="post" action="/report/delete/[% problem.id %]" id="remove-from-site-form"> - <input type="submit" id="key-tool-report-abuse" class="abuse" value="Remove from site"> - </form></li> - [% ELSIF c.cobrand.moniker != 'zurich' %] - <li><a rel="nofollow" id="key-tool-report-abuse" class="abuse" href="[% c.uri_for( '/contact', { id => problem.id } ) %]">[% loc('Report abuse' ) %]</a></li> - [% END %] - [% IF c.cobrand.moniker != 'zurich' %] - <li><a rel="nofollow" id="key-tool-report-updates" class="feed" href="[% c.uri_for( '/alert/subscribe', { id => problem.id } ) %]">[% loc('Get updates' ) %]</a></li> - [% END %] - [% IF c.cobrand.moniker == 'fixmystreet' %] - <li><a rel="nofollow" id="key-tool-report-share" class="share" href="#report-share">[% loc('Share') %]</a></li> - [% END %] - [% IF c.cobrand.moniker == 'zurich' %] - <li><a class="chevron" id="key-tool-problems-nearby" href="[% c.uri_for( '/around', { lat => latitude, lon => longitude } ) %]">[% loc( 'Problems on the map' ) %]</a></li> - [% ELSE %] - <li><a class="chevron" id="key-tool-problems-nearby" href="[% c.uri_for( '/around', { lat => latitude, lon => longitude } ) %]">[% loc( 'Problems nearby' ) %]</a></li> - [% END %] - </ul> - -[% IF c.cobrand.moniker == 'fixmystreet' %] - <div id="report-share" class="hidden-js" align="center"> - <a href="https://twitter.com/share" class="twitter-share-button" data-text="I just reported ‘[% problem.title_safe | html %]’" data-via="fixmystreet" data-related="mysociety" data-count="none" data-dnt="true">Tweet</a> -<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> - <iframe src="//www.facebook.com/plugins/like.php?href=[% c.req.uri | uri %]&send=false&layout=button_count&width=90&show_faces=false&action=like&colorscheme=light&font&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe> - </div> -[% END %] - -<div id="report-updates-data" class="hidden-js"> - <form action="[% c.uri_for( '/alert/subscribe' ) %]" method="post"> - <a href="[% c.uri_for( '/rss', problem.id ) %]"> - <img src="/i/feed.png" width="16" height="16" title="[% loc('RSS feed') %]" alt="[% loc('RSS feed of updates to this problem' ) %]" border="0"> - </a> - <p>[% loc('Receive email when updates are left on this problem.' ) %]</p> - <fieldset> - <label class="hidden n" for="alert_rznvy">[% loc('Your email') %]</label> - <div class="form-txt-submit-box"> - <input type="email" name="rznvy" id="alert_rznvy" value="[% email | html %]" size="30" placeholder="[% loc('Your email') %]"> - <input class="green-btn" type="submit" value="[% loc('Subscribe') %]"> - </div> - <input type="hidden" name="id" value="[% problem.id %]"> - <input type="hidden" name="type" value="updates"> - </fieldset> - </form> -</div> - -</div> - -[% TRY %][% INCLUDE 'report/sharing.html' %][% CATCH file %][% END %] -[% INCLUDE 'report/updates.html' %] -[% INCLUDE 'report/update-form.html' %] -[% INCLUDE 'footer.html' %] diff --git a/templates/web/fixmystreet/report/update-form.html b/templates/web/fixmystreet/report/update-form.html deleted file mode 100644 index a69b793b7..000000000 --- a/templates/web/fixmystreet/report/update-form.html +++ /dev/null @@ -1,152 +0,0 @@ -[% allow_creation = !c.cobrand.only_authed_can_create || (c.user && c.user.from_body) %] -[% IF allow_creation %] -<div id="update_form"> - <h2>[% loc( 'Provide an update') %]</h2> - - [% IF c.cobrand.moniker != 'emptyhomes' AND c.cobrand.moniker != 'stevenage' %] - <div class="general-notes"> - [% INCLUDE 'report/updates-sidebar-notes.html' %] - </div> - [% END %] - - [% INCLUDE 'errors.html' %] - - <form method="post" action="[% c.uri_for( '/report/update' ) %]" id="form_update_form" name="updateForm" class="validate"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %]> - <fieldset> - <input type="hidden" name="submit_update" value="1"> - <input type="hidden" name="id" value="[% problem.id | html %]"> - - <label for="form_update">[% loc( 'Update' ) %]</label> - [% IF field_errors.update %] - <div class='form-error'>[% field_errors.update %]</div> - [% END %] - <textarea rows="7" cols="30" name="update" id="form_update" placeholder="[% loc('Please write your update here') %]" required>[% update.text | html %]</textarea> - - [% IF c.user && c.user.belongs_to_body( problem.bodies_str ) %] - <label for="form_state">[% loc( 'State' ) %]</label> - <select name="state" id="form_state"> - [% FOREACH state IN [ ['confirmed', loc('Open')], ['investigating', - loc('Investigating')], ['action scheduled', loc('Action Scheduled')], - ['in progress', loc('In Progress')], ['duplicate', loc('Duplicate')], - ['unable to fix', loc('Unable to fix')], ['not responsible', loc('Not Responsible')], - ['fixed', loc('Fixed')] ] %] - <option [% 'selected ' IF state.0 == problem.state %] value="[% state.0 %]">[% state.1 %]</option> - [% END %] - </select> - [% ELSE %] - [% IF problem.is_fixed AND ((c.user_exists AND c.user.id == problem.user_id) OR alert_to_reporter) %] - - <input type="checkbox" name="reopen" id="form_reopen" value="1"[% ' checked' IF update.mark_open %]> - <label class="inline" for="form_reopen">[% loc('This problem has not been fixed') %]</label> - - [% ELSIF !problem.is_fixed %] - - <div class="checkbox-group"> - <input type="checkbox" name="fixed" id="form_fixed" value="1"[% ' checked' IF update.mark_fixed %]> - <label class="inline" for="form_fixed">[% loc('This problem has been fixed') %]</label> - </div> - - [% 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 %] - - <input class="final-submit green-btn" type="submit" id="update_post" value="[% loc('Post') %]"> - - - [% ELSE %] - - <label for="form_rznvy">[% loc('Your email' ) %] - <span class="muted">([% loc('We never show your email') %])</span> - </label> - [% IF field_errors.email %] - <p class='form-error'>[% field_errors.email %]</p> - [% END %] - <input type="email" name="rznvy" id="form_rznvy" value="[% update.user.email | html %]" placeholder="[% loc('Your email address' ) %]" required> - - <div id="form_sign_in"> - <h3>[% loc("Now to submit your update…") %]</h3> - <h2>[% tprintf(loc("Do you have a %s password?", "%s is the site name"), site_name) %]</h2> - - <div id="form_sign_in_yes" class="form-box"> - <h5>[% loc('<strong>Yes</strong> I have a password') %]</h5> - - <label class="hidden-js n" for="password_sign_in">[% loc('Yes I have a password') %]</label> - [% IF field_errors.password %] - <p class='form-error'>[% field_errors.password %]</p> - [% END %] - <div class="form-txt-submit-box"> - <input type="password" name="password_sign_in" id="password_sign_in" value="" placeholder="[% loc('Your password') %]"> - <input class="green-btn" type="submit" name="submit_sign_in" id="submit_sign_in" value="[% loc('Post') %]"> - </div> - - <div class="checkbox-group"> - <input type="checkbox" id="remember_me" name="remember_me" value='1'[% ' checked' IF remember_me %]> - <label class="inline n" for="remember_me">[% loc('Keep me signed in on this computer') %]</label> - </div> - - <div class="general-notes"> - <p><strong>[% loc('Forgotten your password?') %]</strong> - [% loc('Confirm by email below, providing a new password at that point. When you confirm, your password will be updated.') %]</p> - </div> - - </div> - <div id="form_sign_in_no" class="form-box"> - <h5>[% loc('<strong>No</strong> Let me confirm my update by email') %]</h5> - - [% INCLUDE name %] - - <label for="password_register">[% loc('Password (optional)') %]</label> - - <div class="general-notes"> - <p>[% loc('Providing a password is optional, but doing so will allow you to more easily report problems, leave updates and manage your reports.') %]</p> - </div> - - <div class="form-txt-submit-box"> - <input type="password" name="password_register" id="password_register" value="" placeholder="[% loc('Enter a password') %]"> - <input class="green-btn" type="submit" name="submit_register" id="submit_register" value="[% loc('Post') %]"> - </div> - - </div> - </div> - - [% END %] - </fieldset> - </form> -</div> -[% END %] - -[% BLOCK name %] - [% INCLUDE 'report/new/extra_name.html' %] - <label for="form_name">[% loc('Name') %]</label> - [% IF field_errors.name %] - <p class='form-error'>[% field_errors.name %]</p> - [% END %] - <input type="text" [% IF problem.bodies_str == '2482' %]class="validName" [% END %]name="name" id="form_name" value="[% update.name || c.user.name | html %]" placeholder="[% loc('Your name') %]"> - - <div class="checkbox-group"> - <input type="checkbox" name="may_show_name" id="form_may_show_name" value="1"[% ' checked' IF update.anonymous==0 OR (c.cobrand.default_show_name AND update.anonymous=='') %]> - <label class="inline" for="form_may_show_name">[% loc('Show my name publicly') %]</label> - </div> - <div class="checkbox-group"> - <input type="checkbox" name="add_alert" id="form_add_alert" value="1"[% ' checked' IF add_alert %]> - <label class="inline" for="form_add_alert">[% loc( 'Alert me to future updates' ) %]</label> - </div> -[% END %] diff --git a/templates/web/fixmystreet/report/update.html b/templates/web/fixmystreet/report/update.html deleted file mode 100644 index 66e698606..000000000 --- a/templates/web/fixmystreet/report/update.html +++ /dev/null @@ -1,70 +0,0 @@ -[% moderating = c.user && c.user.has_permission_to('moderate', problem.bodies_str) %] - -[% IF loop.first %] -<section class="full-width"> - <h4 class="static-with-rule">[% loc('Updates') %]</h4> - <ul class="item-list item-list--updates"> -[% END %] - <li class="item-list__item item-list__item--updates"> - [% IF moderating; original_update = update.moderation_original_data %] - <form method="post" action="/moderate/report/[% problem.id %]/update/[% update.id %]"> - <input type="button" class="btn moderate moderate-display" value="moderate"> - <div class="moderate-edit"> - <input type="checkbox" class="hide-document" name="update_hide"> - <label for="update_hide">Hide update completely?</label> - <br /> - <input type="checkbox" name="update_show_name" [% update.anonymous ? '' : 'checked' %]> - <label for="update_show_name">Show name publicly?</label> - [% IF update.photo or original_update.photo %] - <br /> - <input type="checkbox" name="update_show_photo" [% update.photo ? 'checked' : '' %]> - <label for="update_show_photo">Show Photo?</label> - [% END %] - </div> - [% END %] - <div class="item-list__update-wrap"> - [% IF update.whenanswered %] - <div class="item-list__update-text"> - <p class="meta-2"> [% INCLUDE meta_line %] </p> - </div> - [% ELSE %] - [% INCLUDE 'report/photo.html' object=update %] - <div class="item-list__update-text"> - <div class="moderate-display"> - [% add_links( update.text ) | html_para %] - </div> - [% IF moderating %] - <div class="moderate-edit"> - [% IF update.text != original.detail %] - <input type="checkbox" name="update_revert_detail" class="revert-textarea"> - <label for="update_revert_detail">Revert to original</label> - [% END %] - <textarea name="update_detail">[% add_links( update.text ) %]</textarea> - </div> - [% END %] - - <p class="meta-2"> - <a name="update_[% update.id %]"></a> - [% INCLUDE meta_line %] - [% mlog = update.latest_moderation_log_entry(); IF mlog %] - <br /> Moderated by [% mlog.user.from_body.name %] at [% prettify_dt(mlog.whenedited) %] - [% END %] - </p> - </div> - [% END %] - </div> - [% IF moderating %] - <div class="moderate-edit"> - <label for="moderation_reason">Moderation reason:</label> - <input type="text" name="moderation_reason" - placeholder="Describe why you are moderating this"> - <input type="submit" class="red-btn" value="moderate it"> - <input type="button" class="btn cancel" value="cancel"> - </div> - </form> - [% END %] - </li> -[% IF loop.last %] - </ul> -</section> -[% END %] diff --git a/templates/web/fixmystreet/report/updates-sidebar-notes.html b/templates/web/fixmystreet/report/updates-sidebar-notes.html deleted file mode 100644 index 9f2420392..000000000 --- a/templates/web/fixmystreet/report/updates-sidebar-notes.html +++ /dev/null @@ -1,7 +0,0 @@ - <p> - [% IF c.cobrand.moniker != 'fixamingata' %] - [% IF problem.send_method_used != 'Open311' OR c.cobrand.moniker != 'fixmystreet' OR ( problem.bodies_str != '2482' AND !problem.bodies_str.match('2347') ) %] - [% loc( 'Please note that updates are not sent to the council.' ) %] - [% END %] - [% END %] - [% loc( 'Your information will only be used in accordance with our <a href="/privacy">privacy policy</a>' ) %]</p> diff --git a/templates/web/zurich/admin/problem_row.html b/templates/web/zurich/admin/problem_row.html index baa8d3ac7..acbf17017 100644 --- a/templates/web/zurich/admin/problem_row.html +++ b/templates/web/zurich/admin/problem_row.html @@ -36,9 +36,9 @@ <td> [% IF problem.photo %] - [% FOR photo IN problem.get_photoset(c).images %] + [% FOR photo IN problem.photos %] <div class="update-img"> - <img height="60" width="90" alt="" src="[% c.cobrand.base_url %]/photo/[% photo.0 %].temp.jpeg"> + <img height="60" width="90" alt="" src="[% c.cobrand.base_url %][% photo.url_temp %]"> </div> [% END %] [% END %] diff --git a/templates/web/zurich/admin/report_edit-sdm.html b/templates/web/zurich/admin/report_edit-sdm.html index 8e576a718..a0ff1038d 100644 --- a/templates/web/zurich/admin/report_edit-sdm.html +++ b/templates/web/zurich/admin/report_edit-sdm.html @@ -82,10 +82,10 @@ [% IF problem.photo %] <dd> - [% FOR photo IN problem.get_photoset(c).images %] + [% FOR photo IN problem.photos %] <div class="update-img"> - <a href="[% c.cobrand.base_url %]/photo/[% photo.0 %].fulltemp.jpeg" rel="fancy"> - <img alt="Photo of this report" src="[% c.cobrand.base_url %]/photo/[% photo.0 %].temp.jpeg"> + <a href="[% c.cobrand.base_url %][% photo.url_temp_full %]" rel="fancy"> + <img alt="Photo of this report" src="[% c.cobrand.base_url %][% photo.url_temp %]"> <span>zoom</span> </a> </div> diff --git a/templates/web/zurich/admin/report_edit.html b/templates/web/zurich/admin/report_edit.html index 64d0950ee..dd876935c 100644 --- a/templates/web/zurich/admin/report_edit.html +++ b/templates/web/zurich/admin/report_edit.html @@ -106,10 +106,10 @@ [% IF problem.photo %] <dd> - [% FOR photo IN problem.get_photoset(c).images %] + [% FOR photo IN problem.photos %] <div class="update-img"> - <a href="[% c.cobrand.base_url %]/photo/[% photo.0 %].fulltemp.jpeg" rel="fancy"> - <img alt="Photo of this report" src="[% c.cobrand.base_url %]/photo/[% photo.0 %].temp.jpeg"> + <a href="[% c.cobrand.base_url %][% photo.url_temp_full %]" rel="fancy"> + <img alt="Photo of this report" src="[% c.cobrand.base_url %][% photo.url_temp %]"> <span>zoom</span> </a> </div> diff --git a/templates/web/zurich/admin/update_edit.html b/templates/web/zurich/admin/update_edit.html index ab40981a5..fbd96f3a5 100644 --- a/templates/web/zurich/admin/update_edit.html +++ b/templates/web/zurich/admin/update_edit.html @@ -29,8 +29,8 @@ <li>[% loc('Created:') %] [% PROCESS format_date this_date=update.created %] [% update.created.hms %]</li> [% IF update.photo %] -[% photo = update.get_photo_params %] -<li><img alt="" height="[% photo.height %]" width="[% photo.width %]" src="[% photo.url %]"> +[% photo = update.photos.first %] +<li><img alt="" src="[% photo.url %]"> <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> [% END %] diff --git a/templates/web/zurich/report/_item.html b/templates/web/zurich/report/_item.html index 9ba5e6fcb..a4d274a8e 100644 --- a/templates/web/zurich/report/_item.html +++ b/templates/web/zurich/report/_item.html @@ -1,9 +1,7 @@ <li class="item-list__item item-list--reports__item"> <a href="[% c.uri_for('/report', problem.id ) %]"> - [% IF problem.state != 'unconfirmed' AND problem.photo AND c.cobrand.allow_photo_display(problem); - photo = problem.get_photo_params - %] - <img class="img" height="60" width="90" src="[% photo.url_fp %]" alt=""> + [% IF problem.state != 'unconfirmed' AND problem.photo AND c.cobrand.allow_photo_display(problem) %] + <img class="img" height="60" width="90" src="[% problem.photos.first.url_fp %]" alt=""> [% END %] [% IF problem.state != 'unconfirmed' %] <h4>[% problem.title | html %]</h4> |