mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-12 10:05:39 +00:00
Added views for part and part category
- Worked out simple linking - Category path displaying correctly - Category page lists parts in category
This commit is contained in:
@ -9,10 +9,20 @@ class PartCategory(models.Model):
|
||||
|
||||
def __str__(self):
|
||||
if self.parent:
|
||||
return str(self.parent) + "/" + self.name
|
||||
return "/".join([p.name for p in self.path]) + "/" + self.name
|
||||
else:
|
||||
return self.name
|
||||
|
||||
# Return the parent path of this category
|
||||
@property
|
||||
def path(self):
|
||||
parent_path = []
|
||||
|
||||
if self.parent:
|
||||
parent_path = self.parent.path + [self.parent]
|
||||
|
||||
return parent_path
|
||||
|
||||
class Part(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
description = models.CharField(max_length=250, blank=True)
|
||||
@ -25,4 +35,7 @@ class Part(models.Model):
|
||||
ipn = self.IPN,
|
||||
name = self.name)
|
||||
else:
|
||||
return self.name
|
||||
return self.name
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user