mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Add an 'attachment' page for the PurchaseOrder view
This commit is contained in:
		
							
								
								
									
										73
									
								
								InvenTree/order/templates/order/po_attachments.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								InvenTree/order/templates/order/po_attachments.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | ||||
| {% extends "order/order_base.html" %} | ||||
|  | ||||
| {% load inventree_extras %} | ||||
| {% load i18n %} | ||||
| {% load static %} | ||||
|  | ||||
| {% block details %} | ||||
|  | ||||
| {% include 'order/tabs.html' with tab='attachments' %} | ||||
|  | ||||
| <h4>{% trans "Purchase Order Attachments" %} | ||||
|  | ||||
| <hr> | ||||
|  | ||||
| <div id='attachment-buttons'> | ||||
|     <div class='btn-group'> | ||||
|         <button type='button' class='btn btn-success' id='new-attachment'>{% trans "Add Attachment" %}</button> | ||||
|     </div> | ||||
| </div> | ||||
|  | ||||
| <table class='table table-striped table-condensed' data-toolbar='#attachment-buttons' id='attachment-table'> | ||||
|     <thead> | ||||
|         <tr> | ||||
|             <th data-field='file' data-searchable='true'>{% trans "File" %}</th> | ||||
|             <th data-field='comment' data-searchable='true'>{% trans "Comment" %}</th> | ||||
|             <th></th> | ||||
|         </tr> | ||||
|     </thead> | ||||
|     <tbody> | ||||
|         {% for attachment in order.attachments.all %} | ||||
|         <tr> | ||||
|             <td><a href='/media/{{ attachment.attachment }}'>{{ attachment.basename }}</a></td> | ||||
|             <td>{{ attachment.comment }}</td> | ||||
|             <td> | ||||
|                 <div class='btn-group' style='float: right;'>     | ||||
|                     <button type='button' class='btn btn-default btn-glyph attachment-edit-button' url="{% url 'part-attachment-edit' attachment.id %}" data-toggle='tooltip' title='{% trans "Edit attachment" %}'> | ||||
|                         <span class='glyphicon glyphicon-edit'/> | ||||
|                     </button> | ||||
|                     <button type='button' class='btn btn-default btn-glyph attachment-delete-button' url="{% url 'part-attachment-delete' attachment.id %}" data-toggle='tooltip' title='{% trans "Delete attachment" %}'> | ||||
|                         <span class='glyphicon glyphicon-trash'/> | ||||
|                     </button> | ||||
|                 </div> | ||||
|             </td> | ||||
|         </tr> | ||||
|         {% endfor %} | ||||
|     </tbody> | ||||
| </table> | ||||
|  | ||||
| {% endblock %} | ||||
|  | ||||
| {% block js_ready %} | ||||
| {{ block.super }} | ||||
|  | ||||
| $("#new-attachment").click(function() { | ||||
|      | ||||
| }); | ||||
|  | ||||
| $("#attachment-table").on('click', '.attachment-edit-button', function() { | ||||
|     var button = $(this); | ||||
|  | ||||
|     // TODO | ||||
| }); | ||||
|  | ||||
| $("#attachment-table").on('click', '.attachment-delete-button', function() { | ||||
|     var button = $(this); | ||||
|  | ||||
|     // TODO | ||||
| }); | ||||
|  | ||||
| $("#attachment-table").inventreeTable({ | ||||
| }); | ||||
|  | ||||
| {% endblock %} | ||||
| @@ -4,6 +4,9 @@ | ||||
|     <li{% ifequal tab 'details' %} class='active'{% endifequal %}> | ||||
|         <a href="{% url 'purchase-order-detail' order.id %}">{% trans "Items" %}</a> | ||||
|     </li> | ||||
|     <li{% if tab == 'attachments' %} class='active'{% endif %}> | ||||
|         <a href="{% url 'purchase-order-attachments' order.id %}">{% trans "Attachments" %}</a> | ||||
|     </li> | ||||
|     <li{% ifequal tab 'notes' %} class='active'{% endifequal %}> | ||||
|         <a href="{% url 'purchase-order-notes' order.id %}">{% trans "Notes" %}{% if order.notes %} <span class='glyphicon glyphicon-small glyphicon-info-sign'></span>{% endif %}</a> | ||||
|     </li> | ||||
|   | ||||
| @@ -21,6 +21,7 @@ purchase_order_detail_urls = [ | ||||
|  | ||||
|     url(r'^notes/', views.PurchaseOrderNotes.as_view(), name='purchase-order-notes'), | ||||
|  | ||||
|     url(r'^attachments/', views.PurchaseOrderDetail.as_view(template_name='order/po_attachments.html'), name='purchase-order-attachments'), | ||||
|     url(r'^.*$', views.PurchaseOrderDetail.as_view(), name='purchase-order-detail'), | ||||
| ] | ||||
|  | ||||
|   | ||||
| @@ -942,6 +942,9 @@ def attach_file(instance, filename): | ||||
|  | ||||
|  | ||||
| class PartAttachment(InvenTreeAttachment): | ||||
|     """ | ||||
|     Model for storing file attachments against a Part object | ||||
|     """ | ||||
|      | ||||
|     def getSubdir(self): | ||||
|         return os.path.join("part_files", str(self.part.id)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user