diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Open311.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Photo.pm | 2 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Rss.pm | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 3 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 78 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 20 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 32 | ||||
-rw-r--r-- | perllib/FixMyStreet/Roles/PhotoSet.pm | 34 | ||||
-rw-r--r-- | t/app/controller/rss.t | 60 | ||||
-rw-r--r-- | t/cobrand/zurich.t | 34 | ||||
-rw-r--r-- | templates/web/base/report/photo.html | 14 | ||||
-rw-r--r-- | templates/web/zurich/admin/report_edit.html | 6 | ||||
-rw-r--r-- | templates/web/zurich/report/_item.html | 6 | ||||
-rw-r--r-- | templates/web/zurich/report/_main.html | 4 |
14 files changed, 146 insertions, 156 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm index 95b29d116..c7e4e5bee 100644 --- a/perllib/FixMyStreet/App/Controller/Open311.pm +++ b/perllib/FixMyStreet/App/Controller/Open311.pm @@ -284,7 +284,7 @@ sub output_requests : Private { my $display_photos = $c->cobrand->allow_photo_display($problem); if ($display_photos && $problem->photo) { my $url = $c->cobrand->base_url(); - my $imgurl = $url . $problem->photos->[0]->{url_full}; + my $imgurl = $url . $problem->photos->[$display_photos-1]->{url_full}; $request->{'media_url'} = $imgurl; } push(@problemlist, $request); diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm index 2302322bf..f41702dcf 100644 --- a/perllib/FixMyStreet/App/Controller/Photo.pm +++ b/perllib/FixMyStreet/App/Controller/Photo.pm @@ -63,7 +63,7 @@ sub index :LocalRegex('^(c/)?([1-9]\d*)(?:\.(\d+))?(?:\.(full|tn|fp))?\.(?:jpeg| $c->detach( 'no_photo' ) unless $item; - $c->detach( 'no_photo' ) unless $c->cobrand->allow_photo_display($item); # Should only be for reports, not updates + $c->detach( 'no_photo' ) unless $c->cobrand->allow_photo_display($item, $photo_number); # Should only be for reports, not updates my $photo; $photo = $item->get_photoset diff --git a/perllib/FixMyStreet/App/Controller/Rss.pm b/perllib/FixMyStreet/App/Controller/Rss.pm index 7cf4783c0..e1da4445d 100755 --- a/perllib/FixMyStreet/App/Controller/Rss.pm +++ b/perllib/FixMyStreet/App/Controller/Rss.pm @@ -282,14 +282,15 @@ sub add_row : Private { $item{pubDate} = $pubDate if $pubDate; $item{category} = encode_entities($row->{category}) if $row->{category}; - if ($c->cobrand->allow_photo_display($row) && $row->{photo}) { + if ((my $photo_to_show = $c->cobrand->allow_photo_display($row)) && $row->{photo}) { # Bit yucky as we don't have full objects here my $photoset = FixMyStreet::App::Model::PhotoSet->new({ db_data => $row->{photo} }); - my $first_fn = $photoset->get_id(0); + my $idx = $photo_to_show - 1; + my $first_fn = $photoset->get_id($idx); my ($hash, $format) = split /\./, $first_fn; my $cachebust = substr($hash, 0, 8); my $key = $alert_type->item_table eq 'comment' ? 'c/' : ''; - $item{description} .= encode_entities("\n<br><img src=\"". $base_url . "/photo/$key$row->{id}.0.$format?$cachebust\">"); + $item{description} .= encode_entities("\n<br><img src=\"". $base_url . "/photo/$key$row->{id}.$idx.$format?$cachebust\">"); } if ( $row->{used_map} ) { diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 4c521eaaa..7888f8ccf 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -465,11 +465,12 @@ sub allow_photo_upload { return 1; } =item allow_photo_display Return a boolean indicating whether the cobrand allows photo display +for the particular report and photo. =cut sub allow_photo_display { - my ( $self, $r ) = @_; + my ( $self, $r, $num ) = @_; return 1; } diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 674b870ac..f0308d6d7 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -4,6 +4,7 @@ use base 'FixMyStreet::Cobrand::Default'; use DateTime; use POSIX qw(strcoll); use RABX; +use List::Util qw(min); use Scalar::Util 'blessed'; use DateTime::Format::Pg; @@ -223,19 +224,30 @@ sub updates_as_hashref { return $hashref; } +# If $num is undefined, we want to return the minimum photo number that can be +# shown (1-indexed), or false for no display. If $num is defined, return +# boolean whether that indexed photo can be shown. sub allow_photo_display { - my ( $self, $r ) = @_; + my ( $self, $r, $num ) = @_; + my $publish_photo; if (blessed $r) { - return $r->get_extra_metadata( 'publish_photo' ); + $publish_photo = $r->get_extra_metadata('publish_photo'); + } else { + # additional munging in case $r isn't an object, TODO see if we can remove this + my $extra = $r->{extra}; + utf8::encode($extra) if utf8::is_utf8($extra); + my $h = new IO::String($extra); + $extra = RABX::wire_rd($h); + return unless ref $extra eq 'HASH'; + $publish_photo = $extra->{publish_photo}; } + # Old style stored 1/0 integer, which can still be used if present. + return $publish_photo unless ref $publish_photo; + return $publish_photo->{$num} if defined $num; - # additional munging in case $r isn't an object, TODO see if we can remove this - my $extra = $r->{extra}; - utf8::encode($extra) if utf8::is_utf8($extra); - my $h = new IO::String($extra); - $extra = RABX::wire_rd($h); - return unless ref $extra eq 'HASH'; - return $extra->{publish_photo}; + # We return a 1-indexed number so that '0' can be taken as 'not allowed' + my $i = min grep { $publish_photo->{$_} } keys %$publish_photo; + return $i + 1; } sub show_unconfirmed_reports { @@ -581,7 +593,19 @@ sub admin_report_edit { # Problem updates upon submission if ( ($type eq 'super' || $type eq 'dm') && $c->get_param('submit') ) { - $problem->set_extra_metadata('publish_photo' => $c->get_param('publish_photo') || 0 ); + + my @keys = grep { /^publish_photo/ } keys %{ $c->req->params }; + my %publish_photo; + foreach my $key (@keys) { + my ($index) = $key =~ /(\d+)$/; + $publish_photo{$index} = 1 if $c->get_param($key); + } + + if (%publish_photo) { + $problem->set_extra_metadata('publish_photo' => \%publish_photo); + } else { + $problem->unset_extra_metadata('publish_photo'); + } $problem->set_extra_metadata('third_personal' => $c->get_param('third_personal') || 0 ); # Make sure we have a copy of the original detail field @@ -1020,23 +1044,28 @@ sub _admin_send_email { sub munge_sendreport_params { my ($self, $row, $h, $params) = @_; - if ($row->state =~ /^(closed|investigating)$/ && $row->get_extra_metadata('publish_photo')) { + + if ($row->state =~ /^(closed|investigating)$/) { # we attach images to reports sent to external bodies my $photoset = $row->get_photoset(); my $num = $photoset->num_images or return; my $id = $row->id; my @attachments = map { - my $image = $photoset->get_raw_image($_); - { - body => $image->{data}, - attributes => { - filename => "$id.$_." . $image->{extension}, - content_type => $image->{content_type}, - encoding => 'base64', - # quoted-printable ends up with newlines corrupting binary data - name => "$id.$_." . $image->{extension}, - }, + if ($self->allow_photo_display($row, $_)) { + my $image = $photoset->get_raw_image($_); + { + body => $image->{data}, + attributes => { + filename => "$id.$_." . $image->{extension}, + content_type => $image->{content_type}, + encoding => 'base64', + # quoted-printable ends up with newlines corrupting binary data + name => "$id.$_." . $image->{extension}, + }, + }; + } else { + (); } } (0..$num-1); $params->{_attachments_} = \@attachments; @@ -1180,7 +1209,10 @@ 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->photos} && $c->cobrand->allow_photo_display($report) ) ? ($c->cobrand->base_url . $report->photos->[0]->{url}) : ''; + my $photo_to_display = $c->cobrand->allow_photo_display($report); + my $media_url = (@{$report->photos} && $photo_to_display) + ? $c->cobrand->base_url . $report->photos->[$photo_to_display-1]->{url} + : ''; my @columns = ( $report->id, @@ -1246,7 +1278,7 @@ sub admin_stats { # pictures taken my $pictures_taken = $c->model('DB::Problem')->search( { photo => { '!=', undef }, %params } )->count; # pictures published - my $pictures_published = $c->model('DB::Problem')->search( { extra => { like => '%publish_photo,I1:1%' }, %params } )->count; + my $pictures_published = $c->model('DB::Problem')->search( { extra => { like => '%publish_photo%' }, %params } )->count; # how many times was a telephone number provided # XXX => How many users have a telephone number stored # my $phone = $c->model('DB::User')->search( { phone => { '!=', undef } } )->count; diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 60fd31510..4e869ab24 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -156,26 +156,6 @@ sub url { return "/report/" . $self->problem_id . '#update_' . $self->id; } -sub photos { - my $self = shift; - my $photoset = $self->get_photoset; - my $i = 0; - my $id = $self->id; - my @photos = map { - my $cachebust = substr($_, 0, 8); - my ($hash, $format) = split /\./, $_; - { - id => $hash, - url_temp => "/photo/temp.$hash.$format", - url_temp_full => "/photo/fulltemp.$hash.$format", - url => "/photo/c/$id.$i.$format?$cachebust", - url_full => "/photo/c/$id.$i.full.$format?$cachebust", - idx => $i++, - } - } $photoset->all_ids; - return \@photos; -} - =head2 latest_moderation_log_entry Return most recent ModerationLog object diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 8625bf17a..a32c17ffb 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -919,38 +919,6 @@ sub latest_moderation_log_entry { return $self->admin_log_entries->search({ action => 'moderation' }, { order_by => { -desc => 'id' } })->first; } -sub photos { - my $self = shift; - my $photoset = $self->get_photoset; - my $i = 0; - my $id = $self->id; - my @photos = map { - my $cachebust = substr($_, 0, 8); - # Some Varnish configurations (e.g. on mySociety infra) strip cookies from - # images, which means image requests will be redirected to the login page - # if LOGIN_REQUIRED is set. To stop this happening, Varnish should be - # configured to not strip cookies if the cookie_passthrough param is - # present, which this line ensures will be if LOGIN_REQUIRED is set. - my $extra = ''; - if (FixMyStreet->config('LOGIN_REQUIRED')) { - $cachebust .= '&cookie_passthrough=1'; - $extra = '?cookie_passthrough=1'; - } - my ($hash, $format) = split /\./, $_; - { - id => $hash, - url_temp => "/photo/temp.$hash.$format$extra", - url_temp_full => "/photo/fulltemp.$hash.$format$extra", - 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++, - } - } $photoset->all_ids; - return \@photos; -} - __PACKAGE__->has_many( "admin_log_entries", "FixMyStreet::DB::Result::AdminLog", diff --git a/perllib/FixMyStreet/Roles/PhotoSet.pm b/perllib/FixMyStreet/Roles/PhotoSet.pm index 9607b5049..2a6863cff 100644 --- a/perllib/FixMyStreet/Roles/PhotoSet.pm +++ b/perllib/FixMyStreet/Roles/PhotoSet.pm @@ -32,4 +32,38 @@ sub get_first_image_fp { return $self->get_photoset->get_image_data( num => 0, size => 'fp' ); } +sub photos { + my $self = shift; + my $photoset = $self->get_photoset; + my $i = 0; + my $id = $self->id; + my $typ = $self->result_source->name eq 'comment' ? 'c/' : ''; + + my @photos = map { + my $cachebust = substr($_, 0, 8); + # Some Varnish configurations (e.g. on mySociety infra) strip cookies from + # images, which means image requests will be redirected to the login page + # if LOGIN_REQUIRED is set. To stop this happening, Varnish should be + # configured to not strip cookies if the cookie_passthrough param is + # present, which this line ensures will be if LOGIN_REQUIRED is set. + my $extra = ''; + if (FixMyStreet->config('LOGIN_REQUIRED')) { + $cachebust .= '&cookie_passthrough=1'; + $extra = '?cookie_passthrough=1'; + } + my ($hash, $format) = split /\./, $_; + { + id => $hash, + url_temp => "/photo/temp.$hash.$format$extra", + url_temp_full => "/photo/fulltemp.$hash.$format$extra", + url => "/photo/$typ$id.$i.$format?$cachebust", + url_full => "/photo/$typ$id.$i.full.$format?$cachebust", + url_tn => "/photo/$typ$id.$i.tn.$format?$cachebust", + url_fp => "/photo/$typ$id.$i.fp.$format?$cachebust", + idx => $i++, + } + } $photoset->all_ids; + return \@photos; +} + 1; diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t index 171121eaa..a8101b593 100644 --- a/t/app/controller/rss.t +++ b/t/app/controller/rss.t @@ -14,28 +14,19 @@ my $user1 = $mech->create_user_ok('reporter-rss@example.com', name => 'Reporter my $dt_parser = FixMyStreet::App->model('DB')->schema->storage->datetime_parser; -my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { +my ($report) = $mech->create_problems_for_body(1, 2651, '', { postcode => 'eh1 1BB', - bodies_str => '2651', areas => ',11808,135007,14419,134935,2651,20728,', category => 'Street lighting', title => '&Test’i<n>g \'☃"', detail => 'Testing Detail', - used_map => 1, name => $user1->name, - anonymous => 0, - state => 'confirmed', confirmed => $dt_parser->format_datetime($dt), lastupdate => $dt_parser->format_datetime($dt), whensent => $dt_parser->format_datetime($dt->clone->add( minutes => 5 )), - lang => 'en-gb', - service => '', - cobrand => 'default', - cobrand_data => '', - send_questionnaire => 1, latitude => '55.951963', longitude => '-3.189944', - user_id => $user1->id, + user => $user1, } ); $mech->host('www.fixmystreet.com'); @@ -127,54 +118,19 @@ $report->delete(); my $council = $mech->create_body_ok(2333, 'Hart Council'); my $county = $mech->create_body_ok(2227, 'Hampshire Council'); -my $now = DateTime->now(); -my $report_to_council = FixMyStreet::App->model('DB::Problem')->find_or_create( - { - postcode => 'GU51 4AE', - bodies_str => $council->id, +my ($report_to_council) = $mech->create_problems_for_body(1, $council->id, '', { + user => $user1, areas => ',2333,2227,', - category => 'Other', - title => 'council report', - detail => 'Test 2 Detail', - used_map => 't', - name => 'Test User', - anonymous => 'f', - state => 'closed', - confirmed => $now->ymd . ' ' . $now->hms, - lang => 'en-gb', - service => '', - cobrand => 'default', - cobrand_data => '', - send_questionnaire => 't', latitude => '51.279616', longitude => '-0.846040', - user_id => $user1->id, - } -); +}); -my $report_to_county_council = FixMyStreet::App->model('DB::Problem')->find_or_create( - { - postcode => 'GU51 4AE', - bodies_str => $county->id, +my ($report_to_county_council) = $mech->create_problems_for_body(1, $county->id, '', { + user => $user1, areas => ',2333,2227,', - category => 'Other', - title => 'county report', - detail => 'Test 2 Detail', - used_map => 't', - name => 'Test User', - anonymous => 'f', - state => 'closed', - confirmed => $now->ymd . ' ' . $now->hms, - lang => 'en-gb', - service => '', - cobrand => 'default', - cobrand_data => '', - send_questionnaire => 't', latitude => '51.279616', longitude => '-0.846040', - user_id => $user1->id, - } -); +}); subtest "check RSS feeds on cobrand have correct URLs for non-cobrand reports" => sub { $mech->host('hart.fixmystreet.com'); diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index e0671db2a..7a267a1af 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -3,6 +3,7 @@ use DateTime; use Email::MIME; +use File::Temp; use LWP::Protocol::PSGI; use Test::LongString; use Path::Tiny; @@ -24,7 +25,6 @@ my $cobrand = FixMyStreet::Cobrand::Zurich->new(); my $sample_file = path(__FILE__)->parent->parent->child("app/controller/sample.jpg"); ok $sample_file->exists, "sample file $sample_file exists"; -my $sample_photo = $sample_file->slurp_raw; # This is a helper method that will send the reports but with the config # correctly set - notably STAGING_FLAGS send_reports needs to be true, and @@ -102,7 +102,7 @@ my $superuser; subtest "set up superuser" => sub { $superuser = $mech->log_in_ok( 'super@example.org' ); # a user from body $zurich is a superuser, as $zurich has no parent id! - $superuser->update({ from_body => $zurich->id }); + $superuser->update({ from_body => $zurich->id }); $EXISTING_REPORT_COUNT = get_export_rows_count($mech); $mech->log_out_ok; }; @@ -111,7 +111,6 @@ my @reports = $mech->create_problems_for_body( 1, $division->id, 'Test', { state => 'unconfirmed', confirmed => undef, cobrand => 'zurich', - photo => $sample_photo, areas => ',423017,', }); my $report = $reports[0]; @@ -314,15 +313,30 @@ subtest "report_edit" => sub { } }; +# Give the report three photos +my $UPLOAD_DIR = File::Temp->newdir(); +my @files = map { $_ x 40 . ".jpeg" } (1..3); +$sample_file->copy(path($UPLOAD_DIR, $_)) for @files; +$report->photo(join(',', @files)); +$report->update; + FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'zurich' ], + MAPIT_URL => 'http://mapit.zurich/', MAP_TYPE => 'Zurich,OSM', + UPLOAD_DIR => $UPLOAD_DIR, }, sub { # Photo publishing $mech->get_ok( '/admin/report_edit/' . $report->id ); - $mech->submit_form_ok( { with_fields => { state => 'confirmed', publish_photo => 1 } } ); + $mech->submit_form_ok( { with_fields => { state => 'confirmed', publish_photo_1 => 1 } } ); + $mech->get_ok( '/around?lat=' . $report->latitude . ';lon=' . $report->longitude); + $mech->content_lacks('photo/' . $report->id . '.0.fp.jpeg'); + $mech->content_contains('photo/' . $report->id . '.1.fp.jpeg'); + $mech->content_lacks('photo/' . $report->id . '.2.fp.jpeg'); $mech->get_ok( '/report/' . $report->id ); - $mech->content_contains('photo/' . $report->id . '.0.jpeg'); + $mech->content_lacks('photo/' . $report->id . '.0.jpeg'); + $mech->content_contains('photo/' . $report->id . '.1.jpeg'); + $mech->content_lacks('photo/' . $report->id . '.2.jpeg'); # Internal notes $mech->get_ok( '/admin/report_edit/' . $report->id ); @@ -450,12 +464,16 @@ $mech->content_contains( DateTime->now->strftime("%d.%m.%Y") ); # User confirms their email address $report->set_extra_metadata(email_confirmed => 1); +$report->confirmed(DateTime->now); $report->update; FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'zurich' ], MAP_TYPE => 'Zurich,OSM', }, sub { + # Quick RSS check here, while we have a report + $mech->get_ok('/rss/problems'); + $mech->get_ok( '/admin/report_edit/' . $report->id ); $mech->content_lacks( 'Unbestätigt' ); # Confirmed email $mech->submit_form_ok( { with_fields => { status_update => 'FINAL UPDATE' } } ); @@ -479,7 +497,6 @@ $mech->clear_emails_ok; state => 'unconfirmed', confirmed => undef, cobrand => 'zurich', - photo => $sample_photo, areas => ',423017,', }); $report = $reports[0]; @@ -521,7 +538,6 @@ $mech->email_count_is(0); state => 'unconfirmed', confirmed => undef, cobrand => 'zurich', - photo => $sample_photo, areas => ',423017,', }); $report = $reports[0]; @@ -829,7 +845,7 @@ subtest "test stats" => sub { $mech->content_contains('Innerhalb von fünf Arbeitstagen abgeschlossen: 3'); # my @data = $mech->content =~ /(?:moderiert|abgeschlossen): \d+/g; # diag Dumper(\@data); use Data::Dumper; - + my $export_count = get_export_rows_count($mech); if (defined $export_count) { is $export_count - $EXISTING_REPORT_COUNT, 3, 'Correct number of reports'; @@ -864,7 +880,7 @@ subtest 'email images to external partners' => sub { }); my $fileid = $photoset->data; - $report->set_extra_metadata('publish_photo' => 1); + $report->set_extra_metadata('publish_photo' => { 0 => 1 }); # The below email comparison must not have an external message. $report->unset_extra_metadata('external_message'); $report->update({ diff --git a/templates/web/base/report/photo.html b/templates/web/base/report/photo.html index aa82baef6..5474fad28 100644 --- a/templates/web/base/report/photo.html +++ b/templates/web/base/report/photo.html @@ -1,13 +1,15 @@ -[% IF c.cobrand.allow_photo_display(object) && object.photo %] +[% IF object.photo %] [% IF object.photos.size > 1 %] <div class="update-img-set"> [% END %] [% FOR photo IN object.photos %] - <div class="update-img"> - <a href="[% photo.url_full %]" rel="fancy"> - <img alt="Photo of this report" src="[% photo.url %]"> - <span>zoom</span></a> - </div> + [% IF c.cobrand.allow_photo_display(object, photo.idx) %] + <div class="update-img"> + <a href="[% photo.url_full %]" rel="fancy"> + <img alt="Photo of this report" src="[% photo.url %]"> + <span>zoom</span></a> + </div> + [% END %] [% END %] [% IF object.photos.size > 1 %] </div> diff --git a/templates/web/zurich/admin/report_edit.html b/templates/web/zurich/admin/report_edit.html index 9e4114447..fd03fb044 100644 --- a/templates/web/zurich/admin/report_edit.html +++ b/templates/web/zurich/admin/report_edit.html @@ -117,10 +117,10 @@ </div> <input type="submit" name="rotate_photo_[% loop.index %]" value="[% loc('Rotate Left') %]" class="screen-only"> <input type="submit" name="rotate_photo_[% loop.index %]" value="[% loc('Rotate Right') %]" class="screen-only"> + <br> + <input type="checkbox" id="publish_photo_[% loop.index %]" name="publish_photo_[% loop.index %]" value="1"[% ' checked' IF problem.extra.publish_photo.${loop.index} %] class="screen-only"> + <label class="inline screen-only" for="publish_photo_[% loop.index %]">[% loc("Publish photo") %]</label></li> [% END %] - <br> - <input type="checkbox" id="publish_photo" name="publish_photo" value="1"[% ' checked' IF problem.extra.publish_photo %] class="screen-only"> - <label class="inline screen-only" for="publish_photo">[% loc("Publish photo") %]</label></li> [% END %] </dl> diff --git a/templates/web/zurich/report/_item.html b/templates/web/zurich/report/_item.html index 560cbac51..ccae84271 100644 --- a/templates/web/zurich/report/_item.html +++ b/templates/web/zurich/report/_item.html @@ -1,7 +1,9 @@ <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) %] - <img class="img" height="60" width="90" src="[% problem.photos.first.url_fp %]" alt=""> + [% photo_to_display = c.cobrand.allow_photo_display(problem) %] + [% IF problem.state != 'unconfirmed' AND problem.photo AND photo_to_display %] + [% photo_idx = photo_to_display - 1 ~%] + <img class="img" height="60" width="90" src="[% problem.photos.${photo_idx}.url_fp %]" alt=""> [% END %] [% IF problem.state != 'unconfirmed' %] <h3 class="item-list__heading">[% problem.title | html %]</h3> diff --git a/templates/web/zurich/report/_main.html b/templates/web/zurich/report/_main.html index b868c03e2..912e8b0c9 100644 --- a/templates/web/zurich/report/_main.html +++ b/templates/web/zurich/report/_main.html @@ -6,9 +6,7 @@ </p> [% IF problem.state != 'unconfirmed' %] - [% IF c.cobrand.allow_photo_display(problem) %] - [% INCLUDE 'report/photo.html' object=problem %] - [% END %] + [% INCLUDE 'report/photo.html' object=problem %] [% problem.detail | add_links | html_para %] [% ELSE %] [% loc('This report is awaiting moderation.') %] |