diff options
author | Chris Mytton <chrism@mysociety.org> | 2020-01-22 16:13:17 +0000 |
---|---|---|
committer | Chris Mytton <chrism@mysociety.org> | 2020-02-20 14:01:10 +0000 |
commit | c490a4a8fbeb66f559f3591691f48e0e3eccd4df (patch) | |
tree | 55b8758b7908e460e920d1e9dba9169605394215 | |
parent | fe62503ff288efd655b18aaab970a1f2c725eebe (diff) |
Add --group flag to add_emergency_message script
This allows you to restrict the message to a certain group of
categories.
This is so we can add a "is this problem on private land" message to the
categories in the "Trees" group for Peterborough.
-rwxr-xr-x | bin/fixmystreet.com/add_emergency_message | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/bin/fixmystreet.com/add_emergency_message b/bin/fixmystreet.com/add_emergency_message index 1ed879506..9264cc411 100755 --- a/bin/fixmystreet.com/add_emergency_message +++ b/bin/fixmystreet.com/add_emergency_message @@ -32,6 +32,7 @@ my ($opts, $usage) = describe_options( ['no=s', 'no answer to question'], ['message=s', 'message to be shown if form disabled', { required => 1 } ], ['send_method=s', 'send method to restrict categories to' ], + ['group=s', 'group to restrict categories to' ], ['help|h', "print usage message and exit" ], ); $usage->die if $opts->help; @@ -87,6 +88,10 @@ unless ($body) { my $contacts = $body->contacts->not_deleted; $contacts = $contacts->search({ send_method => $opts->send_method }) if $opts->send_method; foreach my $category ($contacts->all) { + # Check if we're just adding the message to a certain group + if ($opts->group) { + next unless grep { $_ eq $opts->group } @{$category->groups}; + } my $found = $category->get_extra_field(code => $field->{code}); if ($found) { say colored("Updating ", 'red') . $field->{code} . " message disable form on " . $category->category . ", " . $opts->body; |