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:
Oliver 2022-08-25 07:33:36 +10:00 committed by GitHub
parent 6adfc91c5c
commit e8621a97bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 5 deletions

View File

@ -2,11 +2,14 @@
# InvenTree API version
INVENTREE_API_VERSION = 72
INVENTREE_API_VERSION = 73
"""
Increment this API version number whenever there is a significant change to the API that any clients need to know about
v73 -> 2022-08-24 : https://github.com/inventree/InvenTree/pull/3605
- Add 'description' field to PartParameterTemplate model
v72 -> 2022-08-18 : https://github.com/inventree/InvenTree/pull/3567
- Allow PurchaseOrder to be duplicated via the API

View File

@ -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'),
),
]

View File

@ -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.

View File

@ -240,6 +240,7 @@ class PartParameterTemplateSerializer(InvenTreeModelSerializer):
'pk',
'name',
'units',
'description',
]

View File

@ -345,16 +345,23 @@ $("#param-table").inventreeTable({
{
field: 'name',
title: '{% trans "Name" %}',
sortable: 'true',
sortable: true,
},
{
field: 'units',
title: '{% trans "Units" %}',
sortable: 'true',
sortable: true,
switchable: true,
},
{
field: 'description',
title: '{% trans "Description" %}',
sortable: false,
switchable: true,
},
{
formatter: function(value, row, index, field) {
var bEdit = "<button title='{% trans "Edit Template" %}' class='template-edit btn btn-outline-secondary' type='button' pk='" + row.pk + "'><span class='fas fa-edit'></span></button>";
var bEdit = "<button title='{% trans "Edit Template" %}' class='template-edit btn btn-outline-secondary' type='button' pk='" + row.pk + "'><span class='fas fa-edit icon-green'></span></button>";
var bDel = "<button title='{% trans "Delete Template" %}' class='template-delete btn btn-outline-secondary' type='button' pk='" + row.pk + "'><span class='fas fa-trash-alt icon-red'></span></button>";
var html = "<div class='btn-group float-right' role='group'>" + bEdit + bDel + "</div>";
@ -370,6 +377,7 @@ $("#new-param").click(function() {
fields: {
name: {},
units: {},
description: {},
},
method: 'POST',
title: '{% trans "Create Part Parameter Template" %}',
@ -389,6 +397,7 @@ $("#param-table").on('click', '.template-edit', function() {
fields: {
name: {},
units: {},
description: {},
},
title: '{% trans "Edit Part Parameter Template" %}',
onSuccess: function() {