Add "upload date" field to fileattachment base class

This commit is contained in:
Oliver Walters 2020-05-12 20:57:41 +10:00
parent d4fa7d936e
commit 5d716d0cdd
5 changed files with 66 additions and 2 deletions

View File

@ -42,6 +42,8 @@ class InvenTreeAttachment(models.Model):
Attributes:
attachment: File
comment: String descriptor for the attachment
user: User associated with file upload
upload_date: Date the file was uploaded
"""
def getSubdir(self):
"""
@ -63,6 +65,8 @@ class InvenTreeAttachment(models.Model):
help_text=_('User'),
)
upload_date = models.DateField(auto_now_add=True, null=True, blank=True)
@property
def basename(self):
return os.path.basename(self.attachment.name)

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.5 on 2020-05-12 10:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('order', '0033_auto_20200512_1033'),
]
operations = [
migrations.AddField(
model_name='purchaseorderattachment',
name='upload_date',
field=models.DateField(auto_now_add=True, null=True),
),
migrations.AddField(
model_name='salesorderattachment',
name='upload_date',
field=models.DateField(auto_now_add=True, null=True),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.0.5 on 2020-05-12 10:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('part', '0036_partattachment_user'),
]
operations = [
migrations.AddField(
model_name='partattachment',
name='upload_date',
field=models.DateField(auto_now_add=True, null=True),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.0.5 on 2020-05-12 10:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('stock', '0037_stockitemattachment_user'),
]
operations = [
migrations.AddField(
model_name='stockitemattachment',
name='upload_date',
field=models.DateField(auto_now_add=True, null=True),
),
]

View File

@ -22,7 +22,7 @@
<tr>
<th data-field='file' data-searchable='true'>{% trans "File" %}</th>
<th data-field='comment' data-searchable='true'>{% trans "Comment" %}</th>
<th data-field='user' data-searchable='true'>{% trans "Uploaded By" %}</th>
<th data-field='user' data-searchable='true'>{% trans "Uploaded" %}</th>
<th></th>
</tr>
</thead>
@ -32,7 +32,8 @@
<td><a href='/media/{{ attachment.attachment }}'>{{ attachment.basename }}</a></td>
<td>{{ attachment.comment }}</td>
<td>
{% if attachment.user %}{{ attachment.user.username }}{% else %}-{% endif %}
{% 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;'>