agendas: ignore missing category during agenda import (#57424)
This commit is contained in:
parent
f974cfe604
commit
d81e159827
|
@ -438,7 +438,7 @@ class Agenda(models.Model):
|
|||
try:
|
||||
data['category'] = Category.objects.get(slug=data['category'])
|
||||
except Category.DoesNotExist:
|
||||
raise AgendaImportError(_('Missing "%s" category') % data['category'])
|
||||
del data['category']
|
||||
if data.get('absence_reasons_group'):
|
||||
try:
|
||||
data['absence_reasons_group'] = AbsenceReasonGroup.objects.get(
|
||||
|
|
|
@ -386,17 +386,17 @@ def test_import_export_categories(app):
|
|||
data = json.loads(output)
|
||||
del data['categories']
|
||||
|
||||
with pytest.raises(AgendaImportError) as excinfo:
|
||||
import_site(data, overwrite=True)
|
||||
assert str(excinfo.value) == 'Missing "foo" category'
|
||||
import_site(data.copy(), overwrite=True)
|
||||
agenda = Agenda.objects.get(slug=agenda.slug)
|
||||
assert agenda.category is None
|
||||
|
||||
category = Category.objects.create(label='foobar')
|
||||
with pytest.raises(AgendaImportError) as excinfo:
|
||||
import_site(data, overwrite=True)
|
||||
assert str(excinfo.value) == 'Missing "foo" category'
|
||||
import_site(data.copy(), overwrite=True)
|
||||
agenda = Agenda.objects.get(slug=agenda.slug)
|
||||
assert agenda.category is None
|
||||
|
||||
category = Category.objects.create(label='foo')
|
||||
import_site(data, overwrite=True)
|
||||
import_site(data.copy(), overwrite=True)
|
||||
agenda = Agenda.objects.get(slug=agenda.slug)
|
||||
assert agenda.category == category
|
||||
|
||||
|
|
Loading…
Reference in New Issue