This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| from threading import Thread | |
| class SimulateAPICallThread(Thread): | |
| def __init__(self, name): | |
| super().__init__() | |
| self.name = name | |
| def run(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| def sum(a, b): | |
| return a + b | |
| class TestSum(unittest.TestCase): | |
| def test_sum_of_positive_numbers(self): | |
| self.assertEqual(sum(2,2), 5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| def sum(a, b): | |
| return a + b | |
| class TestSum(unittest.TestCase): | |
| def test_sum_of_postive_numbers(self): | |
| self.assertEqual(sum(2,2),4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import uuid | |
| import secrets | |
| from django.db import models | |
| from django.urls import reverse | |
| from django.utils.text import slugify | |
| class Category(models.Model): | |
| title = models.CharField(max_length=200, unique=True) | |
| description = models.TextField(max_length=255, blank=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Image(models.Model): | |
| product_entry = models.ForeignKey(Product_Entry, on_delete=models.CASCADE) | |
| thumb = models.ImageField(default='default.jpeg', blank=True) | |
| def __str__(self): | |
| return self.product_entry.title | |
| class Meta: | |
| verbose_name_plural = "Images" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Product_Entry(models.Model): | |
| sku = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) | |
| title = models.CharField(unique=True, max_length=200) | |
| product = models.ForeignKey(Product, on_delete=models.CASCADE) | |
| size = models.ForeignKey(Size, on_delete=models.CASCADE, blank=True, null=True) | |
| color = models.ForeignKey(Color, on_delete=models.CASCADE, blank=True, null=True) | |
| quantity = models.PositiveIntegerField(default=1) | |
| price = models.DecimalField(max_digits=12, decimal_places=2, default=0) | |
| available = models.BooleanField(default=False) | |
| created_at = models.DateTimeField(auto_now_add=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Size(models.Model): | |
| title = models.CharField(max_length=20) | |
| def __str__(self): | |
| return self.title | |
| class Meta: | |
| verbose_name_plural = "Sizes" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Color(models.Model): | |
| name = models.CharField(max_length=20, unique=True) | |
| code = models.CharField(max_length=10, unique=True) | |
| def __str__(self): | |
| return self.name | |
| class Meta: | |
| verbose_name_plural = "Colors" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import secrets | |
| from django.db import models | |
| from django.urls import reverse | |
| from django.utils.text import slugify | |
| class Product(models.Model): | |
| title = models.CharField(max_length=200, unique=True) | |
| slug = models.SlugField(unique=True, blank=True) | |
| description = models.TextField() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import secrets | |
| from django.db import models | |
| from django.utils.text import slugify | |
| class Product(models.Model): | |
| title = models.CharField(max_length=150, unique=True) | |
| slug = models.SlugField(unique=True) | |
| description = models.TextField(max_length=1000, blank=True) | |
| def __str__(self): |