aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/Cobrand.pm39
-rwxr-xr-xt/Cobrand.t28
-rw-r--r--t/Cobrands/Mysite/Util.pm10
3 files changed, 73 insertions, 4 deletions
diff --git a/perllib/Cobrand.pm b/perllib/Cobrand.pm
index d4d76aeec..7611103d5 100644
--- a/perllib/Cobrand.pm
+++ b/perllib/Cobrand.pm
@@ -7,7 +7,7 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: Cobrand.pm,v 1.28 2009-10-19 11:10:32 louise Exp $
+# $Id: Cobrand.pm,v 1.29 2009-10-19 16:44:55 louise Exp $
package Cobrand;
use strict;
@@ -490,6 +490,43 @@ sub allow_photo_upload {
}
}
+=item allow_photo_display COBRAND
+
+Return a boolean indicating whether the cobrand allows photo display
+
+=cut
+
+sub allow_photo_display {
+ my ($cobrand) = @_;
+ my $handle;
+ if ($cobrand){
+ $handle = cobrand_handle($cobrand);
+ }
+ if ( !$cobrand || !$handle || !$handle->can('allow_photo_display')){
+ return 1;
+ } else{
+ return $handle->allow_photo_display();
+ }
+}
+
+=item location_check COBRAND LOCATION QUERY
+
+Return a boolean indicating whether the location passed any extra location checks defined by the cobrand
+using data in the query
+=cut
+sub location_check {
+ my ($cobrand, $location, $query) = @_;
+ my $handle;
+ if ($cobrand){
+ $handle = cobrand_handle($cobrand);
+ }
+ if ( !$cobrand || !$handle || !$handle->can('location_check')){
+ return 1;
+ } else{
+ return $handle->location_check($location, $query);
+ }
+}
+
1;
diff --git a/t/Cobrand.t b/t/Cobrand.t
index e4a871bed..71f38a3a0 100755
--- a/t/Cobrand.t
+++ b/t/Cobrand.t
@@ -6,12 +6,12 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Cobrand.t,v 1.18 2009-10-19 11:10:32 louise Exp $
+# $Id: Cobrand.t,v 1.19 2009-10-19 16:44:55 louise Exp $
#
use strict;
use warnings;
-use Test::More tests => 56;
+use Test::More tests => 62;
use Test::Exception;
use FindBin;
@@ -248,6 +248,28 @@ sub test_allow_photo_upload {
is($photo_upload, 1, 'allow_photo_upload returns 1 if there is no allow_photo_upload function defined by the cobrand');
}
+sub test_allow_photo_display {
+ my $cobrand = 'mysite';
+ my $photo_display = Cobrand::allow_photo_display($cobrand);
+ is($photo_display, 0, 'allow_photo_display returns output from cobrand module');
+
+ $cobrand = 'nosite';
+ $photo_display = Cobrand::allow_photo_display($cobrand);
+ is($photo_display, 1, 'allow_photo_display returns 1 if there is no allow_photo_display function defined by the cobrand');
+}
+
+sub test_location_check {
+ my $cobrand = 'mysite';
+ my $location = 'near here';
+ my $query = new MockQuery('mysite');
+ my $check_result = Cobrand::location_check($cobrand, $location, $query);
+ is($check_result, 0, 'location_check returns output from cobrand module');
+
+ $cobrand = 'nosite';
+ $check_result = Cobrand::location_check($cobrand, $location, $query);
+ is($check_result, 1, 'location_check returns 1 if there is no location_check function defined by the cobrand');
+}
+
ok(test_cobrand_handle() == 1, 'Ran all tests for the cobrand_handle function');
ok(test_cobrand_page() == 1, 'Ran all tests for the cobrand_page function');
ok(test_site_restriction() == 1, 'Ran all tests for the site_restriction function');
@@ -266,3 +288,5 @@ ok(test_on_map_list_limit() == 1, 'Ran all tests for on_map_list_limit');
ok(test_url() == 1, 'Ran all tests for url');
ok(test_show_watermark() == 1, 'Ran all tests for show_watermark');
ok(test_allow_photo_upload() == 1, 'Ran all tests for allow_photo_upload');
+ok(test_allow_photo_display() == 1, 'Ran all tests for allow_photo_display');
+ok(test_location_check() == 1, 'Ran all tests for location_check');
diff --git a/t/Cobrands/Mysite/Util.pm b/t/Cobrands/Mysite/Util.pm
index e7dbd7c37..4e691a092 100644
--- a/t/Cobrands/Mysite/Util.pm
+++ b/t/Cobrands/Mysite/Util.pm
@@ -7,7 +7,7 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: Util.pm,v 1.17 2009-10-19 11:10:32 louise Exp $
+# $Id: Util.pm,v 1.18 2009-10-19 16:44:56 louise Exp $
package Cobrands::Mysite::Util;
use Page;
@@ -94,4 +94,12 @@ sub show_watermark {
sub allow_photo_upload {
return 0;
}
+
+sub allow_photo_display {
+ return 0;
+}
+
+sub location_check {
+ return 0;
+}
1;