Browse Source

[feature] merge knowledge base in Frappe, fixes frappe/erpnext#6030"

version-14
Rushabh Mehta 8 years ago
parent
commit
2a8902326d
17 changed files with 903 additions and 6 deletions
  1. +15
    -1
      frappe/config/website.py
  2. +4
    -2
      frappe/hooks.py
  3. +1
    -0
      frappe/patches.txt
  4. +19
    -0
      frappe/patches/v7_2/merge_knowledge_base.py
  5. +32
    -0
      frappe/templates/generators/help_article.html
  6. +2
    -3
      frappe/templates/includes/comments/comments.html
  7. +15
    -0
      frappe/templates/includes/kb_row.html
  8. +0
    -0
      frappe/website/doctype/help_article/__init__.py
  9. +8
    -0
      frappe/website/doctype/help_article/help_article.js
  10. +414
    -0
      frappe/website/doctype/help_article/help_article.json
  11. +109
    -0
      frappe/website/doctype/help_article/help_article.py
  12. +12
    -0
      frappe/website/doctype/help_article/test_help_article.py
  13. +0
    -0
      frappe/website/doctype/help_category/__init__.py
  14. +8
    -0
      frappe/website/doctype/help_category/help_category.js
  15. +222
    -0
      frappe/website/doctype/help_category/help_category.json
  16. +30
    -0
      frappe/website/doctype/help_category/help_category.py
  17. +12
    -0
      frappe/website/doctype/help_category/test_help_category.py

+ 15
- 1
frappe/config/website.py View File

@@ -84,5 +84,19 @@ def get_data():
"label": _("Portal Settings"), "label": _("Portal Settings"),
} }
] ]
}
},
{
"label": _("Knowledge Base"),
"items": [
{
"type": "doctype",
"name": "Help Category",
},
{
"type": "doctype",
"name": "Help Article",
},
]
},

] ]

+ 4
- 2
frappe/hooks.py View File

@@ -48,7 +48,8 @@ web_include_css = [
] ]
website_route_rules = [ website_route_rules = [
{"from_route": "/blog", "to_route": "Blog Post"}, {"from_route": "/blog", "to_route": "Blog Post"},
{"from_route": "/blog/<category>", "to_route": "Blog Post"}
{"from_route": "/blog/<category>", "to_route": "Blog Post"},
{"from_route": "/kb/<category>", "to_route": "Help Article"}
] ]


write_file_keys = ["file_url", "file_name"] 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" 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"] email_append_to = ["Event", "ToDo", "Communication"]




+ 1
- 0
frappe/patches.txt View File

@@ -147,3 +147,4 @@ frappe.patches.v7_1.refactor_integration_broker
frappe.patches.v7_1.set_backup_limit frappe.patches.v7_1.set_backup_limit
frappe.patches.v7_1.disabled_print_settings_for_custom_print_format frappe.patches.v7_1.disabled_print_settings_for_custom_print_format
frappe.patches.v7_2.set_doctype_engine frappe.patches.v7_2.set_doctype_engine
frappe.patches.v7_2.merge_knowledge_base

+ 19
- 0
frappe/patches/v7_2/merge_knowledge_base.py View File

@@ -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()

+ 32
- 0
frappe/templates/generators/help_article.html View File

@@ -0,0 +1,32 @@
{% extends "templates/web.html" %}

{% block header %}
<h1>{{ title }}</h1>
{% endblock %}

{% block page_content %}
<article class="help-content" itemscope itemtype="http://schema.org/BlogPost">
<div class="help-article-info">
<p>
<span class="indicator {{ level_class }}">{{ level }}</span>
</p>
<h6 class='text-muted'>By {{ author }} on {{ frappe.format_date(creation) }}</h6>
</div>
<div class="longform" itemprop="articleBody" style='margin: 30px 0px;'>
{{ content }}
</div>

<p><br><a href="/{{ category.route }}" class='text-muted small'>
{{ _("More articles on {0}").format(category.name) }}</a></p>
</article>
<div class="help-article-comments">
<hr>
<h4>Comments</h4>
{% include 'templates/includes/comments/comments.html' %}
</div>
<script>
frappe.ready(function() {
frappe.set_search_path("/kb");
});
</script>
{% endblock %}

+ 2
- 3
frappe/templates/includes/comments/comments.html View File

