From 3fe388af2697cf73b2b25ba7a7c72928f6303f7c Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Sun, 2 Jan 2022 11:05:08 +0000 Subject: [PATCH] Fix importer trying to set pk for qualifications This doesn't work because of the old DB structure --- training/management/commands/import_old_db.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/training/management/commands/import_old_db.py b/training/management/commands/import_old_db.py index b0491c5a..66335925 100644 --- a/training/management/commands/import_old_db.py +++ b/training/management/commands/import_old_db.py @@ -124,8 +124,9 @@ class Command(BaseCommand): for child in root: depths = [("Training_Started", models.TrainingItemQualification.STARTED), ("Training_Complete", models.TrainingItemQualification.COMPLETE), - ("Competency_Assessed", models.TrainingItemQualification.PASSED_OUT)] - for depth, depth_index in depths: + ("Competency_Assessed", models.TrainingItemQualification.PASSED_OUT),] + + for (depth, depth_index) in depths: if child.find('{}_Date'.format(depth)) is not None: if child.find('{}_Assessor_ID'.format(depth)) is None: print("Training Record #{} had no supervisor. Assigning System User.".format(child.find('ID').text)) @@ -138,7 +139,6 @@ class Command(BaseCommand): continue try: obj, created = models.TrainingItemQualification.objects.update_or_create( - pk=int(child.find('ID').text), item=models.TrainingItem.objects.get(pk=int(child.find('Training_Item_ID').text)), trainee=Profile.objects.get(pk=self.id_map[child.find('Member_ID').text]), depth=depth_index, @@ -154,7 +154,7 @@ class Command(BaseCommand): else: tally[0] += 1 except IntegrityError: # Eh? - print("Training Record #{} is duplicate. ಠ_ಠ".format(child.find('ID').text)) + print("Training Record #{} is probably duplicate. ಠ_ಠ".format(child.find('ID').text)) except AttributeError: print(child.find('ID').text)