Add PartParameter table

This commit is contained in:
Oliver Walters 2019-08-20 12:31:43 +10:00
parent 3447123196
commit 2f6357b136
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,23 @@
# Generated by Django 2.2.4 on 2019-08-20 02:30
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('part', '0013_auto_20190628_0951'),
]
operations = [
migrations.CreateModel(
name='PartParameter',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Parameter Name', max_length=100)),
('data', models.CharField(help_text='Parameter Value', max_length=100)),
('part', models.ForeignKey(help_text='Parent Part', on_delete=django.db.models.deletion.CASCADE, related_name='parameters', to='part.Part')),
],
),
]

View File

@ -1028,6 +1028,28 @@ class PartStar(models.Model):
unique_together = ['part', 'user']
class PartParameter(models.Model):
""" A PartParameter provides key:value pairs for extra
parameters fields/values to be added to a Part.
This allows users to arbitrarily assign data fields to a Part
beyond the built-in attributes.
Attributes:
part: Link to a Part object
name: The name (key) of the Parameter [string]
data: The data (value) of the Parameter [string]
"""
part = models.ForeignKey(Part, on_delete=models.CASCADE,
related_name='parameters',
help_text='Parent Part',
)
name = models.CharField(max_length=100, help_text='Parameter Name')
data = models.CharField(max_length=100, help_text='Parameter Value')
class BomItem(models.Model):
""" A BomItem links a part to its component items.
A part can have a BOM (bill of materials) which defines