Skip to content

Commit 74eabe8

Browse files
committed
Management command to change alive status of events.
1 parent 5cbe944 commit 74eabe8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from django.core.management.base import BaseCommand
2+
from tom_targets.models import Target
3+
4+
class Command(BaseCommand):
5+
"""
6+
Command to unalive events with target names provided in a list as a command line argument
7+
"""
8+
9+
help = 'Command to unalive events with target names provided in a list as a command line argument'
10+
11+
def add_arguments(self, parser):
12+
13+
parser.add_argument('target_list', help='List of events to unalive')
14+
15+
16+
def handle(self, *args, **options):
17+
18+
targets_to_unalive = options['target_list'].split(',')
19+
20+
for target_name in targets_to_unalive:
21+
t, created = Target.objects.get_or_create(name=target_name)
22+
print('Target ' + str(t.pk) + ' ' + t.name + ' has status=' + repr(t.alive))
23+
t.alive = False
24+
t.save()
25+
print('Target ' + str(t.pk) + ' ' + t.name + ' now has status=' + repr(t.alive))

0 commit comments

Comments
 (0)