Bläddra i källkod

Merge pull request #15821 from ankush/missing_email

fix: communication missing from form timeline
version-14
mergify[bot] 3 år sedan
committed by GitHub
förälder
incheckning
e43cf12941
Ingen känd nyckel hittad för denna signaturen i databasen GPG-nyckel ID: 4AEE18F83AFDEB23
2 ändrade filer med 51 tillägg och 6 borttagningar
  1. +5
    -4
      frappe/desk/form/load.py
  2. +46
    -2
      frappe/tests/test_form_load.py

+ 5
- 4
frappe/desk/form/load.py Visa fil

@@ -42,7 +42,8 @@ def getdoc(doctype, name, user=None):

# add file list
doc.add_viewed()
get_docinfo(doc)
frappe.response["docinfo"] = get_docinfo(doc)


except Exception:
frappe.errprint(frappe.utils.get_traceback())
@@ -91,8 +92,8 @@ def get_docinfo(doc=None, doctype=None, name=None):
raise frappe.PermissionError

all_communications = _get_communications(doc.doctype, doc.name)
automated_messages = filter(lambda x: x['communication_type'] == 'Automated Message', all_communications)
communications_except_auto_messages = filter(lambda x: x['communication_type'] != 'Automated Message', all_communications)
automated_messages = [msg for msg in all_communications if msg['communication_type'] == 'Automated Message']
communications_except_auto_messages = [msg for msg in all_communications if msg['communication_type'] != 'Automated Message']

docinfo = frappe._dict(user_info = {})

@@ -118,7 +119,7 @@ def get_docinfo(doc=None, doctype=None, name=None):

update_user_info(docinfo)

frappe.response["docinfo"] = docinfo
return docinfo

def add_comments(doc, docinfo):
# divide comments into separate lists


+ 46
- 2
frappe/tests/test_form_load.py Visa fil

@@ -1,9 +1,10 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
import frappe, unittest
from frappe.desk.form.load import getdoctype, getdoc
from frappe.desk.form.load import getdoctype, getdoc, get_docinfo
from frappe.core.page.permission_manager.permission_manager import update, reset, add
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
from frappe.utils.file_manager import save_file

test_dependencies = ['Blog Category', 'Blogger']

@@ -141,9 +142,52 @@ class TestFormLoad(unittest.TestCase):

contact.delete()

def test_get_doc_info(self):
note = frappe.new_doc("Note")
note.content = "some content"
note.title = frappe.generate_hash(length=20)
note.insert()

note.content = "new content"
# trigger a version
note.save(ignore_version=False)

note.add_comment(text="test")

note.add_tag("test_tag")
note.add_tag("more_tag")

# empty attachment
save_file("test_file", b"", note.doctype, note.name, decode=True)

frappe.get_doc({
"doctype": "Communication",
"communication_type": "Communication",
"content": "test email",
"reference_doctype": note.doctype,
"reference_name": note.name,
}).insert()


docinfo = get_docinfo(note)

self.assertEqual(len(docinfo.comments), 1)
self.assertIn("test", docinfo.comments[0].content)

self.assertGreaterEqual(len(docinfo.versions), 2)

self.assertEqual(set(docinfo.tags.split(",")), {"more_tag", "test_tag"})

self.assertEqual(len(docinfo.attachments), 1)
self.assertIn("test_file", docinfo.attachments[0].file_name)

self.assertEqual(len(docinfo.communications), 1)
self.assertIn("email", docinfo.communications[0].content)
note.delete()


def get_blog(blog_name):
frappe.response.docs = []
getdoc('Blog Post', blog_name)
doc = frappe.response.docs[0]
return doc
return doc

Laddar…
Avbryt
Spara