Merge pull request #21718 from barredterra/clear-language-cache

This commit is contained in:
Suraj Shetty 2023-07-18 17:27:09 +05:30 committed by GitHub
commit 688fa27456
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -16,6 +16,10 @@ class Language(Document):
def before_rename(self, old, new, merge=False):
validate_with_regex(new, "Name")
def on_update(self):
frappe.cache.delete_value("languages_with_name")
frappe.cache.delete_value("languages")
def validate_with_regex(name, label):
pattern = re.compile("^[a-zA-Z]+[-_]*[a-zA-Z]+$")

View file

@ -357,7 +357,14 @@ def clear_cache(path=None):
:param path: (optional) for the given path"""
from frappe.website.router import clear_routing_cache
for key in ("website_generator_routes", "website_pages", "website_full_index", "sitemap_routes"):
for key in (
"website_generator_routes",
"website_pages",
"website_full_index",
"sitemap_routes",
"languages_with_name",
"languages",
):
frappe.cache.delete_value(key)
clear_routing_cache()