diff --git a/README.rst b/README.rst index d263b19..be9b059 100644 --- a/README.rst +++ b/README.rst @@ -31,10 +31,15 @@ settings there. Create empty database: ./manage.py syncdb -Copy slots.json.sample to slots.json and edit the file to match -the topics, rooms and time slots for each topic. Then run: +Copy topics.json.sample to topics.json and edit the file to match +the topics you want to have. Then run: -./manage.py loadtopics slots.json +./manage.py loadtopics topics.json Then run a dev server using: ./manage.py runserver + +When you have room layout, copy slots.json.sample to slots.json and edit +the file to match the rooms and time slots for each topic. Then run: + +./manage.py loadslots slots.json diff --git a/cfp/management/__init__.py b/cfp/management/__init__.py new file mode 100644 index 0000000..22a3f41 --- /dev/null +++ b/cfp/management/__init__.py @@ -0,0 +1,14 @@ +# Copyright 2011 Thierry Carrez +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. diff --git a/cfp/management/commands/__init__.py b/cfp/management/commands/__init__.py new file mode 100644 index 0000000..22a3f41 --- /dev/null +++ b/cfp/management/commands/__init__.py @@ -0,0 +1,14 @@ +# Copyright 2011 Thierry Carrez +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. diff --git a/cfp/management/commands/loadtopics.py b/cfp/management/commands/loadtopics.py new file mode 100644 index 0000000..f3b4f5c --- /dev/null +++ b/cfp/management/commands/loadtopics.py @@ -0,0 +1,40 @@ +# Copyright 2011 Thierry Carrez +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import json + +from django.core.management.base import BaseCommand, CommandError +from cfp.models import Topic + + +class Command(BaseCommand): + args = '' + help = 'Create topics from JSON description' + + def handle(self, *args, **options): + + if len(args) != 1: + raise CommandError('Incorrect arguments') + + try: + with open(args[0]) as f: + data = json.load(f) + except ValueError as exc: + raise CommandError("Malformed JSON: %s" % exc.message) + + for topicname, desc in data.iteritems(): + t = Topic(name=topicname, lead_username=desc['lead_username'], + description=desc['description']) + t.save() diff --git a/scheduling/management/commands/loadtopics.py b/scheduling/management/commands/loadslots.py similarity index 93% rename from scheduling/management/commands/loadtopics.py rename to scheduling/management/commands/loadslots.py index 564574e..b3ec7ea 100644 --- a/scheduling/management/commands/loadtopics.py +++ b/scheduling/management/commands/loadslots.py @@ -46,10 +46,8 @@ class Command(BaseCommand): for topicname, desc in data['topics'].iteritems(): started = False - t = Topic(name=topicname, lead_username=desc['lead_username'], - description=desc['description']) + t = Topic.objects.get(name=topicname) room = Room.objects.get(code=desc['room']) - t.save() for (d, h) in slot_generator(data): if (d == desc['start_day'] and h == desc['first_slot']): started = True diff --git a/slots.json.sample b/slots.json.sample index bd748b1..d69327c 100644 --- a/slots.json.sample +++ b/slots.json.sample @@ -23,8 +23,6 @@ ], "topics": { "Swift": { - "description": "Sessions about OpenStack Object Storage (Swift)", - "lead_username": "notmyname", "room": "A", "start_day": "2012-09-20", "first_slot": "09:30", "end_day": "2012-09-21", "last_slot": "10:00" } diff --git a/topics.json.sample b/topics.json.sample new file mode 100644 index 0000000..bcf5f82 --- /dev/null +++ b/topics.json.sample @@ -0,0 +1,6 @@ +{ + "Swift": { + "description": "Sessions about OpenStack Object Storage (Swift)", + "lead_username": "notmyname" + } +}