Beispiel #1
0
class Brand(models.Model):
    def folder_path(self, filename):
        upload_dir = os.path.join('brand/', f'{self.brand_name}')
        return os.path.join(upload_dir, filename)

    user = models.ForeignKey(User,
                             on_delete=models.CASCADE,
                             related_name='brand_user')
    brand_name = models.CharField(max_length=250)
    is_feature = models.BooleanField(default=False)
    is_approved = models.BooleanField(default=False)
    brand_image = models.FileField(upload_to=folder_path,
                                   blank=True,
                                   null=True)
    alt = models.TextField(max_length=50000, null=True, blank=True)
    approved_by = models.ForeignKey(User,
                                    on_delete=models.CASCADE,
                                    null=True,
                                    blank=True,
                                    related_name='brand_approved_by_user')
    slug = models.CharField(max_length=250, blank=True, null=True)
    meta_description = models.TextField(max_length=10000,
                                        null=True,
                                        blank=True)
    meta_keyword = models.CharField(max_length=250, null=True, blank=True)
    meta_title = models.CharField(max_length=250, null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now_add=True)
Beispiel #2
0
class Product(models.Model):
    def folder_path(self, filename):
        product_name = self.product_name.lower().replace(' ', '_')
        upload_dir = os.path.join('products/', f'{product_name}/certificate')
        return os.path.join(upload_dir, filename)

    product_code = models.CharField(max_length=250, unique=True)
    user = models.ForeignKey(User,
                             on_delete=models.CASCADE,
                             related_name='product_user')
    brand = models.ForeignKey(Brand,
                              on_delete=models.CASCADE,
                              null=True,
                              blank=True,
                              related_name='product_brand_relation')
    category = models.ForeignKey(Categories,
                                 on_delete=models.CASCADE,
                                 null=True,
                                 blank=True)
    product_name = models.CharField(max_length=255, unique=True)
    product_description = models.TextField(max_length=65500,
                                           null=True,
                                           blank=True)
    product_specification = models.TextField(max_length=65500,
                                             null=True,
                                             blank=True)
    purchase_note = models.TextField(max_length=65500, null=True, blank=True)
    certificate_by = models.CharField(max_length=250, null=True, blank=True)
    certificate_file = models.FileField(upload_to=folder_path,
                                        blank=True,
                                        null=True)
    price = models.FloatField(max_length=250)
    selling_price = models.FloatField(max_length=250)
    price_off = models.CharField(max_length=250, null=True, blank=True)
    status = models.BooleanField(default=True)
    likes = models.IntegerField(default=0)
    view = models.IntegerField(default=0)
    total_comment = models.IntegerField(default=0)
    total_review = models.FloatField(default=0)
    is_feature = models.BooleanField(default=False)
    is_approved = models.BooleanField(default=False)
    approved_by = models.ForeignKey('admin_users.User',
                                    on_delete=models.CASCADE,
                                    null=True,
                                    blank=True,
                                    related_name='product_approved_by_user')
    slug = models.CharField(max_length=250, blank=True, null=True)
    meta_description = models.TextField(max_length=10000,
                                        null=True,
                                        blank=True)
    meta_keyword = models.CharField(max_length=250, null=True, blank=True)
    meta_title = models.CharField(max_length=250, null=True, blank=True)
    delivery_charge = models.IntegerField(default=0)
    is_cod = models.BooleanField(default=True)
    product_tags = models.TextField(max_length=65500, null=True, blank=True)
    delivery_time = models.CharField(max_length=250, null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now_add=True)
Beispiel #3
0
class ProductShipping(models.Model):
    product = models.ForeignKey(Product, on_delete=models.CASCADE)
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    weight = models.CharField(max_length=250)
    length = models.CharField(max_length=250)
    width = models.CharField(max_length=250)
    height = models.CharField(max_length=250)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now_add=True)
Beispiel #4
0
class ProductSize(models.Model):
    def folder_path(self, filename):
        product_name = self.product.product_name.lower().replace(' ', '_')
        upload_dir = os.path.join('products/', f'{product_name}/sizes')
        return os.path.join(upload_dir, filename)

    product = models.ForeignKey(Product, on_delete=models.CASCADE)
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    size = models.CharField(max_length=250)
    size_image = models.FileField(upload_to=folder_path, blank=True, null=True)
    alt = models.TextField(max_length=10000, null=True, blank=True)
    is_feature = models.BooleanField(default=False)
    price = models.FloatField(default=0)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now_add=True)
Beispiel #5
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='CategoryProducts',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title', models.CharField(max_length=300)),
                ('slug', models.SlugField(blank=True, unique=True)),
                ('image',
                 models.ImageField(
                     blank=True,
                     null=True,
                     upload_to=categories.models.upload_image_path)),
                ('description', models.TextField(blank=True)),
                ('featured', models.BooleanField(default=False)),
                ('active', models.BooleanField(default=True)),
                ('pub_date', models.DateTimeField(auto_now_add=True)),
            ],
        ),
    ]
Beispiel #6
0
class ProductReview(models.Model):
    product = models.ForeignKey(Product, on_delete=models.CASCADE)
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    review = models.IntegerField(default=1)
    review_description = models.TextField(max_length=65500,
                                          null=True,
                                          blank=True)
    approved_by = models.ForeignKey(
        'admin_users.User',
        on_delete=models.CASCADE,
        null=True,
        blank=True,
        related_name='product_review_approved_by_user')
    is_approved = models.BooleanField(default=False)
    is_feature = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now_add=True)
