mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Put function into migration file
This commit is contained in:
parent
d217fa4d9f
commit
9614963f16
@ -1,13 +1,29 @@
|
||||
# Generated by Django 2.2 on 2019-05-20 12:04
|
||||
|
||||
import InvenTree.validators
|
||||
from django.conf import settings
|
||||
import django.core.validators
|
||||
import os
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
import django.core.validators
|
||||
|
||||
import InvenTree.validators
|
||||
import part.models
|
||||
|
||||
|
||||
def attach_file(instance, filename):
|
||||
"""
|
||||
Generate a filename for the uploaded attachment.
|
||||
|
||||
2021-11-17 - This was moved here from part.models.py,
|
||||
as the function itself is no longer used,
|
||||
but is still required for migration
|
||||
"""
|
||||
|
||||
# Construct a path to store a file attachment
|
||||
return os.path.join('part_files', str(instance.part.id), filename)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
@ -61,7 +77,7 @@ class Migration(migrations.Migration):
|
||||
name='PartAttachment',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('attachment', models.FileField(help_text='Select file to attach', upload_to=part.models.attach_file)),
|
||||
('attachment', models.FileField(help_text='Select file to attach', upload_to=attach_file)),
|
||||
('comment', models.CharField(help_text='File comment', max_length=100)),
|
||||
],
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user