diff options
author | Struan Donald <struan@exo.org.uk> | 2019-09-02 15:40:41 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2019-09-27 17:43:38 +0100 |
commit | 6cf49a021b7e06816c386accd98cbcf9c17771d1 (patch) | |
tree | 24a7537ad162eb9c7387690aac3b06041ef9092b | |
parent | 877a8535ed4d50cee0e03840938f20646146260e (diff) |
[IsleOfWight] script to add emergency categories
One off script that adds an question to each Triage category to ask if
the problem is urgent or not. Sets urgent answer to block form
submission.
-rw-r--r-- | bin/fixmystreet.com/island_roads_setup_messages | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/bin/fixmystreet.com/island_roads_setup_messages b/bin/fixmystreet.com/island_roads_setup_messages new file mode 100644 index 000000000..4969f18ba --- /dev/null +++ b/bin/fixmystreet.com/island_roads_setup_messages @@ -0,0 +1,73 @@ +#!/usr/bin/env perl +# +# One off script to transfer the hardcoded JS messages to the database + +use strict; +use warnings; +use v5.14; + +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../../setenv.pl"; +} + +use FixMyStreet::DB; + +use Getopt::Long; + +my $commit; +GetOptions( + 'commit' => \$commit, +); + +if (!$commit) { + say "*** DRY RUN ***"; +} + +my $urgent = { + order => 0, + required => 'true', + protected => 'true', + code => 'urgent', + description => 'To ensure your report is dealt with effectively, please tell us the severity of the issue:-', + datatype_description => 'You have indicated that the issue requires an urgent response, please phone Island Roads on 01983 822440 so that we can respond to the issue appropriately.', + datatype => 'singlevaluelist', + variable => 'true', + values => [ + { + key => 'urgent', + name => 'The issue requires an urgent response/action', + disable => 1, + }, + { + key => 'not_urgent', + name => 'The issue requires a routine/non-urgent response/action', + } + ], +}; + +my $iow = FixMyStreet::DB->resultset("Body")->find({ name => 'Isle of Wight Council' }); +if ($iow) { + my @iow_contacts = $iow->contacts->search({ send_method => 'Triage' })->all; + foreach my $category (@iow_contacts) { + my $extra_fields = $category->get_extra_fields; + my $found = 0; + foreach (@$extra_fields) { + next unless $_->{code} eq 'urgent'; + $_ = $urgent; + $found = 1; + } + if (!$found) { + push @$extra_fields, $urgent; + } + $category->set_extra_fields(@$extra_fields); + say "Making emergency message disable form on " . $category->category . ", Isle of Wight"; + if ($commit) { + $category->update; + } + } +} else { + say STDERR "Could not find IoW"; +} |