aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/browser-tests4
-rwxr-xr-xbin/fixmystreet.com/fixture31
-rw-r--r--bin/fixmystreet.com/island_roads_setup_messages73
-rwxr-xr-xbin/fixmystreet.com/setup_island_roads_triage_cats133
4 files changed, 239 insertions, 2 deletions
diff --git a/bin/browser-tests b/bin/browser-tests
index 013c0d8d3..0180db0b5 100755
--- a/bin/browser-tests
+++ b/bin/browser-tests
@@ -11,7 +11,7 @@ my ($cobrand, $coords, $area_id, $name, $mapit_url);
BEGIN {
$config_file = 'conf/general.yml-example';
- $cobrand = [ 'borsetshire', 'fixmystreet', 'northamptonshire', 'bathnes', 'buckinghamshire', 'hounslow' ];
+ $cobrand = [ 'borsetshire', 'fixmystreet', 'northamptonshire', 'bathnes', 'buckinghamshire', 'hounslow', 'isleofwight' ];
$coords = '51.532851,-2.284277';
$area_id = 2608;
$name = 'Borsetshire';
@@ -150,7 +150,7 @@ browser-tests [running options] [fixture options] [cypress options]
--help this help message
Fixture option:
- --cobrand Cobrand(s) to use, default is fixmystreet,northamptonshire,bathnes,buckinghamshire
+ --cobrand Cobrand(s) to use, default is fixmystreet,northamptonshire,bathnes,buckinghamshire,isleofwight
--coords Default co-ordinates for created reports
--area_id Area ID to use for created body
--name Name to use for created body
diff --git a/bin/fixmystreet.com/fixture b/bin/fixmystreet.com/fixture
index 760c76414..1f6063a47 100755
--- a/bin/fixmystreet.com/fixture
+++ b/bin/fixmystreet.com/fixture
@@ -99,6 +99,7 @@ if ($opt->test_fixtures) {
{ area_id => 2257, categories => ['Flytipping', 'Graffiti'], name => 'Chiltern District Council' },
{ area_id => 2397, categories => [ 'Graffiti' ], name => 'Northampton Borough Council' },
{ area_id => 2483, categories => [ 'Potholes', 'Other' ], name => 'Hounslow Borough Council' },
+ { area_id => 2636, categories => [ 'Potholes', 'Private', 'Extra' ], name => 'Isle of Wight Council' },
) {
$bodies->{$_->{area_id}} = FixMyStreet::DB::Factory::Body->find_or_create($_);
my $cats = join(', ', @{$_->{categories}});
@@ -144,6 +145,36 @@ if ($opt->test_fixtures) {
$child_cat->update({
non_public => 1
});
+
+ $child_cat = FixMyStreet::DB->resultset("Contact")->find({
+ body => $bodies->{2636},
+ category => 'Potholes',
+ });
+ $child_cat->update({
+ send_method => 'Triage'
+ });
+ $child_cat = FixMyStreet::DB->resultset("Contact")->find({
+ body => $bodies->{2636},
+ category => 'Private',
+ });
+ $child_cat->update({
+ non_public => 1,
+ send_method => 'Triage'
+ });
+ $child_cat = FixMyStreet::DB->resultset("Contact")->find({
+ body => $bodies->{2636},
+ category => 'Extra',
+ });
+ $child_cat->update({
+ send_method => 'Triage'
+ });
+ $child_cat->set_extra_fields({
+ code => 'extra',
+ datatype => 'string',
+ order => 1,
+ variable => 'true',
+ });
+ $child_cat->update;
}
FixMyStreet::DB::Factory::ResponseTemplate->create({
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";
+}
diff --git a/bin/fixmystreet.com/setup_island_roads_triage_cats b/bin/fixmystreet.com/setup_island_roads_triage_cats
new file mode 100755
index 000000000..b747fb99b
--- /dev/null
+++ b/bin/fixmystreet.com/setup_island_roads_triage_cats
@@ -0,0 +1,133 @@
+#!/usr/bin/env perl
+
+=head1 NAME
+
+setup_island_roads_triage_cats - create/update triage contacts for Island Roads cobrand
+
+=head1 DESCRIPTION
+
+This script creates a set of contacts for Island Road to be used as part of their triage
+system. The contacts created all have the `Triage` send_method and so will be displayed
+to non staff users.
+
+It also adds the relevant extra fields to the contacts to enable asset details to be
+added to a report created in the category.
+
+If a contact with the same category already exists that does not have a send_method of
+`Triage` then the script will emit a warning. Any existing contacts with the `Triage`
+send_method will have their state reset to `confirmed`.
+
+=cut
+
+use v5.14;
+use warnings;
+
+BEGIN {
+ use File::Basename qw(dirname);
+ use File::Spec;
+ my $d = dirname(File::Spec->rel2abs($0));
+ require "$d/../../setenv.pl";
+}
+
+
+my @cat_list = (
+ "Dog Fouling",
+ "Manholes",
+ "Trees & Hedges",
+ "Pavements/footpaths",
+ "Drainage",
+ "Car Parking",
+ "Street Lighting",
+ "Bus Stops",
+ "Flyposting",
+ "Potholes",
+ "Street Cleaning",
+ "Bridges & Walls",
+ "Traffic Lights",
+ "Street Furniture",
+ "Roads/Highways",
+ "Road Traffic Signs & Markings",
+ "Grass Verges & Weeds",
+ "Flytipping",
+ "Graffiti",
+ "Street Nameplates",
+ "Abandoned Vehicles"
+);
+
+use FixMyStreet::DB;
+use FixMyStreet::Cobrand::IsleOfWight;
+
+my $iow = FixMyStreet::DB->resultset("Body")->search({
+ name => "Isle of Wight Council"
+});
+
+my $cobrand = FixMyStreet::Cobrand::IsleOfWight->new;
+
+if ($iow->count != 1) {
+ die "Could not find IoW body\n";
+}
+
+$iow = $iow->first;
+
+for my $cat (@cat_list) {
+
+ my $existing = FixMyStreet::DB->resultset("Contact")->search({
+ category => $cat, body_id => $iow->id
+ })->first;
+
+ if ( $existing ) {
+ if (!$existing->send_method || $existing->send_method ne 'Triage') {
+ warn "$cat is not a Triage category\n";
+ next;
+ }
+ # make sure category is not deleted
+ $existing->state('confirmed');
+ } else {
+ $existing = FixMyStreet::DB->resultset('Contact')->create({
+ name => $cat,
+ body => $iow,
+ send_method => 'Triage',
+ state => 'confirmed',
+ editor => $0,
+ note => 'created automatically by script',
+ });
+ }
+
+ my $extra_fields = $existing->get_extra_fields;
+ my @meta = grep { $_->{code} ne 'central_asset_id' && $_->{code} ne 'site_code'} @$extra_fields;
+
+ push @meta,
+ {
+ code => 'central_asset_id',
+ datatype => 'string',
+ description => 'central asset id',
+ order => 100,
+ required => 'false',
+ variable => 'true',
+ automated => 'hidden_field',
+ },
+ {
+ code => 'asset_details',
+ datatype => 'string',
+ description => 'asset details',
+ order => 100,
+ required => 'false',
+ variable => 'true',
+ automated => 'hidden_field',
+ },
+ {
+ code => 'site_code',
+ datatype => 'string',
+ description => 'site code',
+ order => 100,
+ required => 'false',
+ variable => 'true',
+ automated => 'hidden_field',
+ };
+
+ $cobrand->call_hook(
+ open311_contact_meta_override => {}, $existing, \@meta);
+
+ $existing->set_extra_fields(@meta);
+ $existing->update;
+}