aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/Cobrand.pm21
-rwxr-xr-xt/Cobrand.t15
-rw-r--r--t/Cobrands/Mysite/Util.pm6
3 files changed, 38 insertions, 4 deletions
diff --git a/perllib/Cobrand.pm b/perllib/Cobrand.pm
index 1acff1358..d4d76aeec 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.27 2009-10-15 16:34:31 louise Exp $
+# $Id: Cobrand.pm,v 1.28 2009-10-19 11:10:32 louise Exp $
package Cobrand;
use strict;
@@ -471,6 +471,25 @@ sub on_map_list_limit {
}
}
+=item allow_photo_upload COBRAND
+
+Return a boolean indicating whether the cobrand allows photo uploads
+
+=cut
+
+sub allow_photo_upload {
+ my ($cobrand) = @_;
+ my $handle;
+ if ($cobrand){
+ $handle = cobrand_handle($cobrand);
+ }
+ if ( !$cobrand || !$handle || !$handle->can('allow_photo_upload')){
+ return 1;
+ } else{
+ return $handle->allow_photo_upload();
+ }
+}
+
1;
diff --git a/t/Cobrand.t b/t/Cobrand.t
index 10f227052..e4a871bed 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.17 2009-10-15 16:34:31 louise Exp $
+# $Id: Cobrand.t,v 1.18 2009-10-19 11:10:32 louise Exp $
#
use strict;
use warnings;
-use Test::More tests => 53;
+use Test::More tests => 56;
use Test::Exception;
use FindBin;
@@ -238,6 +238,16 @@ sub test_show_watermark {
}
+sub test_allow_photo_upload {
+ my $cobrand = 'mysite';
+ my $photo_upload = Cobrand::allow_photo_upload($cobrand);
+ is($photo_upload, 0, 'allow_photo_upload returns output from cobrand module');
+
+ $cobrand = 'nosite';
+ $photo_upload = Cobrand::allow_photo_upload($cobrand);
+ is($photo_upload, 1, 'allow_photo_upload returns 1 if there is no allow_photo_upload 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');
@@ -255,3 +265,4 @@ ok(test_site_title() == 1, 'Ran all tests for site_title');
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');
diff --git a/t/Cobrands/Mysite/Util.pm b/t/Cobrands/Mysite/Util.pm
index 3669afa05..e7dbd7c37 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.16 2009-10-15 16:34:31 louise Exp $
+# $Id: Util.pm,v 1.17 2009-10-19 11:10:32 louise Exp $
package Cobrands::Mysite::Util;
use Page;
@@ -90,4 +90,8 @@ sub url {
sub show_watermark {
return 0;
}
+
+sub allow_photo_upload {
+ return 0;
+}
1;