Browse Source

[fix] link assignment comment to ToDo

version-14
Anand Doshi 10 years ago
parent
commit
48f7311c8f
4 changed files with 39 additions and 8 deletions
  1. +20
    -1
      frappe/core/doctype/comment/comment.json
  2. +10
    -5
      frappe/desk/doctype/todo/todo.py
  3. +2
    -1
      frappe/desk/form/load.py
  4. +7
    -1
      frappe/public/js/frappe/form/footer/timeline_item.html

+ 20
- 1
frappe/core/doctype/comment/comment.json View File

@@ -103,12 +103,31 @@
"fieldtype": "Check", "fieldtype": "Check",
"label": "Unsubscribed", "label": "Unsubscribed",
"permlevel": 0 "permlevel": 0
},
{
"fieldname": "reference_doctype",
"fieldtype": "Link",
"label": "Reference DocType",
"options": "DocType",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"description": "Reference DocType and Reference Name are used to render a comment as a link (href) to a Doc.",
"fieldname": "reference_name",
"fieldtype": "Dynamic Link",
"label": "Reference Name",
"options": "reference_doctype",
"permlevel": 0,
"precision": "",
"read_only": 1
} }
], ],
"icon": "icon-comments", "icon": "icon-comments",
"idx": 1, "idx": 1,
"issingle": 0, "issingle": 0,
"modified": "2015-02-11 15:32:45.807458",
"modified": "2015-06-08 12:31:15.122312",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Core", "module": "Core",
"name": "Comment", "name": "Comment",


+ 10
- 5
frappe/desk/doctype/todo/todo.py View File

@@ -16,8 +16,8 @@ class ToDo(Document):
if self.is_new(): if self.is_new():
self.add_assign_comment(frappe._("Assigned to {0}: {1}").format(get_fullname(self.owner), self.description), "Assigned") self.add_assign_comment(frappe._("Assigned to {0}: {1}").format(get_fullname(self.owner), self.description), "Assigned")
else: else:
cur_status = frappe.db.get_value("ToDo", self.name, "status")
if cur_status != self.status:
# NOTE the previous value is only available in validate method
if self.get_db_value("status") != self.status:
self.add_assign_comment(frappe._("Assignment closed by {0}".format(get_fullname(frappe.session.user))), self.add_assign_comment(frappe._("Assignment closed by {0}".format(get_fullname(frappe.session.user))),
"Assignment Completed") "Assignment Completed")


@@ -31,14 +31,19 @@ class ToDo(Document):
if not self.reference_type and self.reference_name: if not self.reference_type and self.reference_name:
return return


frappe.get_doc({
comment = frappe.get_doc({
"doctype":"Comment", "doctype":"Comment",
"comment_by": frappe.session.user, "comment_by": frappe.session.user,
"comment_type": comment_type, "comment_type": comment_type,
"comment_doctype": self.reference_type, "comment_doctype": self.reference_type,
"comment_docname": self.reference_name, "comment_docname": self.reference_name,
"comment": """{text}""".format(text=text)
}).insert(ignore_permissions=True)
"comment": """{text}""".format(text=text),
"reference_doctype": self.doctype,
"reference_name": self.name
})
comment.flags.ignore_permissions = True
comment.flags.ignore_links = True
comment.insert()


def update_in_reference(self): def update_in_reference(self):
if not (self.reference_type and self.reference_name): if not (self.reference_type and self.reference_name):


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

@@ -105,7 +105,8 @@ def get_attachments(dt, dn):


def get_comments(dt, dn, limit=100): def get_comments(dt, dn, limit=100):
comments = frappe.db.sql("""select name, comment, comment_by, creation, comments = frappe.db.sql("""select name, comment, comment_by, creation,
comment_type, "Comment" as doctype from `tabComment`
reference_doctype, reference_name, comment_type, "Comment" as doctype
from `tabComment`
where comment_doctype=%s and comment_docname=%s where comment_doctype=%s and comment_docname=%s
order by creation desc limit %s""" % ('%s','%s', limit), order by creation desc limit %s""" % ('%s','%s', limit),
(dt, dn), as_dict=1) (dt, dn), as_dict=1)


+ 7
- 1
frappe/public/js/frappe/form/footer/timeline_item.html View File

@@ -31,7 +31,13 @@
{% } else if(in_list(["Assignment Completed", "Assigned", "Shared", "Unshared"], data.comment_type)) { %} {% } else if(in_list(["Assignment Completed", "Assigned", "Shared", "Unshared"], data.comment_type)) { %}
<h6> <h6>
<i class="{%= data.icon %} icon-fixed-width"></i> <i class="{%= data.icon %} icon-fixed-width"></i>
{%= data.comment %}
{% if(data.reference_doctype && data.reference_name) { %}
<a href="#Form/{%= data.reference_doctype %}/{%= data.reference_name %}">
{% } %}
{%= data.comment %}
{% if(data.reference_doctype && data.reference_name) { %}
</a>
{% } %}
<span class="text-muted" style="font-weight: normal;"> <span class="text-muted" style="font-weight: normal;">
&ndash; {%= data.comment_on %}</span> &ndash; {%= data.comment_on %}</span>
</h6> </h6>


Loading…
Cancel
Save