categorias-productos #51 #52

Open
mono wants to merge 13 commits from feat/51-categorias-productos into main
3 changed files with 56 additions and 0 deletions
Showing only changes of commit 570fec0532 - Show all commits

View File

@@ -0,0 +1,28 @@
# Generated by Django 5.0.6 on 2026-10-10 21:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('don_confiao', '0055_productcategory_external_id'),
]
operations = [
migrations.AddField(
model_name='productcategory',
name='active',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='productcategory',
name='alternative_name',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AddField(
model_name='productcategory',
name='description',
field=models.TextField(blank=True, default=''),
),
]

View File

@@ -9,6 +9,9 @@ class MeasuringUnits(models.TextChoices):
class ProductCategory(models.Model):
name = models.CharField(max_length=100, unique=True)
external_id = models.CharField(max_length=100, null=True, blank=True)
description = models.TextField(blank=True, default="")
alternative_name = models.CharField(max_length=100, null=True, blank=True)
active = models.BooleanField(default=True)
def __str__(self):
return self.name

View File

@@ -0,0 +1,25 @@
from django.test import TestCase
from ..models.products import ProductCategory
class TestProductCategoryModel(TestCase):
def test_create_category_with_don_confiao_fields(self):
category = ProductCategory.objects.create(
name="Bebidas",
external_id="8",
description="Bebidas y jugos naturales",
alternative_name="Jugos",
active=False,
)
self.assertEqual(category.name, "Bebidas")
self.assertEqual(category.external_id, "8")
self.assertEqual(category.description, "Bebidas y jugos naturales")
self.assertEqual(category.alternative_name, "Jugos")
self.assertFalse(category.active)
def test_category_active_por_defecto(self):
category = ProductCategory.objects.create(name="Granos")
self.assertTrue(category.active)
self.assertEqual(category.description, "")
self.assertIsNone(category.alternative_name)