mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-26 09:52:16 +00:00
Fix importer trying to set pk for qualifications
This doesn't work because of the old DB structure
This commit is contained in:
@@ -124,8 +124,9 @@ class Command(BaseCommand):
|
|||||||
for child in root:
|
for child in root:
|
||||||
depths = [("Training_Started", models.TrainingItemQualification.STARTED),
|
depths = [("Training_Started", models.TrainingItemQualification.STARTED),
|
||||||
("Training_Complete", models.TrainingItemQualification.COMPLETE),
|
("Training_Complete", models.TrainingItemQualification.COMPLETE),
|
||||||
("Competency_Assessed", models.TrainingItemQualification.PASSED_OUT)]
|
("Competency_Assessed", models.TrainingItemQualification.PASSED_OUT),]
|
||||||
for depth, depth_index in depths:
|
|
||||||
|
for (depth, depth_index) in depths:
|
||||||
if child.find('{}_Date'.format(depth)) is not None:
|
if child.find('{}_Date'.format(depth)) is not None:
|
||||||
if child.find('{}_Assessor_ID'.format(depth)) is None:
|
if child.find('{}_Assessor_ID'.format(depth)) is None:
|
||||||
print("Training Record #{} had no supervisor. Assigning System User.".format(child.find('ID').text))
|
print("Training Record #{} had no supervisor. Assigning System User.".format(child.find('ID').text))
|
||||||
@@ -138,7 +139,6 @@ class Command(BaseCommand):
|
|||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
obj, created = models.TrainingItemQualification.objects.update_or_create(
|
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)),
|
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]),
|
trainee=Profile.objects.get(pk=self.id_map[child.find('Member_ID').text]),
|
||||||
depth=depth_index,
|
depth=depth_index,
|
||||||
@@ -154,7 +154,7 @@ class Command(BaseCommand):
|
|||||||
else:
|
else:
|
||||||
tally[0] += 1
|
tally[0] += 1
|
||||||
except IntegrityError: # Eh?
|
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:
|
except AttributeError:
|
||||||
print(child.find('ID').text)
|
print(child.find('ID').text)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user