B: Fix cache after changing aliases
Some checks are pending
Backend CI / build (3.12) (push) Waiting to run
Frontend CI / build (22.x) (push) Waiting to run

This commit is contained in:
Ivan 2024-09-12 17:56:09 +03:00
parent c18efc93e1
commit bc166b962e

View File

@ -363,6 +363,8 @@ class RSForm:
for cst in self.cache.constituents:
if cst.apply_mapping(mapping, change_aliases):
update_list.append(cst)
if change_aliases:
self.cache.reset_aliases()
Constituenta.objects.bulk_update(update_list, ['alias', 'definition_formal', 'term_raw', 'definition_raw'])
self.save(update_fields=['time_update'])
@ -555,6 +557,9 @@ class RSFormCache:
if not self.is_loaded:
self.reload()
def reset_aliases(self) -> None:
self.by_alias = {cst.alias: cst for cst in self.constituents}
def clear(self) -> None:
self.constituents = []
self.by_id = {}