SHARE
TWEET

Untitled

a guest Dec 9th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Element(TimeStampedModel):
  2.     thumb = models.ImageField(default=None, null=True, blank=True)
  3.     type = models.CharField(choices=TEXTURE_TYPES, max_length=50)
  4.     texture = models.ForeignKey(
  5.         "scenes.Texture", on_delete=models.CASCADE, related_name="elements", null=True
  6.     )
  7.     shade = models.ManyToManyField("scenes.Shade", help_text="Odcień")
  8.     wood = models.ForeignKey(
  9.         "scenes.Wood", on_delete=models.CASCADE, help_text="Rodzaj drewna"
  10.     )
  11.     abrasion = models.ForeignKey(
  12.         "scenes.Abrasion",
  13.         on_delete=models.CASCADE,
  14.         null=True,
  15.         help_text="Klasy ścieralności",
  16.     )
  17.     pattern = models.ForeignKey(
  18.         "scenes.Pattern", help_text="Wzór", on_delete=models.CASCADE, null=True
  19.     )
  20.     thickness = models.CharField(
  21.         choices=THICKNESSES,
  22.         max_length=10,
  23.         help_text="Grubości (dla paneli)",
  24.         null=True,
  25.         blank=True,
  26.     )
  27.     v_groove = models.BooleanField(default=False, help_text="V-Fuga")
  28.     v_groove_color = models.CharField(
  29.         max_length=10, null=True, blank=True, help_text="Kolor V-Fugi"
  30.     )
  31.     size = models.CharField(
  32.         choices=PANEL_SIZES,
  33.         max_length=15,
  34.         help_text="Format (dla paneli) lub wymiar (dla płyt i blatów",
  35.         null=True,
  36.         blank=True,
  37.     )
  38.     structure = models.CharField(
  39.         choices=STRUCTURES, max_length=5, help_text="Struktura", null=True, blank=True
  40.     )
  41.     light_reflection = models.CharField(
  42.         choices=LIGHT_REFLECTIONS,
  43.         max_length=24,
  44.         help_text="Rodzaj materiału",
  45.         default="shiny",
  46.     )
  47.     collection = models.ForeignKey(
  48.         "scenes.Collection", null=True, on_delete=models.CASCADE, name="Kolekcja"
  49.     )
  50.     decor_thickness = models.ManyToManyField(
  51.         "scenes.Thickness", help_text="Grubości (dla dekorów ściennych)"
  52.     )
  53.     details = models.CharField(
  54.         max_length=512, null=True, blank=True, help_text="Szczegóły produktu"
  55.     )
  56.     details_url = models.URLField(null=True, blank=True, max_length=500)
  57.  
  58.     def __str__(self):
  59.         return "{} #{}".format(self.type.capitalize(), self.pk)
  60.  
  61.     class Filters:
  62.         # this is stupid, but because of deadline there was requirement
  63.         # to mirror FE mock 1:1. After BETA, it should go away, or be handled more nicely
  64.         # Probably the best solution would be to renegotiate contract with FE.
  65.         def __init__(
  66.             self,
  67.             wood,
  68.             shade,
  69.             abrasion,
  70.             type,
  71.             pattern,
  72.             thickness,
  73.             v_groove,
  74.             v_groove_color,
  75.             size,
  76.             structure,
  77.             light_reflection,
  78.             collection,
  79.             decor_thickness,
  80.             details,
  81.         ):
  82.             self.wood = wood
  83.             self.shade = shade
  84.             self.abrasion = abrasion
  85.             self.type = type
  86.             self.pattern = pattern
  87.             self.thickness = thickness
  88.             self.v_groove = v_groove
  89.             self.v_groove_color = v_groove_color
  90.             self.size = size
  91.             self.structure = structure
  92.             self.light_reflection = light_reflection
  93.             self.collection = collection
  94.             self.decor_thickness = decor_thickness
  95.             self.details = details
  96.  
  97.     @property
  98.     def filters(self):
  99.         f = self.Filters(
  100.             wood=self.wood.name_pl,
  101.             shade=self.shade,
  102.             abrasion=self.abrasion.name_pl,
  103.             type=self.type,
  104.             pattern=self.pattern,
  105.             thickness=self.thickness,
  106.             v_groove=self.v_groove,
  107.             v_groove_color=self.v_groove_color,
  108.             size=self.size,
  109.             structure=self.structure,
  110.             light_reflection=self.light_reflection,
  111.             collection=getattr(self, "collection", None),
  112.             decor_thickness=self.decor_thickness,
  113.             details=self.details,
  114.         )
  115.         return f
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top