aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf/general.yml-example18
-rw-r--r--perllib/FixMyStreet.pm14
-rw-r--r--perllib/FixMyStreet/Cobrand/FiksGataMi.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/FixaMinGata.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm6
-rw-r--r--perllib/FixMyStreet/Script/Reports.pm2
-rw-r--r--perllib/FixMyStreet/SendReport/Email.pm2
-rw-r--r--t/cobrand/bromley.t2
-rw-r--r--t/cobrand/zurich.t4
-rw-r--r--t/sendreport/open311.t2
-rw-r--r--templates/web/base/admin/bodies.html4
-rw-r--r--templates/web/base/admin/body.html4
-rw-r--r--templates/web/base/admin/config_page.html6
13 files changed, 44 insertions, 24 deletions
diff --git a/conf/general.yml-example b/conf/general.yml-example
index 3b2c597b9..71fbeea35 100644
--- a/conf/general.yml-example
+++ b/conf/general.yml-example
@@ -41,14 +41,16 @@ DO_NOT_REPLY_EMAIL: 'do-not-reply@example.org'
# Whether this is a development site or not. It will mean e.g. templates/
# CSS modified times aren't cached
STAGING_SITE: 1
-# Normally, a staging site will route all reports to the reporter on a
-# development site (when STAGING_SITE is 1), to guard against sending fake
-# reports to live places. Set this to 1 if you want a dev site to route
-# reports as normal.
-SEND_REPORTS_ON_STAGING: 0
-# Manual testing of multiple cobrands can be made easier by skipping some
-# checks they have in them, if this variable is set
-SKIP_CHECKS_ON_STAGING: 0
+# Developers may want a staging site to act differently from a live site.
+# Possible flags include:
+# - send_reports: Normally, a staging site will route all reports to the
+# reporter, to guard against sending fake reports to live places. Set
+# this to 1 if you want a staging site to route reports as normal.
+# - skip_checks: Manual testing of multiple cobrands can be made easier by
+# skipping some checks they have in them, if this variable is set.
+STAGING_FLAGS:
+ send_reports: 0
+ skip_checks: 0
# What to use as front page/alert example places placeholder
# Defaults to High Street, Main Street
diff --git a/perllib/FixMyStreet.pm b/perllib/FixMyStreet.pm
index 14f3f3607..1f4579293 100644
--- a/perllib/FixMyStreet.pm
+++ b/perllib/FixMyStreet.pm
@@ -212,4 +212,18 @@ sub set_time_zone {
$dt->set_time_zone($tz_f) if $tz_f;
}
+# Development functions
+
+sub staging_flag {
+ my ($cls, $flag, $value) = @_;
+ $value = 1 unless defined $value;
+ return unless $cls->config('STAGING_SITE');
+ my $flags = $cls->config('STAGING_FLAGS');
+ unless ($flags && ref $flags eq 'HASH') {
+ # Assume all flags 0 if missing
+ return !$value;
+ }
+ return $flags->{$flag} == $value;
+}
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
index 242735073..cf0d72f8e 100644
--- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
+++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm
@@ -30,7 +30,7 @@ sub disambiguate_location {
sub area_types {
my $self = shift;
- return $self->next::method() if FixMyStreet->config('STAGING_SITE') && FixMyStreet->config('SKIP_CHECKS_ON_STAGING');
+ return $self->next::method() if FixMyStreet->staging_flag('skip_checks');
[ 'NKO', 'NFY', 'NRA' ];
}
diff --git a/perllib/FixMyStreet/Cobrand/FixaMinGata.pm b/perllib/FixMyStreet/Cobrand/FixaMinGata.pm
index 5b78b3fa1..324811008 100644
--- a/perllib/FixMyStreet/Cobrand/FixaMinGata.pm
+++ b/perllib/FixMyStreet/Cobrand/FixaMinGata.pm
@@ -31,7 +31,7 @@ sub disambiguate_location {
sub area_types {
my $self = shift;
- return $self->next::method() if FixMyStreet->config('STAGING_SITE') && FixMyStreet->config('SKIP_CHECKS_ON_STAGING');
+ return $self->next::method() if FixMyStreet->staging_flag('skip_checks');
[ 'KOM' ];
}
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index c22224307..64ca7fc62 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -42,13 +42,13 @@ sub restriction {
sub problems_restriction {
my ($self, $rs) = @_;
- return $rs if FixMyStreet->config('STAGING_SITE') && FixMyStreet->config('SKIP_CHECKS_ON_STAGING');
+ return $rs if FixMyStreet->staging_flag('skip_checks');
return $rs->to_body($self->council_id);
}
sub updates_restriction {
my ($self, $rs) = @_;
- return $rs if FixMyStreet->config('STAGING_SITE') && FixMyStreet->config('SKIP_CHECKS_ON_STAGING');
+ return $rs if FixMyStreet->staging_flag('skip_checks');
return $rs->to_body($self->council_id);
}
@@ -105,7 +105,7 @@ sub enter_postcode_text {
sub area_check {
my ( $self, $params, $context ) = @_;
- return 1 if FixMyStreet->config('STAGING_SITE') && FixMyStreet->config('SKIP_CHECKS_ON_STAGING');
+ return 1 if FixMyStreet->staging_flag('skip_checks');
my $councils = $params->{all_areas};
my $council_match = defined $councils->{$self->council_id};
diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm
index 7d614bc30..193c5fa41 100644
--- a/perllib/FixMyStreet/Script/Reports.pm
+++ b/perllib/FixMyStreet/Script/Reports.pm
@@ -211,7 +211,7 @@ sub send(;$) {
. " ]\n\n";
}
- if (FixMyStreet->config('STAGING_SITE') && !FixMyStreet->config('SEND_REPORTS_ON_STAGING')) {
+ if (FixMyStreet->staging_flag('send_reports', 0)) {
# on a staging server send emails to ourselves rather than the bodies
%reporters = map { $_ => $reporters{$_} } grep { /FixMyStreet::SendReport::Email/ } keys %reporters;
unless (%reporters) {
diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm
index 2eab1c754..4cee58d42 100644
--- a/perllib/FixMyStreet/SendReport/Email.pm
+++ b/perllib/FixMyStreet/SendReport/Email.pm
@@ -67,7 +67,7 @@ sub send {
my $recips = $self->build_recipient_list( $row, $h );
# on a staging server send emails to ourselves rather than the bodies
- if (FixMyStreet->config('STAGING_SITE') && !FixMyStreet->config('SEND_REPORTS_ON_STAGING') && !FixMyStreet->test_mode) {
+ if (FixMyStreet->staging_flag('send_reports', 0) && !FixMyStreet->test_mode) {
$recips = 1;
@{$self->to} = [ $row->user->email, $self->to->[0][1] || $row->name ];
}
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index 43d936684..a7cc563dc 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -55,7 +55,7 @@ subtest 'testing special Open311 behaviour', sub {
$body->update( { send_method => 'Open311', endpoint => 'http://bromley.endpoint.example.com', jurisdiction => 'FMS', api_key => 'test' } );
my $test_data;
FixMyStreet::override_config {
- SEND_REPORTS_ON_STAGING => 1,
+ STAGING_FLAGS => { send_reports => 1 },
ALLOWED_COBRANDS => [ 'fixmystreet', 'bromley' ],
}, sub {
$test_data = FixMyStreet::DB->resultset('Problem')->send_reports();
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index ddaae1f90..85cada27a 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -28,12 +28,12 @@ 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 SEND_REPORTS_ON_STAGING needs to be true, and
+# correctly set - notably STAGING_FLAGS send_reports needs to be true, and
# zurich must be allowed cobrand if we want to be able to call cobrand
# methods on it.
sub send_reports_for_zurich {
FixMyStreet::override_config {
- SEND_REPORTS_ON_STAGING => 1,
+ STAGING_FLAGS => { send_reports => 1 },
ALLOWED_COBRANDS => ['zurich']
}, sub {
# Actually send the report
diff --git a/t/sendreport/open311.t b/t/sendreport/open311.t
index 636faba31..c40b64d12 100644
--- a/t/sendreport/open311.t
+++ b/t/sendreport/open311.t
@@ -26,7 +26,7 @@ subtest 'testing Open311 behaviour', sub {
$body->update( { send_method => 'Open311', endpoint => 'http://endpoint.example.com', jurisdiction => 'FMS', api_key => 'test' } );
my $test_data;
FixMyStreet::override_config {
- SEND_REPORTS_ON_STAGING => 1,
+ STAGING_FLAGS => { send_reports => 1 },
ALLOWED_COBRANDS => [ 'fixmystreet' ],
}, sub {
$test_data = FixMyStreet::DB->resultset('Problem')->send_reports();
diff --git a/templates/web/base/admin/bodies.html b/templates/web/base/admin/bodies.html
index e98e2d350..9bd85940b 100644
--- a/templates/web/base/admin/bodies.html
+++ b/templates/web/base/admin/bodies.html
@@ -14,9 +14,9 @@
</p>
[% ELSE %]
- [% IF c.config.STAGING_SITE and !c.config.SEND_REPORTS_ON_STAGING %]
+ [% IF c.config.STAGING_SITE and !c.config.STAGING_FLAGS.send_reports %]
<p class="fms-admin-warning">
- [% tprintf(loc("As this is a staging site and %s is false, reports made on this site will be sent to the problem reporter, not the contact given for the report’s category."), "<a class='admin-offsite-link' href='http://fixmystreet.org/customising/config/#send_reports_on_staging'><code>SEND_REPORTS_ON_STAGING</code></a>") %]
+ [% tprintf(loc("As this is a staging site and %s is false, reports made on this site will be sent to the problem reporter, not the contact given for the report’s category."), "<a class='admin-offsite-link' href='http://fixmystreet.org/customising/config/#send_reports_on_staging'><code>STAGING_FLAGS send_reports</code></a>") %]
</p>
[% END %]
diff --git a/templates/web/base/admin/body.html b/templates/web/base/admin/body.html
index 5c9f4f9b9..5e8c6a164 100644
--- a/templates/web/base/admin/body.html
+++ b/templates/web/base/admin/body.html
@@ -59,9 +59,9 @@
<br>
[% loc("Add a contact using the form below.") %]
</p>
-[% ELSIF c.config.STAGING_SITE and !c.config.SEND_REPORTS_ON_STAGING %]
+[% ELSIF c.config.STAGING_SITE and !c.config.STAGING_FLAGS.send_reports %]
<p class="fms-admin-warning">
- [% tprintf(loc("As this is a staging site and %s is false, reports made on this site will be sent to the problem reporter, not the contact given for the report’s category."), "<a class='admin-offsite-link' href='http://fixmystreet.org/customising/config/#send_reports_on_staging'><code>SEND_REPORTS_ON_STAGING</code></a>") %]
+ [% tprintf(loc("As this is a staging site and %s is false, reports made on this site will be sent to the problem reporter, not the contact given for the report’s category."), "<a class='admin-offsite-link' href='http://fixmystreet.org/customising/config/#send_reports_on_staging'><code>STAGING_FLAGS send_reports</code></a>") %]
</p>
[% END %]
diff --git a/templates/web/base/admin/config_page.html b/templates/web/base/admin/config_page.html
index 67661c597..f35cd6adb 100644
--- a/templates/web/base/admin/config_page.html
+++ b/templates/web/base/admin/config_page.html
@@ -118,7 +118,11 @@ running version <strong>[% git_version || 'unknown' %]</strong>.
[% INCLUDE subsection heading="Development" %]
[% INCLUDE just_value value="STAGING_SITE" %]
-[% INCLUDE just_value value="SEND_REPORTS_ON_STAGING" %]
+[% staging_conf = FOR k IN c.config.STAGING_FLAGS %]
+ [% k.key %]:[% k.value %]
+ [%- ',' IF NOT loop.last %]
+[% END %]
+[% INCLUDE just_value value="STAGING_FLAGS" conf = staging_conf %]
[% INCLUDE just_value value="UPLOAD_DIR" %]
[% INCLUDE just_value value="GEO_CACHE" %]
[% INCLUDE just_value value="TESTING_COUNCILS" %]