From 2a8902326d99656f19d0b6b7b807b3cc1723b247 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 28 Nov 2016 17:26:53 +0530 Subject: [PATCH] [feature] merge knowledge base in Frappe, fixes frappe/erpnext#6030" --- frappe/config/website.py | 16 +- frappe/hooks.py | 6 +- frappe/patches.txt | 1 + frappe/patches/v7_2/merge_knowledge_base.py | 19 + frappe/templates/generators/help_article.html | 32 ++ .../templates/includes/comments/comments.html | 5 +- frappe/templates/includes/kb_row.html | 15 + .../website/doctype/help_article/__init__.py | 0 .../doctype/help_article/help_article.js | 8 + .../doctype/help_article/help_article.json | 414 ++++++++++++++++++ .../doctype/help_article/help_article.py | 109 +++++ .../doctype/help_article/test_help_article.py | 12 + .../website/doctype/help_category/__init__.py | 0 .../doctype/help_category/help_category.js | 8 + .../doctype/help_category/help_category.json | 222 ++++++++++ .../doctype/help_category/help_category.py | 30 ++ .../help_category/test_help_category.py | 12 + 17 files changed, 903 insertions(+), 6 deletions(-) create mode 100644 frappe/patches/v7_2/merge_knowledge_base.py create mode 100644 frappe/templates/generators/help_article.html create mode 100644 frappe/templates/includes/kb_row.html create mode 100644 frappe/website/doctype/help_article/__init__.py create mode 100644 frappe/website/doctype/help_article/help_article.js create mode 100644 frappe/website/doctype/help_article/help_article.json create mode 100644 frappe/website/doctype/help_article/help_article.py create mode 100644 frappe/website/doctype/help_article/test_help_article.py create mode 100644 frappe/website/doctype/help_category/__init__.py create mode 100644 frappe/website/doctype/help_category/help_category.js create mode 100644 frappe/website/doctype/help_category/help_category.json create mode 100644 frappe/website/doctype/help_category/help_category.py create mode 100644 frappe/website/doctype/help_category/test_help_category.py diff --git a/frappe/config/website.py b/frappe/config/website.py index 9c319e0297..b2691959a0 100644 --- a/frappe/config/website.py +++ b/frappe/config/website.py @@ -84,5 +84,19 @@ def get_data(): "label": _("Portal Settings"), } ] - } + }, + { + "label": _("Knowledge Base"), + "items": [ + { + "type": "doctype", + "name": "Help Category", + }, + { + "type": "doctype", + "name": "Help Article", + }, + ] + }, + ] diff --git a/frappe/hooks.py b/frappe/hooks.py index e3ad554bee..a79e377763 100755 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -48,7 +48,8 @@ web_include_css = [ ] website_route_rules = [ {"from_route": "/blog", "to_route": "Blog Post"}, - {"from_route": "/blog/", "to_route": "Blog Post"} + {"from_route": "/blog/", "to_route": "Blog Post"}, + {"from_route": "/kb/", "to_route": "Help Article"} ] write_file_keys = ["file_url", "file_name"] @@ -57,7 +58,8 @@ notification_config = "frappe.core.notifications.get_notification_config" before_tests = "frappe.utils.install.before_tests" -website_generators = ["Web Page", "Blog Post", "Blog Category", "Web Form"] +website_generators = ["Web Page", "Blog Post", "Blog Category", "Web Form", + "Help Article"] email_append_to = ["Event", "ToDo", "Communication"] diff --git a/frappe/patches.txt b/frappe/patches.txt index 80e6b98f58..afcba8ce6f 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -147,3 +147,4 @@ frappe.patches.v7_1.refactor_integration_broker frappe.patches.v7_1.set_backup_limit frappe.patches.v7_1.disabled_print_settings_for_custom_print_format frappe.patches.v7_2.set_doctype_engine +frappe.patches.v7_2.merge_knowledge_base diff --git a/frappe/patches/v7_2/merge_knowledge_base.py b/frappe/patches/v7_2/merge_knowledge_base.py new file mode 100644 index 0000000000..24b4dcda54 --- /dev/null +++ b/frappe/patches/v7_2/merge_knowledge_base.py @@ -0,0 +1,19 @@ +import frappe + +from frappe.patches.v7_0.re_route import update_routes +from frappe.installer import remove_from_installed_apps + +def execute(): + if 'knowledge_base' in frappe.get_installed_apps(): + frappe.reload_doc('website', 'doctype', 'help_category') + frappe.reload_doc('website', 'doctype', 'help_article') + update_routes(['Help Category', 'Help Article']) + remove_from_installed_apps('knowledge_base') + + # set missing routes + for doctype in ('Help Category', 'Help Article'): + for d in frappe.get_all(doctype, fields=['name', 'route']): + if not d.route: + doc = frappe.get_doc(doctype, d.name) + doc.set_route() + doc.db_update() \ No newline at end of file diff --git a/frappe/templates/generators/help_article.html b/frappe/templates/generators/help_article.html new file mode 100644 index 0000000000..913e6d6a92 --- /dev/null +++ b/frappe/templates/generators/help_article.html @@ -0,0 +1,32 @@ +{% extends "templates/web.html" %} + +{% block header %} +

{{ title }}

+{% endblock %} + +{% block page_content %} + +
+
+

Comments

+ {% include 'templates/includes/comments/comments.html' %} +
+ +{% endblock %} diff --git a/frappe/templates/includes/comments/comments.html b/frappe/templates/includes/comments/comments.html index 1fddcbc30a..15abea27ec 100644 --- a/frappe/templates/includes/comments/comments.html +++ b/frappe/templates/includes/comments/comments.html @@ -2,8 +2,7 @@
{{ comment_text or "" }}
{% if not comment_list %}
-

{{ _("Start a new discussion.") }}

-
+

{{ _("No comments yet. Start a new discussion.") }}

{% endif %} @@ -20,7 +19,7 @@
- {{ _("Add Comment") }} + {{ _("Add Comment") }}