agendas: fix missing options in agenda import/export (#86634)

This commit is contained in:
Lauréline Guérin 2024-02-22 16:36:49 +01:00
parent e6db17f145
commit f6a0b58167
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 34 additions and 0 deletions

View File

@ -484,7 +484,14 @@ class Agenda(WithApplicationMixin, models.Model):
agenda['booking_check_filters'] = self.booking_check_filters
agenda['event_display_template'] = self.event_display_template
agenda['mark_event_checked_auto'] = self.mark_event_checked_auto
agenda['disable_check_update'] = self.disable_check_update
agenda['enable_check_for_future_events'] = self.enable_check_for_future_events
agenda['booking_extra_user_block_template'] = self.booking_extra_user_block_template
agenda['events_type'] = self.events_type.slug if self.events_type else None
agenda['partial_bookings'] = self.partial_bookings
if self.partial_bookings:
agenda['invoicing_tolerance'] = self.invoicing_tolerance
agenda['invoicing_unit'] = self.invoicing_unit
elif self.kind == 'meetings':
agenda['meetingtypes'] = [x.export_json() for x in self.meetingtype_set.filter(deleted=False)]
agenda['desks'] = [desk.export_json() for desk in self.desk_set.all()]

View File

@ -192,6 +192,9 @@ def test_import_export_events_agenda_options(app):
booking_check_filters='foo,bar',
event_display_template='foo bar',
mark_event_checked_auto=True,
disable_check_update=True,
enable_check_for_future_events=True,
booking_extra_user_block_template='foobar',
)
Desk.objects.create(agenda=agenda, slug='_exceptions_holder')
@ -213,6 +216,30 @@ def test_import_export_events_agenda_options(app):
assert agenda.booking_check_filters == 'foo,bar'
assert agenda.event_display_template == 'foo bar'
assert agenda.mark_event_checked_auto is True
assert agenda.disable_check_update is True
assert agenda.enable_check_for_future_events is True
assert agenda.booking_extra_user_block_template == 'foobar'
agenda.partial_bookings = True
agenda.invoicing_tolerance = 5
agenda.invoicing_unit = 'minute'
agenda.save()
output = get_output_of_command('export_site')
assert len(json.loads(output)['agendas']) == 1
import_site(data={}, clean=True)
with tempfile.NamedTemporaryFile() as f:
f.write(force_bytes(output))
f.flush()
call_command('import_site', f.name)
assert Agenda.objects.count() == 1
agenda = Agenda.objects.first()
assert agenda.partial_bookings is True
assert agenda.invoicing_tolerance == 5
assert agenda.invoicing_unit == 'minute'
def test_import_export_event_details(app):