export_import: snapshots on application import (#87653)
This commit is contained in:
parent
07512150e8
commit
df0e356e75
|
@ -260,6 +260,11 @@ class BundleImport(GenericAPIView):
|
|||
self.application, existing_component
|
||||
)
|
||||
self.application_elements.add(element.content_object)
|
||||
if self.install is True:
|
||||
existing_component.take_snapshot(
|
||||
comment=_('Application (%s)') % self.application,
|
||||
application=self.application,
|
||||
)
|
||||
|
||||
def unlink_obsolete_objects(self):
|
||||
known_elements = ApplicationElement.objects.filter(application=self.application)
|
||||
|
|
|
@ -506,6 +506,12 @@ def test_bundle_import(app, admin_user):
|
|||
assert application.editable is False
|
||||
assert application.visible is True
|
||||
assert ApplicationElement.objects.count() == 8
|
||||
for model in [Agenda, Category, EventsType, Resource, UnavailabilityCalendar]:
|
||||
for instance in model.objects.all():
|
||||
last_snapshot = model.get_snapshot_model().objects.filter(instance=instance).latest('pk')
|
||||
assert last_snapshot.comment == 'Application (Test)'
|
||||
assert last_snapshot.application_slug == 'test'
|
||||
assert last_snapshot.application_version == '42.0'
|
||||
|
||||
# check editable flag is kept on install
|
||||
application.editable = True
|
||||
|
@ -535,6 +541,12 @@ def test_bundle_import(app, admin_user):
|
|||
).exists()
|
||||
is False
|
||||
)
|
||||
for model in [Agenda, Category, EventsType, Resource, UnavailabilityCalendar]:
|
||||
for instance in model.objects.all():
|
||||
last_snapshot = model.get_snapshot_model().objects.filter(instance=instance).latest('pk')
|
||||
assert last_snapshot.comment == 'Application (Test)'
|
||||
assert last_snapshot.application_slug == 'test'
|
||||
assert last_snapshot.application_version == '42.1'
|
||||
|
||||
|
||||
def test_bundle_declare(app, admin_user):
|
||||
|
|
Loading…
Reference in New Issue