diff --git a/src/core/models/schedules.py b/src/core/models/schedules.py index dc6faaad140072beeb0f1b911eadb65e2f57ea0d..055da53413a8025a50865750e1bbde78bdb0c325 100644 --- a/src/core/models/schedules.py +++ b/src/core/models/schedules.py @@ -187,7 +187,8 @@ class ScheduleSource(models.Model): if not new_mapping and mapping.local_id and mapping.local_id in expected_items: expected_items.remove(mapping.local_id) - return + # signal that we didn't actually load an item + return 'skipped' if new_mapping: try: @@ -219,6 +220,7 @@ class ScheduleSource(models.Model): # ... and delete the incomplete (wrong) mapping mapping.delete() + return 'error' else: # store new item's data @@ -229,7 +231,7 @@ class ScheduleSource(models.Model): 'source_id': item_source_id, 'local_id': str(mapping.local_id), }) - return + return 'added' # note that we've seen the existing room in the imported data if mapping.local_id in expected_items: @@ -247,7 +249,7 @@ class ScheduleSource(models.Model): 'source_id': item_source_id, 'local_id': str(mapping.local_id), }) - return + return 'deleted' # update data on existing room mapping.local_object.from_dict( @@ -265,6 +267,7 @@ class ScheduleSource(models.Model): 'source_id': item_source_id, 'local_id': str(mapping.local_id), }) + return 'seen' def load_data(self, data): assert isinstance(data, dict) @@ -288,7 +291,7 @@ class ScheduleSource(models.Model): # first, load the rooms (as they're needed for events) for r_id, r in data['rooms'].items(): try: - self._load_dataitem( + action = self._load_dataitem( activity=activity, item=r, item_source_id=r_id, @@ -299,6 +302,13 @@ class ScheduleSource(models.Model): 'allow_backend_roomtypes': False, }, ) + + if action == 'skipped': + # if the room has been skipped throw it into the mapping table anyway + r_mapping = self.mappings.get(mapping_type=ScheduleSourceMapping.MappingType.ROOM, source_id=r_id) + assert r_mapping.skip + rooms[r_id] = r_mapping.local_object + except Exception as err: activity.append({ 'action': 'error',