@@ -2,8 +2,7 @@
<div class="comment-header">{{ comment_text or "" }}</div> <div class="comment-header">{{ comment_text or "" }}</div>
{% if not comment_list %} {% if not comment_list %}
<div class="no-comment"> <div class="no-comment">
<p class="text-muted">{{ _("Start a new discussion.") }}</p>
<br>
<p class="text-muted small">{{ _("No comments yet. Start a new discussion.") }}</p>
</div> </div>
{% endif %} {% endif %}


@@ -20,7 +19,7 @@
</div> </div>


<div class="comment-form-wrapper"> <div class="comment-form-wrapper">
<a class="add-comment btn btn-default btn-sm">{{ _("Add Comment") }}</a>
<a class="add-comment btn btn-default btn-xs">{{ _("Add Comment") }}</a>
<div style="display: none;" id="comment-form"> <div style="display: none;" id="comment-form">
<p>{{ _("Leave a Comment") }}</p> <p>{{ _("Leave a Comment") }}</p>
<div class="alert" style="display:none;"></div> <div class="alert" style="display:none;"></div>


+ 15
- 0
frappe/templates/includes/kb_row.html View File

@@ -0,0 +1,15 @@
{% set article = doc %}
<div class="row">
<div class="col-sm-9">
<p>
<a class="no-decoration" href="/{{ article.route }}">
{{ article.title }}
</a><br>
</p>
</div>
<div class="col-sm-3 indicator-column text-right">
<span class="help-category-label indicator-right {{ get_level_class(article.level) }}">
{{ article.level }}
</span>
</div>
</div>

+ 0
- 0
frappe/website/doctype/help_article/__init__.py View File


+ 8
- 0
frappe/website/doctype/help_article/help_article.js View File

@@ -0,0 +1,8 @@
// Copyright (c) 2016, Frappe Technologies and contributors
// For license information, please see license.txt

frappe.ui.form.on('Help Article', {
refresh: function(frm) {

}
});

+ 414
- 0
frappe/website/doctype/help_article/help_article.json View File

@@ -0,0 +1,414 @@
{
"allow_copy": 0,
"allow_import": 1,
"allow_rename": 0,
"beta": 0,
"creation": "2014-10-30 14:25:53.780105",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 0,
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "title",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Title",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "category",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Category",
"length": 0,
"no_copy": 0,
"options": "Help Category",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "published",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Published",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_4",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "user_fullname",
"fieldname": "author",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Author",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "level",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Level",
"length": 0,
"no_copy": 0,
"options": "Beginner\nIntermediate\nExpert",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_7",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "content",
"fieldtype": "Text Editor",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Content",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "likes",
"fieldtype": "Int",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Likes",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "route",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Route",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "user",
"fieldname": "owner",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Owner",
"length": 0,
"no_copy": 0,
"options": "User",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "icon-file-alt",
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-11-28 06:52:49.173892",
"modified_by": "Administrator",
"module": "Website",
"name": "Help Article",
"name_case": "",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"if_owner": 0,
"import": 1,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Knowledge Base Editor",
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 1,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 0,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 0,
"read": 1,
"report": 0,
"role": "Knowledge Base Contributor",
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 0,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 0,
"read": 1,
"report": 0,
"role": "Guest",
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 0
}
],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "title",
"track_seen": 0
}

+ 109
- 0
frappe/website/doctype/help_article/help_article.py View File

@@ -0,0 +1,109 @@
# Copyright (c) 2013, Frappe and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe.website.website_generator import WebsiteGenerator
from frappe.utils import is_markdown, markdown
from frappe.website.utils import get_comment_list
from frappe import _

class HelpArticle(WebsiteGenerator):
website = frappe._dict(
condition_field = "published",
template = "templates/generators/help_article.html",
)

def validate(self):
self.set_route()

def set_route(self):
'''Set route from category and title if missing'''
if not self.route:
self.route = '/'.join([frappe.get_value('Help Category', self.category, 'route'),
self.scrub(self.title)])

def on_update(self):
self.update_category()
clear_cache()
super(HelpArticle, self).on_update()

def update_category(self):
cnt = frappe.db.sql("""select count(*) from `tabHelp Article`
where category=%s and ifnull(published,0)=1""", self.category)[0][0]
cat = frappe.get_doc("Help Category", self.category)
cat.help_articles = cnt
cat.save()

