Separate topic creation from slots creation

Allow to create topics separately from slots, as we usually
don't have the topic room layout until late in Summit prep.
This commit is contained in:
Thierry Carrez 2013-02-08 11:49:41 +01:00
parent 32e0a72687
commit 7a8b086e69
7 changed files with 83 additions and 8 deletions

View File

@ -31,10 +31,15 @@ settings there.
Create empty database: Create empty database:
./manage.py syncdb ./manage.py syncdb
Copy slots.json.sample to slots.json and edit the file to match Copy topics.json.sample to topics.json and edit the file to match
the topics, rooms and time slots for each topic. Then run: the topics you want to have. Then run:
./manage.py loadtopics slots.json ./manage.py loadtopics topics.json
Then run a dev server using: Then run a dev server using:
./manage.py runserver ./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

View File

@ -0,0 +1,14 @@
# Copyright 2011 Thierry Carrez <thierry@openstack.org>
# 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.

View File

@ -0,0 +1,14 @@
# Copyright 2011 Thierry Carrez <thierry@openstack.org>
# 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.

View File

@ -0,0 +1,40 @@
# Copyright 2011 Thierry Carrez <thierry@openstack.org>
# 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 = '<description.json>'
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()

View File

@ -46,10 +46,8 @@ class Command(BaseCommand):
for topicname, desc in data['topics'].iteritems(): for topicname, desc in data['topics'].iteritems():
started = False started = False
t = Topic(name=topicname, lead_username=desc['lead_username'], t = Topic.objects.get(name=topicname)
description=desc['description'])
room = Room.objects.get(code=desc['room']) room = Room.objects.get(code=desc['room'])
t.save()
for (d, h) in slot_generator(data): for (d, h) in slot_generator(data):
if (d == desc['start_day'] and h == desc['first_slot']): if (d == desc['start_day'] and h == desc['first_slot']):
started = True started = True

View File

@ -23,8 +23,6 @@
], ],
"topics": { "topics": {
"Swift": { "Swift": {
"description": "Sessions about OpenStack Object Storage (Swift)",
"lead_username": "notmyname",
"room": "A", "room": "A",
"start_day": "2012-09-20", "first_slot": "09:30", "start_day": "2012-09-20", "first_slot": "09:30",
"end_day": "2012-09-21", "last_slot": "10:00" } "end_day": "2012-09-21", "last_slot": "10:00" }

6
topics.json.sample Normal file
View File

@ -0,0 +1,6 @@
{
"Swift": {
"description": "Sessions about OpenStack Object Storage (Swift)",
"lead_username": "notmyname"
}
}