Skip to content

Commit

Permalink
Management command to change alive status of events.
Browse files Browse the repository at this point in the history
  • Loading branch information
KKruszynska committed Jan 22, 2025
1 parent 5cbe944 commit 74eabe8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mop/management/commands/unalive_events_list.py
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))

0 comments on commit 74eabe8

Please sign in to comment.