From 9b10e362f7bfbc0daed24a1b9db2957e4d28f3f3 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 24 May 2013 16:00:56 +0530 Subject: [PATCH] [form/list] ui fixes, [note] new table to merge question + answer --- config.json | 9 +-- utilities/doctype/note/__init__.py | 0 utilities/doctype/note/note.py | 19 ++++++ utilities/doctype/note/note.txt | 75 +++++++++++++++++++++++ utilities/doctype/note_user/__init__.py | 0 utilities/doctype/note_user/note_user.py | 8 +++ utilities/doctype/note_user/note_user.txt | 45 ++++++++++++++ 7 files changed, 152 insertions(+), 4 deletions(-) create mode 100644 utilities/doctype/note/__init__.py create mode 100644 utilities/doctype/note/note.py create mode 100644 utilities/doctype/note/note.txt create mode 100644 utilities/doctype/note_user/__init__.py create mode 100644 utilities/doctype/note_user/note_user.py create mode 100644 utilities/doctype/note_user/note_user.txt diff --git a/config.json b/config.json index ff6f80ffff..e2c22bc031 100644 --- a/config.json +++ b/config.json @@ -68,11 +68,12 @@ "icon": "icon-play", "label": "Activity" }, - "Knowledge Base": { - "type": "page", - "link": "questions", + "Notes": { + "type": "list", + "doctype": "Note", + "link": "List/Note", "color": "#01372b", - "label": "Knowledge Base", + "label": "Notes", "icon": "icon-question-sign" } }, diff --git a/utilities/doctype/note/__init__.py b/utilities/doctype/note/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utilities/doctype/note/note.py b/utilities/doctype/note/note.py new file mode 100644 index 0000000000..3a1799443b --- /dev/null +++ b/utilities/doctype/note/note.py @@ -0,0 +1,19 @@ +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl + + def onload(self): + if webnotes.session.user != self.doc.owner: + if webnotes.session.user not in [d.user for d in self.doclist if d.doctype=="Note User"]: + webnotes.msgprint("You are not authorized to read this record.", raise_exception=True) + + def validate(self): + if webnotes.session.user != self.doc.owner: + if webnotes.session.user not in webnotes.conn.sql_list("""select user from `tabNote User` + where parent=%s and permission='Edit'""", self.doc.name): + webnotes.msgprint("You are not authorized to edit this record.", raise_exception=True) diff --git a/utilities/doctype/note/note.txt b/utilities/doctype/note/note.txt new file mode 100644 index 0000000000..2deb02746e --- /dev/null +++ b/utilities/doctype/note/note.txt @@ -0,0 +1,75 @@ +[ + { + "creation": "2013-05-24 13:41:00", + "docstatus": 0, + "modified": "2013-05-24 15:47:11", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "allow_rename": 1, + "autoname": "field:title", + "description": "Note is a free page where users can share documents / notes", + "doctype": "DocType", + "document_type": "Transaction", + "module": "Utilities", + "name": "__common__", + "read_only_onload": 1 + }, + { + "doctype": "DocField", + "name": "__common__", + "parent": "Note", + "parentfield": "fields", + "parenttype": "DocType", + "permlevel": 0 + }, + { + "cancel": 1, + "create": 1, + "doctype": "DocPerm", + "name": "__common__", + "parent": "Note", + "parentfield": "permissions", + "parenttype": "DocType", + "permlevel": 0, + "read": 1, + "role": "All", + "write": 1 + }, + { + "doctype": "DocType", + "name": "Note" + }, + { + "doctype": "DocField", + "fieldname": "title", + "fieldtype": "Data", + "label": "Title", + "print_hide": 1 + }, + { + "description": "Help: To link to another record in the system, use \"#Form/Note/[Note Name]\" as the Link URL. (don't use \"http://\")", + "doctype": "DocField", + "fieldname": "content", + "fieldtype": "Text Editor", + "in_list_view": 0, + "label": "Content" + }, + { + "doctype": "DocField", + "fieldname": "share", + "fieldtype": "Section Break", + "label": "Share" + }, + { + "doctype": "DocField", + "fieldname": "share_with", + "fieldtype": "Table", + "label": "Share With", + "options": "Note User" + }, + { + "doctype": "DocPerm" + } +] \ No newline at end of file diff --git a/utilities/doctype/note_user/__init__.py b/utilities/doctype/note_user/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utilities/doctype/note_user/note_user.py b/utilities/doctype/note_user/note_user.py new file mode 100644 index 0000000000..928aa9ff9f --- /dev/null +++ b/utilities/doctype/note_user/note_user.py @@ -0,0 +1,8 @@ +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/utilities/doctype/note_user/note_user.txt b/utilities/doctype/note_user/note_user.txt new file mode 100644 index 0000000000..2d82bb0384 --- /dev/null +++ b/utilities/doctype/note_user/note_user.txt @@ -0,0 +1,45 @@ +[ + { + "creation": "2013-05-24 14:24:48", + "docstatus": 0, + "modified": "2013-05-24 14:24:48", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "description": "List of users who can edit a particular Note", + "doctype": "DocType", + "document_type": "Other", + "istable": 1, + "module": "Utilities", + "name": "__common__" + }, + { + "doctype": "DocField", + "name": "__common__", + "parent": "Note User", + "parentfield": "fields", + "parenttype": "DocType", + "permlevel": 0 + }, + { + "doctype": "DocType", + "name": "Note User" + }, + { + "doctype": "DocField", + "fieldname": "user", + "fieldtype": "Link", + "label": "User", + "options": "Profile", + "reqd": 1 + }, + { + "default": "Edit", + "doctype": "DocField", + "fieldname": "permission", + "fieldtype": "Select", + "label": "Permission", + "options": "Edit\nRead" + } +] \ No newline at end of file