diff --git a/frappe/core/doctype/communication/communication.py b/frappe/core/doctype/communication/communication.py index e05fa5e285..ea7e6df21e 100644 --- a/frappe/core/doctype/communication/communication.py +++ b/frappe/core/doctype/communication/communication.py @@ -44,6 +44,7 @@ class Communication(Document): def send(self, send_me_a_copy=False, print_html=None, print_format=None, attachments=None): if print_format: + print self.get_attach_link(print_format) self.content += self.get_attach_link(print_format) mail = get_email(self.recipients, sender=self.sender, subject=self.subject, @@ -73,7 +74,8 @@ class Communication(Document): "url": get_url(), "doctype": self.reference_doctype, "name": self.reference_name, - "print_format": print_format + "print_format": print_format, + "key": self.get_parent_doc().get_signature() }) def on_doctype_update(): @@ -126,20 +128,3 @@ def attach_print(mail, parent_doc, print_html, print_format): print_html = scrub_urls(print_html) mail.add_attachment(name.replace(' ','').replace('/','-') + '.html', print_html, 'text/html') - -def set_portal_link(sent_via, comm): - """set portal link in footer""" - - footer = "" - - if is_signup_enabled() and hasattr(sent_via, "get_portal_page"): - portal_page = sent_via.get_portal_page() - if portal_page: - is_valid_recipient = cstr(sent_via.get("email") or sent_via.get("email_id") or - sent_via.get("contact_email")) in comm.recipients - if is_valid_recipient: - url = "%s/%s?name=%s" % (get_url(), portal_page, urllib.quote(sent_via.name)) - footer = """ -
""" % url - - return footer diff --git a/frappe/desk/doctype/todo/todo.py b/frappe/desk/doctype/todo/todo.py index f2a8087b39..13320d9549 100644 --- a/frappe/desk/doctype/todo/todo.py +++ b/frappe/desk/doctype/todo/todo.py @@ -10,11 +10,11 @@ from frappe.model.document import Document class ToDo(Document): def validate(self): if self.is_new(): - self.add_comment(frappe._("Assigned to {0}").format(self.owner), "Assigned") + self.add_assign_comment(frappe._("Assigned to {0}").format(self.owner), "Assigned") else: cur_status = frappe.db.get_value("ToDo", self.name, "status") if cur_status != self.status: - self.add_comment(frappe._("Assignment Status Changed"), "Assignment Completed") + self.add_assign_comment(frappe._("Assignment Status Changed"), "Assignment Completed") def on_update(self): self.update_in_reference() @@ -22,7 +22,7 @@ class ToDo(Document): def on_trash(self): self.update_in_reference() - def add_comment(self, text, comment_type): + def add_assign_comment(self, text, comment_type): if not self.reference_type and self.reference_name: return diff --git a/frappe/model/document.py b/frappe/model/document.py index 814f435720..742667f725 100644 --- a/frappe/model/document.py +++ b/frappe/model/document.py @@ -9,6 +9,7 @@ from frappe.modules import load_doctype_module from frappe.model.base_document import BaseDocument from frappe.model.naming import set_new_name from werkzeug.exceptions import NotFound, Forbidden +import hashlib # once_only validation # methods @@ -590,3 +591,6 @@ class Document(BaseDocument): "comment": text or comment_type }).insert(ignore_permissions=True) return comment + + def get_signature(self): + return hashlib.sha224(self.creation).hexdigest() diff --git a/frappe/templates/emails/print_link.html b/frappe/templates/emails/print_link.html index f97b36593b..4e69190fa3 100644 --- a/frappe/templates/emails/print_link.html +++ b/frappe/templates/emails/print_link.html @@ -1,3 +1,3 @@- {{ _("View this in your browser") }} + {{ _("View this in your browser") }}
diff --git a/frappe/templates/pages/print.py b/frappe/templates/pages/print.py index 0c76ec9c4e..1dc45b114c 100644 --- a/frappe/templates/pages/print.py +++ b/frappe/templates/pages/print.py @@ -95,6 +95,10 @@ def download_pdf(doctype, name, format=None): frappe.local.response.type = "download" def validate_print_permission(doc): + if frappe.form_dict.get("key"): + if frappe.form_dict.key == doc.get_signature(): + return + for ptype in ("read", "print"): if not frappe.has_permission(doc.doctype, ptype, doc): raise frappe.PermissionError(_("No {0} permission").format(ptype)) diff --git a/frappe/utils/file_manager.py b/frappe/utils/file_manager.py index 2fbbb5ab4d..9eff6368a0 100644 --- a/frappe/utils/file_manager.py +++ b/frappe/utils/file_manager.py @@ -39,6 +39,8 @@ def upload(): comment = frappe.get_doc(dt, dn).add_comment("Attachment", _("Added {0}").format("{file_name}".format(**filedata.as_dict()))) + print dt, dn, comment + return { "name": filedata.name, "file_name": filedata.file_name,