Ver código fonte

Add codes to unidentifiable catalogue models (#4216)

* Add codes to unidentifiable catalogue models

* Add missing migration
master
Viggo de Vries 1 ano atrás
pai
commit
d94e52babc
Nenhuma conta vinculada ao e-mail do autor do commit

+ 28
- 0
src/oscar/apps/catalogue/abstract_models.py Ver arquivo

@@ -136,6 +136,13 @@ class AbstractCategory(MP_Node):
136 136
     COMPARISON_FIELDS = ("pk", "path", "depth")
137 137
 
138 138
     name = models.CharField(_("Name"), max_length=255, db_index=True)
139
+    code = NullCharField(
140
+        _("Code"),
141
+        max_length=255,
142
+        blank=True,
143
+        null=True,
144
+        unique=True,
145
+    )
139 146
     description = models.TextField(_("Description"), blank=True)
140 147
     meta_title = models.CharField(
141 148
         _("Meta title"), max_length=255, blank=True, null=True
@@ -1300,6 +1307,13 @@ class AbstractAttributeOptionGroup(models.Model):
1300 1307
     """
1301 1308
 
1302 1309
     name = models.CharField(_("Name"), max_length=128)
1310
+    code = NullCharField(
1311
+        _("Unique identifier"),
1312
+        max_length=255,
1313
+        blank=True,
1314
+        null=True,
1315
+        unique=True,
1316
+    )
1303 1317
 
1304 1318
     def __str__(self):
1305 1319
         return self.name
@@ -1329,6 +1343,13 @@ class AbstractAttributeOption(models.Model):
1329 1343
         verbose_name=_("Group"),
1330 1344
     )
1331 1345
     option = models.CharField(_("Option"), max_length=255)
1346
+    code = NullCharField(
1347
+        _("Unique identifier"),
1348
+        max_length=255,
1349
+        blank=True,
1350
+        null=True,
1351
+        unique=True,
1352
+    )
1332 1353
 
1333 1354
     def __str__(self):
1334 1355
         return self.option
@@ -1535,6 +1556,13 @@ class AbstractProductImage(models.Model):
1535 1556
         related_name="images",
1536 1557
         verbose_name=_("Product"),
1537 1558
     )
1559
+    code = NullCharField(
1560
+        _("Code"),
1561
+        max_length=255,
1562
+        blank=True,
1563
+        null=True,
1564
+        unique=True,
1565
+    )
1538 1566
     original = models.ImageField(
1539 1567
         _("Original"), upload_to=get_image_upload_path, max_length=255
1540 1568
     )

+ 41
- 0
src/oscar/apps/catalogue/migrations/0027_attributeoption_code_attributeoptiongroup_code_and_more.py Ver arquivo

@@ -0,0 +1,41 @@
1
+# Generated by Django 4.2.6 on 2023-12-20 17:10
2
+
3
+from django.db import migrations
4
+import oscar.models.fields
5
+
6
+
7
+class Migration(migrations.Migration):
8
+    dependencies = [
9
+        ("catalogue", "0026_predefined_product_options"),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AddField(
14
+            model_name="attributeoption",
15
+            name="code",
16
+            field=oscar.models.fields.NullCharField(
17
+                max_length=255, unique=True, verbose_name="Unique identifier"
18
+            ),
19
+        ),
20
+        migrations.AddField(
21
+            model_name="attributeoptiongroup",
22
+            name="code",
23
+            field=oscar.models.fields.NullCharField(
24
+                max_length=255, unique=True, verbose_name="Unique identifier"
25
+            ),
26
+        ),
27
+        migrations.AddField(
28
+            model_name="category",
29
+            name="code",
30
+            field=oscar.models.fields.NullCharField(
31
+                max_length=255, unique=True, verbose_name="Code"
32
+            ),
33
+        ),
34
+        migrations.AddField(
35
+            model_name="productimage",
36
+            name="code",
37
+            field=oscar.models.fields.NullCharField(
38
+                max_length=255, unique=True, verbose_name="Code"
39
+            ),
40
+        ),
41
+    ]

+ 41
- 0
tests/_site/apps/catalogue/migrations/0027_attributeoption_code_attributeoptiongroup_code_and_more.py Ver arquivo

@@ -0,0 +1,41 @@
1
+# Generated by Django 4.2.6 on 2023-12-20 17:10
2
+
3
+from django.db import migrations
4
+import oscar.models.fields
5
+
6
+
7
+class Migration(migrations.Migration):
8
+    dependencies = [
9
+        ("catalogue", "0026_predefined_product_options"),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AddField(
14
+            model_name="attributeoption",
15
+            name="code",
16
+            field=oscar.models.fields.NullCharField(
17
+                max_length=255, unique=True, verbose_name="Unique identifier"
18
+            ),
19
+        ),
20
+        migrations.AddField(
21
+            model_name="attributeoptiongroup",
22
+            name="code",
23
+            field=oscar.models.fields.NullCharField(
24
+                max_length=255, unique=True, verbose_name="Unique identifier"
25
+            ),
26
+        ),
27
+        migrations.AddField(
28
+            model_name="category",
29
+            name="code",
30
+            field=oscar.models.fields.NullCharField(
31
+                max_length=255, unique=True, verbose_name="Code"
32
+            ),
33
+        ),
34
+        migrations.AddField(
35
+            model_name="productimage",
36
+            name="code",
37
+            field=oscar.models.fields.NullCharField(
38
+                max_length=255, unique=True, verbose_name="Code"
39
+            ),
40
+        ),
41
+    ]

Carregando…
Cancelar
Salvar