Add exportbranches command for PDC.

This commit is contained in:
Ralph Bean 2017-11-17 13:52:23 +00:00
parent f8a3c46e93
commit 5676d70ef4
2 changed files with 34 additions and 0 deletions

View file

@ -0,0 +1,15 @@
import json
from django.core.management.base import BaseCommand
from pdc.apps.componentbranch.models import ComponentBranch
from pdc.apps.componentbranch.serializers import is_branch_active
class Command(BaseCommand):
help = 'Export a JSON file with information about all component branches'
def handle(self, *args, **options):
all_entries = ComponentBranch.objects.all()
exported = [e.export() for e in all_entries]
for i, entry in enumerate(all_entries):
exported[i]['active'] = is_branch_active(entry)
self.stdout.write(json.dumps(exported, indent=2))