mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 20:45:44 +00:00
Add new attechment functionality to new models
- Giving the ol' refactor tractor a fresh coat of paint
This commit is contained in:
@ -12,6 +12,7 @@ from rest_framework import filters
|
||||
from django.conf.urls import url, include
|
||||
|
||||
from InvenTree.helpers import str2bool
|
||||
from InvenTree.api import AttachmentMixin
|
||||
|
||||
from part.models import Part
|
||||
from company.models import SupplierPart
|
||||
@ -200,7 +201,7 @@ class POLineItemDetail(generics.RetrieveUpdateAPIView):
|
||||
]
|
||||
|
||||
|
||||
class SOAttachmentList(generics.ListCreateAPIView):
|
||||
class SOAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
|
||||
"""
|
||||
API endpoint for listing (and creating) a SalesOrderAttachment (file upload)
|
||||
"""
|
||||
@ -208,12 +209,6 @@ class SOAttachmentList(generics.ListCreateAPIView):
|
||||
queryset = SalesOrderAttachment.objects.all()
|
||||
serializer_class = SOAttachmentSerializer
|
||||
|
||||
filter_backends = [
|
||||
DjangoFilterBackend,
|
||||
filters.OrderingFilter,
|
||||
filters.SearchFilter,
|
||||
]
|
||||
|
||||
filter_fields = [
|
||||
'order',
|
||||
]
|
||||
@ -399,7 +394,7 @@ class SOLineItemDetail(generics.RetrieveUpdateAPIView):
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
|
||||
|
||||
class POAttachmentList(generics.ListCreateAPIView):
|
||||
class POAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
|
||||
"""
|
||||
API endpoint for listing (and creating) a PurchaseOrderAttachment (file upload)
|
||||
"""
|
||||
@ -407,12 +402,6 @@ class POAttachmentList(generics.ListCreateAPIView):
|
||||
queryset = PurchaseOrderAttachment.objects.all()
|
||||
serializer_class = POAttachmentSerializer
|
||||
|
||||
filter_backends = [
|
||||
DjangoFilterBackend,
|
||||
filters.OrderingFilter,
|
||||
filters.SearchFilter,
|
||||
]
|
||||
|
||||
filter_fields = [
|
||||
'order',
|
||||
]
|
||||
|
@ -21,8 +21,9 @@
|
||||
<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 data-field='file' data-sortable='true' data-searchable='true'>{% trans "File" %}</th>
|
||||
<th data-field='comment' data-sortable='true' data-searchable='true'>{% trans "Comment" %}</th>
|
||||
<th data-field='user' data-sortable='true' data-searchable='true'>{% trans "Uploaded" %}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -31,6 +32,10 @@
|
||||
<tr>
|
||||
<td><a href='/media/{{ attachment.attachment }}'>{{ attachment.basename }}</a></td>
|
||||
<td>{{ attachment.comment }}</td>
|
||||
<td>
|
||||
{% if attachment.upload_date %}{{ attachment.upload_date }}{% endif %}
|
||||
{% if attachment.user %}<span class='badge'>{{ attachment.user.username }}</div>{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<div class='btn-group' style='float: right;'>
|
||||
<button type='button' class='btn btn-default btn-glyph attachment-edit-button' url="{% url 'po-attachment-edit' attachment.id %}" data-toggle='tooltip' title='{% trans "Edit attachment" %}'>
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
{% include 'order/so_tabs.html' with tab='attachments' %}
|
||||
|
||||
<h4>{% trans "Sales Order Attachments" %}
|
||||
<h4>{% trans "Sales Order Attachments" %}</h4>
|
||||
|
||||
<hr>
|
||||
|
||||
@ -21,8 +21,9 @@
|
||||
<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 data-field='file' data-sortable='true' data-searchable='true'>{% trans "File" %}</th>
|
||||
<th data-field='comment' data-sortable='true' data-searchable='true'>{% trans "Comment" %}</th>
|
||||
<th data-field='user' data-sortable='true' data-sortable='true' data-searchable='true'>{% trans "Uploaded" %}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -31,6 +32,10 @@
|
||||
<tr>
|
||||
<td><a href='/media/{{ attachment.attachment }}'>{{ attachment.basename }}</a></td>
|
||||
<td>{{ attachment.comment }}</td>
|
||||
<td>
|
||||
{% if attachment.upload_date %}{{ attachment.upload_date }}{% endif %}
|
||||
{% if attachment.user %}<span class='badge'>{{ attachment.user.username }}</div>{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<div class='btn-group' style='float: right;'>
|
||||
<button type='button' class='btn btn-default btn-glyph attachment-edit-button' url="{% url 'so-attachment-edit' attachment.id %}" data-toggle='tooltip' title='{% trans "Edit attachment" %}'>
|
||||
|
@ -93,6 +93,10 @@ class PurchaseOrderAttachmentCreate(AjaxCreateView):
|
||||
ajax_form_title = _("Add Purchase Order Attachment")
|
||||
ajax_template_name = "modal_form.html"
|
||||
|
||||
def post_save(self, **kwargs):
|
||||
self.object.user = self.request.user
|
||||
self.object.save()
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
"success": _("Added attachment")
|
||||
@ -133,6 +137,10 @@ class SalesOrderAttachmentCreate(AjaxCreateView):
|
||||
form_class = order_forms.EditSalesOrderAttachmentForm
|
||||
ajax_form_title = _('Add Sales Order Attachment')
|
||||
|
||||
def post_save(self, **kwargs):
|
||||
self.object.user = self.request.user
|
||||
self.object.save()
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
'success': _('Added attachment')
|
||||
|
Reference in New Issue
Block a user