def get_context(self, context):
if is_markdown(context.content):
context.content = markdown(context.content)
context.login_required = True
context.category = frappe.get_doc('Help Category', self.category)
context.level_class = get_level_class(self.level)
context.comment_list = get_comment_list(self.doctype, self.name)
context.show_sidebar = True
context.sidebar_items = get_sidebar_items()
context.parents = self.get_parents(context)

def get_parents(self, context):
return [{"title": context.category.category_name, "name":context.category.route}]

def get_list_context(context=None):
filters = dict(published=1)

category = frappe.db.get_value("Help Category", { "route": frappe.local.path })

if category:
filters['category'] = category

list_context = frappe._dict(
title = category or _("Knowledge Base"),
row_template = "templates/includes/kb_row.html",
get_level_class = get_level_class,
show_sidebar = True,
sidebar_items = get_sidebar_items(),
hide_filters = True,
filters = filters,
category = frappe.local.form_dict.category,
no_breadcrumbs = True
)


if frappe.local.form_dict.txt:
list_context.blog_subtitle = _('Filtered by "{0}"').format(frappe.local.form_dict.txt)
#
# list_context.update(frappe.get_doc("Blog Settings", "Blog Settings").as_dict())
return list_context

def get_level_class(level):
return {
"Beginner": "green",
"Intermediate": "orange",
"Expert": "red"
}[level]

def get_sidebar_items():
def _get():
return frappe.db.sql("""select
concat(category_name, " (", help_articles, ")") as title,
concat('/', route) as route
from
`tabHelp Category`
where
ifnull(published,0)=1 and help_articles > 0
order by
help_articles desc""", as_dict=True)

return frappe.cache().get_value("knowledge_base:category_sidebar", _get)

def clear_cache():
clear_website_cache()

from frappe.website.render import clear_cache
clear_cache()

def clear_website_cache(path=None):
frappe.cache().delete_value("knowledge_base:category_sidebar")
frappe.cache().delete_value("knowledge_base:faq")


+ 12
- 0
frappe/website/doctype/help_article/test_help_article.py View File

@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and Contributors
# See license.txt
from __future__ import unicode_literals

import frappe
import unittest

# test_records = frappe.get_test_records('Help Article')

class TestHelpArticle(unittest.TestCase):
pass

+ 0
- 0
frappe/website/doctype/help_category/__init__.py View File


+ 8
- 0
frappe/website/doctype/help_category/help_category.js View File

@@ -0,0 +1,8 @@
// Copyright (c) 2016, Frappe Technologies and contributors
// For license information, please see license.txt

frappe.ui.form.on('Help Category', {
refresh: function(frm) {

}
});

+ 222
- 0
frappe/website/doctype/help_category/help_category.json View File

@@ -0,0 +1,222 @@
{
"allow_copy": 0,
"allow_import": 1,
"allow_rename": 0,
"autoname": "",
"beta": 0,
"creation": "2014-10-30 14:23:30.958074",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 0,
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "category_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Category Name",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "category_description",
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Category Description",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "published",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Published",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "help_articles",
"fieldtype": "Int",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Help Articles",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "route",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Route",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "icon-list",
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-11-28 02:39:47.111785",
"modified_by": "Administrator",
"module": "Website",
"name": "Help Category",
"name_case": "Title Case",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"if_owner": 0,
"import": 1,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Knowledge Base Editor",
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 0,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 0,
"read": 1,
"report": 0,
"role": "Knowledge Base Contributor",
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 0
}
],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_seen": 0
}

+ 30
- 0
frappe/website/doctype/help_category/help_category.py View File

@@ -0,0 +1,30 @@
# Copyright (c) 2013, Frappe and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe.website.website_generator import WebsiteGenerator
from frappe.website.doctype.help_article.help_article import clear_cache

class HelpCategory(WebsiteGenerator):
website = frappe._dict(
condition_field = "published",
page_title_field = "category_name"
)

def before_insert(self):
self.published=1

def autoname(self):
self.name = self.category_name

def validate(self):
self.set_route()

def set_route(self):
if not self.route:
self.route = 'kb/' + self.scrub(self.category_name)

def on_update(self):
clear_cache()
super(HelpCategory, self).on_update()

+ 12
- 0
frappe/website/doctype/help_category/test_help_category.py View File

@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and Contributors
# See license.txt
from __future__ import unicode_literals

import frappe
import unittest

# test_records = frappe.get_test_records('Help Category')

class TestHelpCategory(unittest.TestCase):
pass

Loading…
Cancel
Save