Mise à jour pour Django 4.0

This commit is contained in:
Claude Paroz 2022-02-15 12:15:04 +01:00
parent 2de8ccc805
commit 4d3b665183
2 changed files with 5 additions and 5 deletions

View file

@ -1,5 +1,5 @@
Django>=3.1,<4.0
tabimport>=0.4.0
Django>=3.2<4.1
tabimport==0.5.1
xlrd<2 # Required by tabimport
openpyxl==3.0.5
reportlab

View file

@ -188,7 +188,7 @@ class StudentImportView(ImportViewBase):
for line in up_file:
student_defaults = {
val: strip(line.get(key, '')) for key, val in self.student_mapping.items()
val: '' if line[key] is None else strip(line[key]) for key, val in self.student_mapping.items()
}
if student_defaults['ext_id'] in seen_students_ids:
# Second line for student, ignore it
@ -200,7 +200,7 @@ class StudentImportView(ImportViewBase):
if self.corporation_mapping:
corporation_defaults = {
val: strip(line[key]) for key, val in self.corporation_mapping.items()
val: '' if line[key] is None else strip(line[key]) for key, val in self.corporation_mapping.items()
}
if isinstance(corporation_defaults['pcode'], float):
corporation_defaults['pcode'] = int(corporation_defaults['pcode'])
@ -271,7 +271,7 @@ class StudentImportView(ImportViewBase):
def get_corporation(self, corp_values):
if corp_values['ext_id'] == '':
return None
if 'city' in corp_values and is_int(corp_values['city'][:4]):
if corp_values.get('city') and is_int(corp_values['city'][:4]):
corp_values['pcode'], _, corp_values['city'] = corp_values['city'].partition(' ')
try:
corp, created = Corporation.objects.get_or_create(