diff options
author | Dan McGee <dan@archlinux.org> | 2011-08-17 16:14:49 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-17 16:14:49 -0500 |
commit | 366e438ed5b6b9f2fc2651e64e3e41444fb781fb (patch) | |
tree | 3bd9d033aa8ef9485127053969e7945acc98c6f4 /releng/management/commands/syncisos.py | |
parent | c80afa08c7aec23984e84bfb3ab5683c9c392115 (diff) |
releng syncisos: reactive inactive ISOs if available
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'releng/management/commands/syncisos.py')
-rw-r--r-- | releng/management/commands/syncisos.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/releng/management/commands/syncisos.py b/releng/management/commands/syncisos.py index 23955afe..270c6c34 100644 --- a/releng/management/commands/syncisos.py +++ b/releng/management/commands/syncisos.py @@ -34,18 +34,25 @@ class IsoListParser(HTMLParser): raise CommandError('Couldn\'t parse "%s"' % url) class Command(BaseCommand): - help = 'Gets new isos from %s' % settings.ISO_LIST_URL + help = 'Gets new ISOs from %s' % settings.ISO_LIST_URL def handle(self, *args, **options): parser = IsoListParser() isonames = Iso.objects.values_list('name', flat=True) active_isos = parser.parse(settings.ISO_LIST_URL) - # create any names that don't already exist for iso in active_isos: + # create any names that don't already exist if iso not in isonames: new = Iso(name=iso, active=True) new.save() + # update those that do if they were marked inactive + else: + existing = Iso.objects.get(name=iso) + if not existing.active: + existing.active = True + existing.removed = None + existing.save() now = datetime.utcnow() # and then mark all other names as no longer active Iso.objects.filter(active=True).exclude(name__in=active_isos).update( |