Merge branch 'develop' into data-options

This commit is contained in:
Suraj Shetty 2020-03-30 13:06:41 +05:30 committed by GitHub
commit ba6a73bd34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 23 deletions

View file

@ -56,18 +56,20 @@ def validate_link():
frappe.response['valid_value'] = valid_value
frappe.response['message'] = 'Ok'
@frappe.whitelist()
def add_comment(reference_doctype, reference_name, content, comment_email):
def add_comment(reference_doctype, reference_name, content, comment_email, comment_by):
"""allow any logged user to post a comment"""
doc = frappe.get_doc(dict(
doctype = 'Comment',
reference_doctype = reference_doctype,
reference_name = reference_name,
comment_email = comment_email,
comment_type = 'Comment'
doctype='Comment',
reference_doctype=reference_doctype,
reference_name=reference_name,
comment_email=comment_email,
comment_type='Comment',
comment_by=comment_by
))
doc.content = extract_images_from_html(doc, content)
doc.insert(ignore_permissions = True)
doc.insert(ignore_permissions=True)
follow_document(doc.reference_doctype, doc.reference_name, frappe.session.user)
return doc.as_dict()

View file

@ -68,7 +68,7 @@ def load_doctype_from_file(doctype):
class Meta(Document):
_metaclass = True
default_fields = list(default_fields)[1:]
special_doctypes = ("DocField", "DocPerm", "Role", "DocType", "Module Def")
special_doctypes = ("DocField", "DocPerm", "Role", "DocType", "Module Def", 'DocType Action', 'DocType Link')
def __init__(self, doctype):
self._fields = {}
@ -168,7 +168,8 @@ class Meta(Document):
def get_valid_columns(self):
if not hasattr(self, "_valid_columns"):
if self.name in ("DocType", "DocField", "DocPerm", 'DocType Action', 'DocType Link'):
table_exists = frappe.db.table_exists(self.name)
if self.name in self.special_doctypes and table_exists:
self._valid_columns = get_table_columns(self.name)
else:
self._valid_columns = self.default_fields + \

View file

@ -703,7 +703,8 @@ frappe.ui.form.Timeline = class Timeline {
reference_doctype: this.frm.doctype,
reference_name: this.frm.docname,
content: comment,
comment_email: frappe.session.user
comment_email: frappe.session.user,
comment_by: frappe.session.user_fullname
},
btn: btn,
callback: function(r) {

View file

@ -3,11 +3,15 @@
from __future__ import unicode_literals
import functools
import frappe, re, os
import re
import os
import frappe
from six import iteritems
from past.builtins import cmp
from frappe.utils import markdown
def delete_page_cache(path):
cache = frappe.cache()
cache.delete_value('full_index')
@ -20,7 +24,7 @@ def delete_page_cache(path):
cache.delete_key(name)
def find_first_image(html):
m = re.finditer("""<img[^>]*src\s?=\s?['"]([^'"]*)['"]""", html)
m = re.finditer(r"""<img[^>]*src\s?=\s?['"]([^'"]*)['"]""", html)
try:
return next(m).groups()[0]
except StopIteration:
@ -33,16 +37,34 @@ def can_cache(no_cache=False):
return False
return not no_cache
def get_comment_list(doctype, name):
return frappe.get_all('Comment',
fields = ['name', 'creation', 'owner', 'comment_email', 'comment_by', 'content'],
filters = dict(
reference_doctype = doctype,
reference_name = name,
comment_type = 'Comment',
published = 1
),
order_by = 'creation asc')
comments = frappe.get_all('Comment',
fields=['name', 'creation', 'owner',
'comment_email', 'comment_by', 'content'],
filters=dict(
reference_doctype=doctype,
reference_name=name,
comment_type='Comment',
),
or_filters=[
['owner', '=', frappe.session.user],
['published', '=', 1]])
communications = frappe.get_all("Communication",
fields=['name', 'creation', 'owner', 'owner as comment_email',
'sender_full_name as comment_by', 'content', 'recipients'],
filters=dict(
reference_doctype=doctype,
reference_name=name,
),
or_filters=[
['recipients', 'like', '%{0}%'.format(frappe.session.user)],
['cc', 'like', '%{0}%'.format(frappe.session.user)],
['bcc', 'like', '%{0}%'.format(frappe.session.user)]])
return sorted((comments + communications), key=lambda comment: comment['creation'], reverse=True)
def get_home_page():
if frappe.local.flags.home_page:
@ -92,7 +114,7 @@ def cleanup_page_name(title):
return ''
name = title.lower()
name = re.sub('[~!@#$%^&*+()<>,."\'\?]', '', name)
name = re.sub(r'[~!@#$%^&*+()<>,."\'\?]', '', name)
name = re.sub('[:/]', '-', name)
name = '-'.join(name.split())
@ -194,7 +216,6 @@ def abs_url(path):
def get_toc(route, url_prefix=None, app=None):
'''Insert full index (table of contents) for {index} tag'''
from frappe.website.utils import get_full_index
full_index = get_full_index(app=app)