move deprecation from product to sketches, add option names for sketches
parent
eea3d117bc
commit
f0cf85f3fa
|
|
@ -23,30 +23,6 @@ class Product(PartModel):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name + " (" + self.brand.name + ")"
|
return self.name + " (" + self.brand.name + ")"
|
||||||
|
|
||||||
|
|
||||||
class Sketch(PartModel):
|
|
||||||
class Meta:
|
|
||||||
verbose_name_plural = "sketches"
|
|
||||||
|
|
||||||
name = models.CharField(max_length=256)
|
|
||||||
brand = models.ForeignKey(Brand, blank=True, null=True, on_delete=models.CASCADE, db_index=True)
|
|
||||||
product = models.ForeignKey(Product, blank=True, null=True, on_delete=models.CASCADE)
|
|
||||||
image = models.FileField(upload_to="sketches/", blank=True, null=True)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return "Sketch: " + self.name + " (" + str(self.product) + ")"
|
|
||||||
|
|
||||||
def get_product(self):
|
|
||||||
if self.product:
|
|
||||||
return [self.product] + list(self.usage_set.values('productusage__product').distinct())
|
|
||||||
return self.usage_set.values('productusage__product').distinct()
|
|
||||||
|
|
||||||
def get_brand(self):
|
|
||||||
if self.brand:
|
|
||||||
return [self.brand] + list(self.usage_set.values('productusage__product__brand').distinct())
|
|
||||||
return self.usage_set.values('productusage__product__brand').distinct()
|
|
||||||
|
|
||||||
|
|
||||||
class Version(PartModel):
|
class Version(PartModel):
|
||||||
product = models.ForeignKey(Product, on_delete=models.CASCADE)
|
product = models.ForeignKey(Product, on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=256)
|
name = models.CharField(max_length=256)
|
||||||
|
|
@ -54,9 +30,6 @@ class Version(PartModel):
|
||||||
start = models.DateField(blank=True, null=True)
|
start = models.DateField(blank=True, null=True)
|
||||||
end = models.DateField(blank=True, null=True)
|
end = models.DateField(blank=True, null=True)
|
||||||
|
|
||||||
additional_sketch = models.ManyToManyField(Sketch, blank=True, related_name='added')
|
|
||||||
unused_sketch = models.ManyToManyField(Sketch, blank=True, related_name='replaced')
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Version: " + self.name + " (" + str(self.product) + ")"
|
return "Version: " + self.name + " (" + str(self.product) + ")"
|
||||||
|
|
||||||
|
|
@ -78,6 +51,33 @@ class Version(PartModel):
|
||||||
other.delete()
|
other.delete()
|
||||||
|
|
||||||
|
|
||||||
|
class Sketch(PartModel):
|
||||||
|
class Meta:
|
||||||
|
verbose_name_plural = "sketches"
|
||||||
|
|
||||||
|
name = models.CharField(max_length=256)
|
||||||
|
brand = models.ForeignKey(Brand, blank=True, null=True, on_delete=models.CASCADE, db_index=True)
|
||||||
|
product = models.ForeignKey(Product, blank=True, null=True, on_delete=models.CASCADE)
|
||||||
|
image = models.FileField(upload_to="sketches/", blank=True, null=True)
|
||||||
|
used_until = models.ForeignKey(Version, null=True, blank=True, related_name='dismisses_sketch', on_delete=models.SET_NULL)
|
||||||
|
used_since = models.ForeignKey(Version, null=True, blank=True, related_name='introduces_sketch', on_delete=models.SET_NULL)
|
||||||
|
option = models.CharField(max_length=1024, null=True, blank=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "Sketch: " + self.name + " (" + str(self.product) + ")"
|
||||||
|
|
||||||
|
def get_product(self):
|
||||||
|
if self.product:
|
||||||
|
return [self.product] + list(self.usage_set.values('productusage__product').distinct())
|
||||||
|
return self.usage_set.values('productusage__product').distinct()
|
||||||
|
|
||||||
|
def get_brand(self):
|
||||||
|
if self.brand:
|
||||||
|
return [self.brand] + list(self.usage_set.values('productusage__product__brand').distinct())
|
||||||
|
return self.usage_set.values('productusage__product__brand').distinct()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Part(PartModel):
|
class Part(PartModel):
|
||||||
name = models.CharField(max_length=256, db_index=True)
|
name = models.CharField(max_length=256, db_index=True)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue