def build_schedule(self):
        created_items = []
        reader = csv.DictReader(self.cleaned_data.get('filename'))
        data = [dict((k.strip(), v.strip()) for k, v in x.items()) for x in reader]
        # build rooms
        created_items.extend(self._build_rooms(data))
        # build_days
        created_items.extend(self._build_days(data))
        # build Slot  -> SlotRoom
        for row in data:
            room = Room.objects.get(
                schedule=self.schedule, name=row[self.ROOM_KEY]
            )
            date = datetime.strptime(row[self.DATE_KEY], "%m/%d/%Y")
            day = Day.objects.get(schedule=self.schedule, date=date)
            start, end = self._get_start_end_times(row)
            slot_kind, created = SlotKind.objects.get_or_create(
                label=row[self.KIND], schedule=self.schedule
            )
            if created:
                created_items.append(slot_kind)
            if row[self.KIND] == 'plenary':
                slot, created = Slot.objects.get_or_create(
                    kind=slot_kind, day=day, start=start, end=end
                )
                if created:
                    created_items.append(slot)
            else:
                slot = Slot.objects.create(
                    kind=slot_kind, day=day, start=start, end=end
                )
                created_items.append(slot)
            try:
                with transaction.atomic():
                    SlotRoom.objects.create(slot=slot, room=room)
            except IntegrityError:
                # delete all created objects and report error
                for x in created_items:
                    x.delete()
                return messages.ERROR, u'An overlap occurred; the import was cancelled.'
        return messages.SUCCESS, u'Your schedule has been imported.'
dataset/ETHPy150Open pinax/symposion/symposion/schedule/forms.py/ScheduleSectionForm.build_schedule/original