浏览代码

[fix] [performance] add communication in _comments in doc for listviews

version-14
Rushabh Mehta 9 年前
父节点
当前提交
9d141e11e4
共有 6 个文件被更改,包括 27 次插入10 次删除
  1. +10
    -3
      frappe/core/doctype/communication/comment.py
  2. +1
    -1
      frappe/desk/form/load.py
  3. +2
    -2
      frappe/model/delete_doc.py
  4. +2
    -1
      frappe/patches.txt
  5. +9
    -0
      frappe/patches/v7_0/add_communication_in_doc.py
  6. +3
    -3
      frappe/templates/includes/login/login.css

+ 10
- 3
frappe/core/doctype/communication/comment.py 查看文件

@@ -39,6 +39,8 @@ def update_comment_in_doc(doc):
"""Updates `_comments` (JSON) property in parent Document.
Creates a column `_comments` if property does not exist.

Only user created comments Communication or Comment of type Comment are saved.

`_comments` format

{
@@ -47,15 +49,19 @@ def update_comment_in_doc(doc):
"name": [Comment Document name]
}"""

if doc.communication_type != "Comment":
if doc.communication_type not in ("Comment", "Communication"):
return

if doc.reference_doctype and doc.reference_name and doc.content and doc.comment_type=="Comment":
if doc.communication_type == 'Comment' and doc.comment_type != 'Comment':
# other updates
return

if doc.reference_doctype and doc.reference_name and doc.content:
_comments = get_comments_from_parent(doc)
updated = False
for c in _comments:
if c.get("name")==doc.name:
c["comment"] = doc.content
c["comment"] = (doc.content[:97] + '...') if len(doc.content) > 100 else doc.content
updated = True

if not updated:
@@ -64,6 +70,7 @@ def update_comment_in_doc(doc):
"by": doc.sender or doc.owner,
"name": doc.name
})

update_comments_in_parent(doc.reference_doctype, doc.reference_name, _comments)

def notify_mentions(doc):


+ 1
- 1
frappe/desk/form/load.py 查看文件

@@ -134,7 +134,7 @@ def _get_communications(doctype, name, start=0, limit=20):

def get_communication_data(doctype, name, start=0, limit=20, after=None, fields=None,
group_by=None, as_dict=True):
'''Returns list of communicataions for a given document'''
'''Returns list of communications for a given document'''
if not fields:
fields = '''name, communication_type,
communication_medium, comment_type,


+ 2
- 2
frappe/model/delete_doc.py 查看文件

@@ -86,7 +86,7 @@ def delete_doc(doctype=None, name=None, force=0, ignore_doctypes=None, for_reloa
delete_email_subscribe(doc)

# check if links exist
if not force:
if not force and doc.doctype not in ("ToDo", "Communication", "DocShare", "Email Unsubscribe"):
check_if_doc_is_linked(doc)
check_if_doc_is_dynamically_linked(doc)

@@ -165,7 +165,7 @@ def check_if_doc_is_linked(doc, method="Delete"):
# linked to an non-cancelled doc when deleting
# or linked to a submitted doc when cancelling
frappe.throw(_("Cannot delete or cancel because {0} {1} is linked with {2} {3}")
.format(doc.doctype, doc.name, item.parenttype if item.parent else link_dt,
.format(doc.doctype, doc.name, item.parenttype if item.parent else link_dt,
item.parent or item.name), frappe.LinkExistsError)

def check_if_doc_is_dynamically_linked(doc, method="Delete"):


+ 2
- 1
frappe/patches.txt 查看文件

@@ -123,4 +123,5 @@ frappe.patches.v6_24.sync_desktop_icons
frappe.patches.v6_20x.set_allow_draft_for_print
frappe.patches.v6_20x.remove_roles_from_website_user
frappe.patches.v7_0.set_user_fullname
frappe.patches.v7_0.desktop_icons_hidden_by_admin_as_blocked
frappe.patches.v7_0.desktop_icons_hidden_by_admin_as_blocked
frappe.patches.v7_0.add_communication_in_doc

+ 9
- 0
frappe/patches/v7_0/add_communication_in_doc.py 查看文件

@@ -0,0 +1,9 @@
import frappe

from frappe.core.doctype.communication.comment import update_comment_in_doc

def execute():
for d in frappe.db.get_all("Communication",
fields = ['name', 'reference_doctype', 'reference_name', 'content', 'communication_type'],
filters = {'communication_type': 'Communication'}):
update_comment_in_doc(d)

+ 3
- 3
frappe/templates/includes/login/login.css 查看文件

@@ -8,12 +8,12 @@
}

.blue {
color: #7575ff;
color: #7575ff;
}

.icon-facebook, .icon-facebook-sign{
color: #3b5998;
}
}
.icon-google-plus, .icon-google-plus-sign{
color: #C63D2D;
}
@@ -37,7 +37,7 @@
max-width: 360px;
padding-right: 30px;
padding-left: 30px;
padding-top: 10px;
padding-top: 50px;
margin: 0 auto;
border-radius: 5px;
background-color: #fff;


正在加载...
取消
保存