aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2013-05-13 12:28:18 +0100
committerMatthew Somerville <matthew@mysociety.org>2013-05-13 12:39:19 +0100
commitd290d52f48a167131cab3bdc6844888ed824d7fe (patch)
tree6bdb06fd9d5328a8c0a7ef22f11cb869c46652e9
parente0f04654af67eb27ac8e5876a4b39d0cde43f3cb (diff)
Consolidate photo display checking to one function.
-rw-r--r--perllib/FixMyStreet/App/Controller/Open311.pm2
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Rss.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm5
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm6
-rw-r--r--templates/web/default/report/photo.html2
-rw-r--r--templates/web/fixmystreet/report/photo-js.html2
-rw-r--r--templates/web/zurich/report/_item.html2
-rw-r--r--templates/web/zurich/report/_main.html2
8 files changed, 16 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm
index a4e72e9bd..b336a44f0 100644
--- a/perllib/FixMyStreet/App/Controller/Open311.pm
+++ b/perllib/FixMyStreet/App/Controller/Open311.pm
@@ -272,7 +272,7 @@ sub output_requests : Private {
$request->{'comment_count'} = [ $updates ];
}
- my $display_photos = $c->cobrand->allow_photo_display;
+ my $display_photos = $c->cobrand->allow_photo_display($problem);
if ($display_photos && $problem->photo) {
my $url = $c->cobrand->base_url();
my $imgurl = $url . "/photo/$id.full.jpeg";
diff --git a/perllib/FixMyStreet/App/Controller/Rss.pm b/perllib/FixMyStreet/App/Controller/Rss.pm
index 90ab7ad41..ed47f6f87 100755
--- a/perllib/FixMyStreet/App/Controller/Rss.pm
+++ b/perllib/FixMyStreet/App/Controller/Rss.pm
@@ -280,7 +280,7 @@ sub add_row : Private {
$item{pubDate} = $pubDate if $pubDate;
$item{category} = $row->{category} if $row->{category};
- if ($c->cobrand->allow_photo_display && $row->{photo}) {
+ if ($c->cobrand->allow_photo_display($row) && $row->{photo}) {
my $key = $alert_type->item_table eq 'comment' ? 'c/' : '';
$item{description} .= ent("\n<br><img src=\"". $base_url . "/photo/$key$row->{id}.jpeg\">");
}
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 96b3625a8..978968ba6 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -364,7 +364,10 @@ Return a boolean indicating whether the cobrand allows photo display
=cut
-sub allow_photo_display { return 1; }
+sub allow_photo_display {
+ my ( $self, $r ) = @_;
+ return 1;
+}
=head2 allow_update_reporting
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 9c725e7aa..7f7125b29 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -103,6 +103,12 @@ sub updates_as_hashref {
return $hashref;
}
+sub allow_photo_display {
+ my ( $self, $r ) = @_;
+ my $extra = ref($r) eq 'HASH' ? $r->{extra} : $r->extra;
+ return $extra->{publish_photo};
+}
+
sub show_unconfirmed_reports {
1;
}
diff --git a/templates/web/default/report/photo.html b/templates/web/default/report/photo.html
index 02ab9228b..c463c34c4 100644
--- a/templates/web/default/report/photo.html
+++ b/templates/web/default/report/photo.html
@@ -1,4 +1,4 @@
-[% IF c.cobrand.allow_photo_display && object.photo %]
+[% IF c.cobrand.allow_photo_display(object) && object.photo %]
[% photo = object.get_photo_params %]
<div class="update-img">
[% IF photo.url_full %]<a href="[% photo.url_full %]" rel="fancy">[% END
diff --git a/templates/web/fixmystreet/report/photo-js.html b/templates/web/fixmystreet/report/photo-js.html
index df0e2f92d..9075ce005 100644
--- a/templates/web/fixmystreet/report/photo-js.html
+++ b/templates/web/fixmystreet/report/photo-js.html
@@ -1,4 +1,4 @@
-[% IF c.cobrand.allow_photo_display %]
+[% IF c.cobrand.allow_photo_display(problem) %]
[% extra_css = BLOCK %]
<link rel="stylesheet" href="[% version('/js/fancybox/jquery.fancybox-1.3.4.css') %]">
[% END %]
diff --git a/templates/web/zurich/report/_item.html b/templates/web/zurich/report/_item.html
index 7adb7cdd4..22b39a2c8 100644
--- a/templates/web/zurich/report/_item.html
+++ b/templates/web/zurich/report/_item.html
@@ -1,6 +1,6 @@
<li>
<a class="text" href="[% c.uri_for('/report', problem.id ) %]">
- [% IF problem.state != 'unconfirmed' AND problem.photo AND problem.extra.publish_photo;
+ [% 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="">
diff --git a/templates/web/zurich/report/_main.html b/templates/web/zurich/report/_main.html
index c5fbabf1c..d80eeb9a4 100644
--- a/templates/web/zurich/report/_main.html
+++ b/templates/web/zurich/report/_main.html
@@ -6,7 +6,7 @@
</p>
[% IF problem.state != 'unconfirmed' %]
- [% IF problem.extra.publish_photo %]
+ [% IF c.cobrand.allow_photo_display(problem) %]
[% INCLUDE 'report/photo.html' object=problem %]
[% END %]
[% add_links( problem.detail ) | html_para %]