View Attachments in portal (#8830)

* View Attachments in portal

* HTML beautify correction

* Move option to shopping cart settings

* new field in shopping cart settings for public attachments display in portal
This commit is contained in:
Charles-Henri Decultot
2017-05-19 12:34:10 +02:00
committed by Rushabh Mehta
parent 7f02714c26
commit 2de1cd3529
4 changed files with 105 additions and 2 deletions

View File

@@ -86,6 +86,24 @@
{% endif %}
{% endif %}
</div>
{% if attachments %}
<div class="order-item-table">
<div class="row order-items order-item-header text-muted">
<div class="col-sm-12 h6 text-uppercase">
{{ _("Attachments") }}
</div>
</div>
<div class="row order-items">
<div class="col-sm-12">
{% for attachment in attachments %}
<p class="small">
<a href="{{ attachment.file_url }}" target="blank"> {{ attachment.file_name }} </a>
</p>
{% endfor %}
</div>
</div>
</div>
{% endif %}
</div>
{% endblock %}

View File

@@ -5,6 +5,7 @@ from __future__ import unicode_literals
import frappe
from frappe import _
from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import show_attachments
def get_context(context):
context.no_cache = 1
@@ -13,6 +14,9 @@ def get_context(context):
if hasattr(context.doc, "set_indicator"):
context.doc.set_indicator()
if show_attachments():
context.attachments = get_attachments(frappe.form_dict.doctype, frappe.form_dict.name)
context.parents = frappe.form_dict.parents
context.payment_ref = frappe.db.get_value("Payment Request",
{"reference_name": frappe.form_dict.name}, "name")
@@ -21,3 +25,7 @@ def get_context(context):
if not frappe.has_website_permission(context.doc):
frappe.throw(_("Not Permitted"), frappe.PermissionError)
def get_attachments(dt, dn):
return frappe.get_all("File", fields=["name", "file_name", "file_url", "is_private"],
filters = {"attached_to_name": dn, "attached_to_doctype": dt, "is_private":0})