Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Element(TimeStampedModel):
- thumb = models.ImageField(default=None, null=True, blank=True)
- type = models.CharField(choices=TEXTURE_TYPES, max_length=50)
- texture = models.ForeignKey(
- "scenes.Texture", on_delete=models.CASCADE, related_name="elements", null=True
- )
- shade = models.ManyToManyField("scenes.Shade", help_text="Odcień")
- wood = models.ForeignKey(
- "scenes.Wood", on_delete=models.CASCADE, help_text="Rodzaj drewna"
- )
- abrasion = models.ForeignKey(
- "scenes.Abrasion",
- on_delete=models.CASCADE,
- null=True,
- help_text="Klasy ścieralności",
- )
- pattern = models.ForeignKey(
- "scenes.Pattern", help_text="Wzór", on_delete=models.CASCADE, null=True
- )
- thickness = models.CharField(
- choices=THICKNESSES,
- max_length=10,
- help_text="Grubości (dla paneli)",
- null=True,
- blank=True,
- )
- v_groove = models.BooleanField(default=False, help_text="V-Fuga")
- v_groove_color = models.CharField(
- max_length=10, null=True, blank=True, help_text="Kolor V-Fugi"
- )
- size = models.CharField(
- choices=PANEL_SIZES,
- max_length=15,
- help_text="Format (dla paneli) lub wymiar (dla płyt i blatów",
- null=True,
- blank=True,
- )
- structure = models.CharField(
- choices=STRUCTURES, max_length=5, help_text="Struktura", null=True, blank=True
- )
- light_reflection = models.CharField(
- choices=LIGHT_REFLECTIONS,
- max_length=24,
- help_text="Rodzaj materiału",
- default="shiny",
- )
- collection = models.ForeignKey(
- "scenes.Collection", null=True, on_delete=models.CASCADE, name="Kolekcja"
- )
- decor_thickness = models.ManyToManyField(
- "scenes.Thickness", help_text="Grubości (dla dekorów ściennych)"
- )
- details = models.CharField(
- max_length=512, null=True, blank=True, help_text="Szczegóły produktu"
- )
- details_url = models.URLField(null=True, blank=True, max_length=500)
- def __str__(self):
- return "{} #{}".format(self.type.capitalize(), self.pk)
- class Filters:
- # this is stupid, but because of deadline there was requirement
- # to mirror FE mock 1:1. After BETA, it should go away, or be handled more nicely
- # Probably the best solution would be to renegotiate contract with FE.
- def __init__(
- self,
- wood,
- shade,
- abrasion,
- type,
- pattern,
- thickness,
- v_groove,
- v_groove_color,
- size,
- structure,
- light_reflection,
- collection,
- decor_thickness,
- details,
- ):
- self.wood = wood
- self.shade = shade
- self.abrasion = abrasion
- self.type = type
- self.pattern = pattern
- self.thickness = thickness
- self.v_groove = v_groove
- self.v_groove_color = v_groove_color
- self.size = size
- self.structure = structure
- self.light_reflection = light_reflection
- self.collection = collection
- self.decor_thickness = decor_thickness
- self.details = details
- @property
- def filters(self):
- f = self.Filters(
- wood=self.wood.name_pl,
- shade=self.shade,
- abrasion=self.abrasion.name_pl,
- type=self.type,
- pattern=self.pattern,
- thickness=self.thickness,
- v_groove=self.v_groove,
- v_groove_color=self.v_groove_color,
- size=self.size,
- structure=self.structure,
- light_reflection=self.light_reflection,
- collection=getattr(self, "collection", None),
- decor_thickness=self.decor_thickness,
- details=self.details,
- )
- return f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement