fix(minor): Unpublish article when category is unpublished #15361
This commit is contained in:
parent
f7ff072b5a
commit
cb2e803d0c
2 changed files with 17 additions and 0 deletions
|
|
@ -39,6 +39,18 @@ class TestHelpArticle(FrappeTestCase):
|
|||
self.assertEqual(self.help_article.helpful, 1)
|
||||
self.assertEqual(self.help_article.not_helpful, 1)
|
||||
|
||||
def test_category_disable(self):
|
||||
self.help_article.load_from_db()
|
||||
self.help_article.published = 1
|
||||
self.help_article.save()
|
||||
|
||||
self.help_category.load_from_db()
|
||||
self.help_category.published = 0
|
||||
self.help_category.save()
|
||||
|
||||
self.help_article.load_from_db()
|
||||
self.assertEqual(self.help_article.published, 0)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls) -> None:
|
||||
frappe.delete_doc(cls.help_article.doctype, cls.help_article.name)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,11 @@ class HelpCategory(WebsiteGenerator):
|
|||
def validate(self):
|
||||
self.set_route()
|
||||
|
||||
# disable help articles of this category
|
||||
if not self.published:
|
||||
for d in frappe.get_all("Help Article", dict(category=self.name)):
|
||||
frappe.db.set_value("Help Article", d.name, "published", 0)
|
||||
|
||||
def set_route(self):
|
||||
if not self.route:
|
||||
self.route = "kb/" + self.scrub(self.category_name)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue