Drag and drop for order attachments

This commit is contained in:
Oliver Walters 2020-05-13 11:28:45 +10:00
parent 7143c32fc9
commit 30b5f7d507
6 changed files with 95 additions and 2 deletions

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.5 on 2020-05-13 00:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('order', '0034_auto_20200512_1054'),
]
operations = [
migrations.AlterField(
model_name='purchaseorderattachment',
name='comment',
field=models.CharField(blank=True, help_text='File comment', max_length=100),
),
migrations.AlterField(
model_name='salesorderattachment',
name='comment',
field=models.CharField(blank=True, help_text='File comment', max_length=100),
),
]

View File

@ -20,6 +20,20 @@
{% block js_ready %}
{{ block.super }}
enableDragAndDrop(
'#attachment-dropzone',
"{% url 'po-attachment-create' %}",
{
data: {
order: {{ order.id }},
},
label: 'attachment',
success: function(data, status, xhr) {
location.reload();
}
}
);
$("#new-attachment").click(function() {
launchModalForm("{% url 'po-attachment-create' %}?order={{ order.id }}",
{

View File

@ -19,6 +19,20 @@
{% block js_ready %}
{{ block.super }}
enableDragAndDrop(
'#attachment-dropzone',
"{% url 'so-attachment-create' %}",
{
data: {
order: {{ order.id }},
},
label: 'attachment',
success: function(data, status, xhr) {
location.reload();
}
}
);
$("#new-attachment").click(function() {
launchModalForm("{% url 'so-attachment-create' %}?order={{ order.id }}",
{

View File

@ -112,7 +112,10 @@ class PurchaseOrderAttachmentCreate(AjaxCreateView):
initials = super(AjaxCreateView, self).get_initial()
initials["order"] = PurchaseOrder.objects.get(id=self.request.GET.get('order', -1))
try:
initials["order"] = PurchaseOrder.objects.get(id=self.request.GET.get('order', -1))
except (ValueError, PurchaseOrder.DoesNotExist):
pass
return initials
@ -149,7 +152,10 @@ class SalesOrderAttachmentCreate(AjaxCreateView):
def get_initial(self):
initials = super().get_initial().copy()
initials['order'] = SalesOrder.objects.get(id=self.request.GET.get('order', None))
try:
initials['order'] = SalesOrder.objects.get(id=self.request.GET.get('order', None))
except (ValueError, SalesOrder.DoesNotExist):
pass
return initials

View File

@ -0,0 +1,18 @@
# Generated by Django 3.0.5 on 2020-05-13 00:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('part', '0037_partattachment_upload_date'),
]
operations = [
migrations.AlterField(
model_name='partattachment',
name='comment',
field=models.CharField(blank=True, help_text='File comment', max_length=100),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.0.5 on 2020-05-13 00:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('stock', '0038_stockitemattachment_upload_date'),
]
operations = [
migrations.AlterField(
model_name='stockitemattachment',
name='comment',
field=models.CharField(blank=True, help_text='File comment', max_length=100),
),
]