digitalfabrik/integreat-cms

Imprint cache not invalidated when language tree nodes are deleted

Opened this issue · 0 comments

Describe the Bug

After deleting language tree nodes, the imprint form still shows the deleted languages in its tabs.

Steps to Reproduce

  1. Enable caching
  2. Go to imprint form to cache the object
  3. Delete language tree node
  4. Return to imprint form and still see the tab of the deleted language

Expected Behavior

The language tabs should not list deleted languages

Actual Behavior

Probably, we have to invalidate the cache of the imprint object here:

def manually_invalidate_models(region: Region) -> None:
"""
This is a helper function to iterate through all affected objects and invalidate their cache.
This is necessary as the original cache invalidation of cacheops only triggers for direct foreign key relationships.
:param region: The affected region
"""
for page in region.pages.all():
invalidate_obj(page)
for event in region.events.all():
invalidate_obj(event)
for poi in region.pois.all():
invalidate_obj(poi)
for push_notification in region.push_notifications.all():
invalidate_obj(push_notification)