-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Management command to change alive status of events.
- Loading branch information
1 parent
5cbe944
commit 74eabe8
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from django.core.management.base import BaseCommand | ||
from tom_targets.models import Target | ||
|
||
class Command(BaseCommand): | ||
""" | ||
Command to unalive events with target names provided in a list as a command line argument | ||
""" | ||
|
||
help = 'Command to unalive events with target names provided in a list as a command line argument' | ||
|
||
def add_arguments(self, parser): | ||
|
||
parser.add_argument('target_list', help='List of events to unalive') | ||
|
||
|
||
def handle(self, *args, **options): | ||
|
||
targets_to_unalive = options['target_list'].split(',') | ||
|
||
for target_name in targets_to_unalive: | ||
t, created = Target.objects.get_or_create(name=target_name) | ||
print('Target ' + str(t.pk) + ' ' + t.name + ' has status=' + repr(t.alive)) | ||
t.alive = False | ||
t.save() | ||
print('Target ' + str(t.pk) + ' ' + t.name + ' now has status=' + repr(t.alive)) |