mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
Show project attachments in portal view
This commit is contained in:
@@ -57,10 +57,34 @@
|
||||
{% else %}
|
||||
<p class="text-muted">{{ _("No time sheets") }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% if doc.attachments %}
|
||||
<div class='padding'></div>
|
||||
|
||||
<h4>{{ _("Attachments") }}</h4>
|
||||
<div class="project-attachments">
|
||||
{% for attachment in doc.attachments %}
|
||||
<div class="attachment">
|
||||
<a class="no-decoration attachment-link" href="{{ attachment.file_url }}" target="blank">
|
||||
<div class="row">
|
||||
<div class="col-xs-9">
|
||||
<span class="indicator red file-name"> {{ attachment.file_name }}</span>
|
||||
</div>
|
||||
<div class="col-xs-3">
|
||||
<span class="pull-right file-size">{{ attachment.file_size }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
{% include "erpnext/templates/pages/projects.js" %}
|
||||
{% include "frappe/public/js/frappe/provide.js" %}
|
||||
{% include "frappe/public/js/frappe/form/formatters.js" %}
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -36,6 +36,10 @@ frappe.ready(function() {
|
||||
more_items('timeline', false);
|
||||
});
|
||||
|
||||
$(".file-size").each(function() {
|
||||
$(this).text(frappe.form.formatters.FileSize($(this).text()));
|
||||
});
|
||||
|
||||
|
||||
var reload_items = function(item_status, item, $btn) {
|
||||
$.ajax({
|
||||
|
||||
@@ -6,7 +6,7 @@ import frappe
|
||||
import json
|
||||
|
||||
def get_context(context):
|
||||
project_user = frappe.db.get_value("Project User", {"parent": frappe.form_dict.project, "user": frappe.session.user} , "user")
|
||||
project_user = frappe.db.get_value("Project User", {"parent": frappe.form_dict.project, "user": frappe.session.user} , ["user", "view_attachments"], as_dict= True)
|
||||
if not project_user or frappe.session.user == 'Guest':
|
||||
raise frappe.PermissionError
|
||||
|
||||
@@ -22,6 +22,8 @@ def get_context(context):
|
||||
project.timesheets = get_timesheets(project.name, start=0,
|
||||
search=frappe.form_dict.get("search"))
|
||||
|
||||
if project_user.view_attachments:
|
||||
project.attachments = get_attachments(project.name)
|
||||
|
||||
context.doc = project
|
||||
|
||||
@@ -92,3 +94,6 @@ def get_timesheet_html(project, start=0):
|
||||
return frappe.render_template("erpnext/templates/includes/projects/project_timesheets.html",
|
||||
{"doc": {"timesheets": get_timesheets(project, start)}}, is_path=True)
|
||||
|
||||
def get_attachments(project):
|
||||
return frappe.get_all('File', filters= {"attached_to_name": project, "attached_to_doctype": 'Project', "is_private":0},
|
||||
fields=['file_name','file_url', 'file_size'])
|
||||
|
||||
Reference in New Issue
Block a user