2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-13 08:21:26 +00:00

Merge pull request #133 from SchrodingersGat/part-files

Part files
This commit is contained in:
Oliver
2019-04-18 00:23:09 +10:00
committed by GitHub
3 changed files with 20 additions and 9 deletions

View File

@ -310,15 +310,8 @@ class Part(models.Model):
def attach_file(instance, filename):
base = 'part_files'
# TODO - For a new PartAttachment object, PK is NULL!!
# Prefix the attachment ID to the filename
fn = "{id}_{fn}".format(id=instance.pk, fn=filename)
return os.path.join(base, fn)
# Construct a path to store a file attachment
return os.path.join('part_files', str(instance.part.id), filename)
class PartAttachment(models.Model):
@ -331,6 +324,10 @@ class PartAttachment(models.Model):
attachment = models.FileField(upload_to=attach_file, null=True, blank=True)
@property
def basename(self):
return os.path.basename(self.attachment.name)
class BomItem(models.Model):
""" A BomItem links a part to its component items.