Add exportbranches command for PDC.
This commit is contained in:
parent
f8a3c46e93
commit
5676d70ef4
2 changed files with 34 additions and 0 deletions
15
roles/pdc/frontend/files/exportbranches.py
Normal file
15
roles/pdc/frontend/files/exportbranches.py
Normal 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))
|
Loading…
Add table
Add a link
Reference in a new issue