mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #12 from SchrodingersGat/master
Updated part parameter
This commit is contained in:
commit
fd30d11eee
@ -1,6 +1,6 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import PartCategory, Part, PartParameter, PartParameterTemplate
|
||||
from .models import PartCategory, Part, PartParameter, PartParameterTemplate, CategoryParameterLink
|
||||
|
||||
|
||||
class PartAdmin(admin.ModelAdmin):
|
||||
@ -14,7 +14,7 @@ class PartCategoryAdmin(admin.ModelAdmin):
|
||||
|
||||
|
||||
class ParameterTemplateAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'units', 'category')
|
||||
list_display = ('name', 'units', 'format')
|
||||
|
||||
|
||||
class ParameterAdmin(admin.ModelAdmin):
|
||||
@ -26,3 +26,4 @@ admin.site.register(PartCategory, PartCategoryAdmin)
|
||||
|
||||
admin.site.register(PartParameter, ParameterAdmin)
|
||||
admin.site.register(PartParameterTemplate, ParameterTemplateAdmin)
|
||||
admin.site.register(CategoryParameterLink)
|
||||
|
@ -82,9 +82,6 @@ class PartParameterTemplate(models.Model):
|
||||
ready to be copied for use with a given Part.
|
||||
A PartParameterTemplate can be optionally associated with a PartCategory
|
||||
"""
|
||||
|
||||
category = models.ForeignKey(PartCategory, on_delete=models.CASCADE, blank=True, null=True)
|
||||
|
||||
name = models.CharField(max_length=20)
|
||||
description = models.CharField(max_length=100, blank=True)
|
||||
units = models.CharField(max_length=10, blank=True)
|
||||
@ -93,6 +90,18 @@ class PartParameterTemplate(models.Model):
|
||||
default_min = models.CharField(max_length=50, blank=True)
|
||||
default_max = models.CharField(max_length=50, blank=True)
|
||||
|
||||
# Parameter format
|
||||
PARAM_NUMERIC = 10
|
||||
PARAM_TEXT = 20
|
||||
PARAM_BOOL = 30
|
||||
|
||||
format = models.IntegerField(
|
||||
default=PARAM_NUMERIC,
|
||||
choices=[
|
||||
(PARAM_NUMERIC, "Numeric"),
|
||||
(PARAM_TEXT, "Text"),
|
||||
(PARAM_BOOL, "Boolean")])
|
||||
|
||||
def __str__(self):
|
||||
return "{name} ({units})".format(
|
||||
name=self.name,
|
||||
@ -101,7 +110,23 @@ class PartParameterTemplate(models.Model):
|
||||
class Meta:
|
||||
verbose_name = "Parameter Template"
|
||||
verbose_name_plural = "Parameter Templates"
|
||||
|
||||
|
||||
class CategoryParameterLink(models.Model):
|
||||
""" Links a PartParameterTemplate to a PartCategory
|
||||
"""
|
||||
category = models.ForeignKey(PartCategory, on_delete=models.CASCADE)
|
||||
template = models.ForeignKey(PartParameterTemplate, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return "{name} - {cat}".format(
|
||||
name=self.template.name,
|
||||
cat=self.category)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Category Parameter"
|
||||
verbose_name_plural = "Category Parameters"
|
||||
|
||||
|
||||
class PartParameter(models.Model):
|
||||
""" PartParameter is associated with a single part
|
||||
|
Loading…
Reference in New Issue
Block a user