diff --git a/foundation/erpnext_foundation/doctype/chapter/chapter.json b/foundation/erpnext_foundation/doctype/chapter/chapter.json index e848a150..9a3dc214 100644 --- a/foundation/erpnext_foundation/doctype/chapter/chapter.json +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.json @@ -267,7 +267,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-05-11 12:54:19.260083", + "modified": "2017-05-11 17:07:13.825474", "modified_by": "Administrator", "module": "ERPNext Foundation", "name": "Chapter", diff --git a/foundation/erpnext_foundation/doctype/chapter/chapter.py b/foundation/erpnext_foundation/doctype/chapter/chapter.py index dcbff3d4..323a15ac 100644 --- a/foundation/erpnext_foundation/doctype/chapter/chapter.py +++ b/foundation/erpnext_foundation/doctype/chapter/chapter.py @@ -5,11 +5,20 @@ from __future__ import unicode_literals import frappe from frappe.website.website_generator import WebsiteGenerator +from frappe.model.document import Document +from frappe import _ class Chapter(WebsiteGenerator): def get_context(self, context): context.no_cache = True - pass + + def validate(self): + chapter_head = self.chapter_head + chapter = frappe.get_all('Chapter', filters={'published': True}, fields=['chapter_head']) + + if chapter_head in [d.chapter_head for d in chapter]: + frappe.throw(_('You are not allow to create more than one Chapter')) + def get_list_context(context): context.allow_guest = True diff --git a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html index a4d796e2..ed2ce9f6 100644 --- a/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html +++ b/foundation/erpnext_foundation/doctype/chapter/templates/chapter.html @@ -43,24 +43,6 @@
-