Browse Source

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

version-14
Rushabh Mehta 9 years ago
parent
commit
9d141e11e4
6 changed files with 27 additions and 10 deletions
  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 View File

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


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

`_comments` format `_comments` format


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


if doc.communication_type != "Comment":
if doc.communication_type not in ("Comment", "Communication"):
return 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) _comments = get_comments_from_parent(doc)
updated = False updated = False
for c in _comments: for c in _comments:
if c.get("name")==doc.name: 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 updated = True


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

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


def notify_mentions(doc): def notify_mentions(doc):


+ 1
- 1
frappe/desk/form/load.py View File

@@ -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, def get_communication_data(doctype, name, start=0, limit=20, after=None, fields=None,
group_by=None, as_dict=True): 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: if not fields:
fields = '''name, communication_type, fields = '''name, communication_type,
communication_medium, comment_type, communication_medium, comment_type,


+ 2
- 2
frappe/model/delete_doc.py View File

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


# check if links exist # 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_linked(doc)
check_if_doc_is_dynamically_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 # linked to an non-cancelled doc when deleting
# or linked to a submitted doc when cancelling # or linked to a submitted doc when cancelling
frappe.throw(_("Cannot delete or cancel because {0} {1} is linked with {2} {3}") 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) item.parent or item.name), frappe.LinkExistsError)


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


+ 2
- 1
frappe/patches.txt View File

@@ -123,4 +123,5 @@ frappe.patches.v6_24.sync_desktop_icons
frappe.patches.v6_20x.set_allow_draft_for_print frappe.patches.v6_20x.set_allow_draft_for_print
frappe.patches.v6_20x.remove_roles_from_website_user frappe.patches.v6_20x.remove_roles_from_website_user
frappe.patches.v7_0.set_user_fullname 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 View File

@@ -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 View File

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


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


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


Loading…
Cancel
Save