Don't duplicate existing rooms when importing schedule CSV
* Old implementation needs to see exactly the same rooms in exactly the same order every time it loads new data, otherwise it will create a duplicate entry for the room that differs only in display order. * New implementation ignores the display order when checking to see if the room already exists.
This commit is contained in:
parent
cfc19f309f
commit
3239bbe29a
1 changed files with 7 additions and 3 deletions
10
vendor/symposion/schedule/forms.py
vendored
10
vendor/symposion/schedule/forms.py
vendored
|
@ -96,9 +96,13 @@ class ScheduleSectionForm(forms.Form):
|
|||
created_rooms = []
|
||||
rooms = sorted(set([x[self.ROOM_KEY] for x in data]))
|
||||
for i, room in enumerate(rooms):
|
||||
room, created = Room.objects.get_or_create(
|
||||
schedule=self.schedule, name=room, order=i
|
||||
)
|
||||
try:
|
||||
room = Room.objects.get(schedule=self.schedule, name=room)
|
||||
created = False
|
||||
except Room.DoesNotExist:
|
||||
room = Room.objects.create(
|
||||
schedule=self.schedule, name=room, order=i
|
||||
)
|
||||
if created:
|
||||
created_rooms.append(room)
|
||||
return created_rooms
|
||||
|
|
Loading…
Reference in a new issue