diff options
author | Dave Arter <davea@mysociety.org> | 2020-03-13 13:07:47 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2020-07-02 14:38:29 +0100 |
commit | c3b4b23b378f6d14881675556571e912d1a52ee0 (patch) | |
tree | f551348d0135a49a9c4d34431dc68c31321e4b72 /bin | |
parent | aa9d3cce479c7b28ba3f5f09cac0231111aeebf8 (diff) |
Improve category import script
Adds ability for categories to be marked as devolved with their own
send_method, and for the open311_protect flag to be set.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/import_categories | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/import_categories b/bin/import_categories index 744759f1f..23a1089f5 100644 --- a/bin/import_categories +++ b/bin/import_categories @@ -46,11 +46,10 @@ if (!$opt->commit) { my $config = decode_json(path($ARGV[0])->slurp_utf8); my $body = FixMyStreet::DB->resultset('Body')->find({ name => $opt->body }); +die "Couldn't find body " . $opt->body unless $body; $body->contacts->delete_all if $opt->delete; -die "Couldn't find body" unless $body; - my $groups = $config->{groups}; if ($groups) { for my $group (keys %$groups) { @@ -72,12 +71,14 @@ sub make_categories { category => $cat->{category} }); $child_cat->email($cat->{email}); + $child_cat->send_method($cat->{devolved}) if $cat->{devolved}; $child_cat->state('confirmed'); $child_cat->editor($0); $child_cat->whenedited(\'current_timestamp'); $child_cat->note($child_cat->in_storage ? 'Updated by import_categories' : 'Created by import_categories'); say colored("WARNING", 'red') . " " . $child_cat->category . " already exists" if $child_cat->in_storage and $child_cat->category ne 'Other (TfL)'; $child_cat->extra(undef) if $child_cat->in_storage; + $child_cat->set_extra_metadata(open311_protect => 1) if $cat->{open311_protect}; if ($group) { my $groups = $child_cat->groups; |