Beispiel #7
0
class ShippingAddress(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    full_name = models.CharField(max_length=250)
    mobile_number = models.CharField(max_length=250)
    country = models.ForeignKey(Country,
                                on_delete=models.CASCADE,
                                related_name='shipping_address_country_name')
    city = models.ForeignKey(City,
                             on_delete=models.CASCADE,
                             related_name='shipping_address_city_name')
    state = models.ForeignKey(State,
                              on_delete=models.CASCADE,
                              related_name='shipping_address_state_name')
    pincode = models.ForeignKey(Pincode,
                                on_delete=models.CASCADE,
                                related_name='shipping_address_pincode')
    address = models.TextField(max_length=20000)
    landmark = models.CharField(max_length=250, null=True, blank=True)
    is_default = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now_add=True)
Beispiel #8
0
class ProductInventory(models.Model):
    product = models.ForeignKey(Product, on_delete=models.CASCADE)
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    stock_keeping_unit = models.CharField(max_length=250)
    stock_quantity = models.IntegerField(default=0)
    stock_status = models.CharField(max_length=250,
                                    choices=(('In stock', 'In stock'),
                                             ('Out of stock', 'Out of stock'),
                                             ('On backorder', 'On backorder')),
                                    null=True,
                                    blank=True)
    allow_backorders = models.CharField(
        max_length=250,
        choices=(('Do not allow', 'Do not allow'),
                 ('Allow, but notify customer',
                  'Allow, but notify customer'), ('Allow', 'Allow')),
        null=True,
        blank=True)
    low_stock_threshold = models.IntegerField(default=0)
    sold_individually = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now_add=True)
Beispiel #9
0
class ProductComment(models.Model):
    product = models.ForeignKey(Product,
                                on_delete=models.CASCADE,
                                related_name="product_comment")
    user = models.ForeignKey(User,
                             on_delete=models.CASCADE,
                             related_name="product_comment_user")
    comment = models.TextField(max_length=65500)
    sub_comment = models.ForeignKey('self',
                                    on_delete=models.CASCADE,
                                    related_name='product_sub_comment',
                                    null=True,
                                    blank=True)
    is_approved = models.BooleanField(default=False)
    approved_by = models.ForeignKey(
        'admin_users.User',
        on_delete=models.CASCADE,
        null=True,
        blank=True,
        related_name='product_comment_approved_by_user')
    is_feature = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now_add=True)
Beispiel #10
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('category_name',
                 models.CharField(blank=True,
                                  max_length=30,
                                  null=True,
                                  verbose_name='Kategori Ismi')),
                ('category_defination',
                 models.CharField(blank=True,
                                  max_length=140,
                                  null=True,
                                  verbose_name='Kategori Açıklaması')),
                ('category_logo',
                 models.CharField(blank=True,
                                  max_length=50,
                                  null=True,
                                  verbose_name='Kategori Logo')),
                ('category_slug',
                 models.SlugField(blank=True, null=True, verbose_name='Slug')),
                ('image_prod',
                 versatileimagefield.fields.VersatileImageField(
                     blank=True,
                     height_field='height_field',
                     null=True,
                     upload_to=categories.models.upload_location,
                     verbose_name='Kategori Resmi',
                     width_field='width_field')),
                ('height_field',
                 models.PositiveIntegerField(blank=True,
                                             default=0,
                                             verbose_name='Uzunluk Değeri')),
                ('width_field',
                 models.PositiveIntegerField(blank=True,
                                             default=0,
                                             verbose_name='Genişlik Değeri')),
                ('created_at',
                 models.DateTimeField(auto_now_add=True,
                                      verbose_name='Oluşturulma Tarihi')),
                ('updated_at',
                 models.DateTimeField(auto_now=True,
                                      verbose_name='Güncellenme Tarihi')),
                ('lft',
                 models.PositiveIntegerField(db_index=True, editable=False)),
                ('rght',
                 models.PositiveIntegerField(db_index=True, editable=False)),
                ('tree_id',
                 models.PositiveIntegerField(db_index=True, editable=False)),
                ('level',
                 models.PositiveIntegerField(db_index=True, editable=False)),
                ('parent',
                 mptt.fields.TreeForeignKey(
                     blank=True,
                     null=True,
                     on_delete=django.db.models.deletion.CASCADE,
                     related_name='children',
                     to='categories.Category',
                     verbose_name='Üst Kategori')),
            ],
            options={
                'verbose_name': 'Kategori',
                'verbose_name_plural': 'Kategoriler',
                'ordering': ('-created_at', ),
            },
        ),
        migrations.AlterUniqueTogether(
            name='category',
            unique_together={('parent', 'category_slug')},
        ),
    ]
Beispiel #11
0
class ProductView(models.Model):
    product = models.ForeignKey(Product, on_delete=models.CASCADE)
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now_add=True)
Beispiel #12
0
class ProductColor(models.Model):
    product = models.ForeignKey(Product, on_delete=models.CASCADE)
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    color_code = models.CharField(max_length=250)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now_add=True)