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
6
vendor/symposion/schedule/forms.py
vendored
6
vendor/symposion/schedule/forms.py
vendored
|
@ -96,7 +96,11 @@ class ScheduleSectionForm(forms.Form):
|
||||||
created_rooms = []
|
created_rooms = []
|
||||||
rooms = sorted(set([x[self.ROOM_KEY] for x in data]))
|
rooms = sorted(set([x[self.ROOM_KEY] for x in data]))
|
||||||
for i, room in enumerate(rooms):
|
for i, room in enumerate(rooms):
|
||||||
room, created = Room.objects.get_or_create(
|
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
|
schedule=self.schedule, name=room, order=i
|
||||||
)
|
)
|
||||||
if created:
|
if created:
|
||||||
|
|
Loading…
Reference in a new issue