mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	Part parameter update (#3605)
* Adds 'description' field to PartParameterTemplate model * Add 'description' field to API, update settings table * Bump API version * Allow more characters in PartParameterTemplate name
This commit is contained in:
		@@ -0,0 +1,18 @@
 | 
			
		||||
# Generated by Django 3.2.15 on 2022-08-24 12:09
 | 
			
		||||
 | 
			
		||||
from django.db import migrations, models
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ('part', '0084_partcategory_icon'),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='partparametertemplate',
 | 
			
		||||
            name='description',
 | 
			
		||||
            field=models.CharField(blank=True, help_text='Parameter description', max_length=250, verbose_name='Description'),
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
@@ -2369,7 +2369,7 @@ class PartTestTemplate(models.Model):
 | 
			
		||||
 | 
			
		||||
def validate_template_name(name):
 | 
			
		||||
    """Prevent illegal characters in "name" field for PartParameterTemplate."""
 | 
			
		||||
    for c in "!@#$%^&*()<>{}[].,?/\\|~`_+-=\'\"":  # noqa: P103
 | 
			
		||||
    for c in "\"\'`!?|":  # noqa: P103
 | 
			
		||||
        if c in str(name):
 | 
			
		||||
            raise ValidationError(_(f"Illegal character in template name ({c})"))
 | 
			
		||||
 | 
			
		||||
@@ -2424,6 +2424,13 @@ class PartParameterTemplate(models.Model):
 | 
			
		||||
 | 
			
		||||
    units = models.CharField(max_length=25, verbose_name=_('Units'), help_text=_('Parameter Units'), blank=True)
 | 
			
		||||
 | 
			
		||||
    description = models.CharField(
 | 
			
		||||
        max_length=250,
 | 
			
		||||
        verbose_name=_('Description'),
 | 
			
		||||
        help_text=_('Parameter description'),
 | 
			
		||||
        blank=True,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PartParameter(models.Model):
 | 
			
		||||
    """A PartParameter is a specific instance of a PartParameterTemplate. It assigns a particular parameter <key:value> pair to a part.
 | 
			
		||||
 
 | 
			
		||||
@@ -240,6 +240,7 @@ class PartParameterTemplateSerializer(InvenTreeModelSerializer):
 | 
			
		||||
            'pk',
 | 
			
		||||
            'name',
 | 
			
		||||
            'units',
 | 
			
		||||
            'description',
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user