Skip to content

Commit cf8e722

Browse files
committed
write out scheduled in json format
- Legacy-Id: 6244
1 parent 6193d1b commit cf8e722

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from django.core.management.base import BaseCommand
2+
from django.core import serializers
3+
from optparse import make_option
4+
import sys
5+
6+
class Command(BaseCommand):
7+
option_list = BaseCommand.option_list + (
8+
make_option('--format', default='json', dest='format',
9+
help='Specifies the output serialization format for fixtures.'),
10+
make_option('--indent', default=None, dest='indent', type='int',
11+
help='Specifies the indent level to use when pretty-printing output'),
12+
# make_option('--schedulename', action='store', dest='schedulename', default=False,
13+
# help='Tells Django to stop running the test suite after first failed test.')
14+
)
15+
help = 'Saves the scheduled information for a named schedule in JSON format'
16+
args = 'meetingname [owner] schedname'
17+
18+
def handle(self, *labels, **options):
19+
from django.conf import settings
20+
from django.test.utils import get_runner
21+
22+
meetingname = labels[0]
23+
schedname = labels[1]
24+
25+
from ietf.meeting.helpers import get_meeting,get_schedule
26+
27+
format = options.get('format','json')
28+
indent = options.get('indent', 2)
29+
meeting = get_meeting(meetingname)
30+
schedule = get_schedule(meeting, schedname)
31+
32+
scheduledsessions = schedule.scheduledsession_set.all()
33+
34+
# cribbed from django/core/management/commands/dumpdata.py
35+
# Check that the serialization format exists; this is a shortcut to
36+
# avoid collating all the objects and _then_ failing.
37+
if format not in serializers.get_public_serializer_formats():
38+
raise CommandError("Unknown serialization format: %s" % format)
39+
40+
return serializers.serialize(format, scheduledsessions, indent=indent,
41+
use_natural_keys=True)
42+
43+

0 commit comments

Comments
 (0)