Skip to content

Commit

Permalink
feat: clear cache button
Browse files Browse the repository at this point in the history
  • Loading branch information
BreadGenie committed Jul 25, 2023
1 parent 2059d21 commit d5284b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions wiki/wiki/doctype/wiki_settings/wiki_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
frappe.ui.form.on("Wiki Settings", {
refresh: function (frm) {
frm.add_web_link("/wiki", __("See on website"));

frm.add_custom_button("Clear Wiki Page Cache", () => {
frm.call({
method: "clear_wiki_page_cache",
callback: (r) => {
if (r.message) {
frappe.show_alert({
message: "Wiki Page Cache Cleared",
indicator: "blue",
});
}
},
});
});
},

onload: function (frm) {
Expand Down
8 changes: 8 additions & 0 deletions wiki/wiki/doctype/wiki_settings/wiki_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ def on_update(self):
@frappe.whitelist()
def get_all_spaces():
return frappe.get_all("Wiki Space", pluck="route")


@frappe.whitelist()
def clear_wiki_page_cache():
for route in frappe.get_all("Wiki Page", pluck="route"):
frappe.cache().hdel("website_page", route)

return True

0 comments on commit d5284b4

Please sign in to comment.