diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet.pm | 14 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FiksGataMi.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixaMinGata.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/Script/Reports.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/SendReport/Email.pm | 2 |
6 files changed, 21 insertions, 7 deletions
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 ]; } |