浏览代码

Add codes to unidentifiable catalogue models (#4216)

* Add codes to unidentifiable catalogue models

* Add missing migration
master
Viggo de Vries 1年前
父节点
当前提交
d94e52babc
没有帐户链接到提交者的电子邮件

+ 28
- 0
src/oscar/apps/catalogue/abstract_models.py 查看文件

136
     COMPARISON_FIELDS = ("pk", "path", "depth")
136
     COMPARISON_FIELDS = ("pk", "path", "depth")
137
 
137
 
138
     name = models.CharField(_("Name"), max_length=255, db_index=True)
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
     description = models.TextField(_("Description"), blank=True)
146
     description = models.TextField(_("Description"), blank=True)
140
     meta_title = models.CharField(
147
     meta_title = models.CharField(
141
         _("Meta title"), max_length=255, blank=True, null=True
148
         _("Meta title"), max_length=255, blank=True, null=True
1300
     """
1307
     """
1301
 
1308
 
1302
     name = models.CharField(_("Name"), max_length=128)
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
     def __str__(self):
1318
     def __str__(self):
1305
         return self.name
1319
         return self.name
1329
         verbose_name=_("Group"),
1343
         verbose_name=_("Group"),
1330
     )
1344
     )
1331
     option = models.CharField(_("Option"), max_length=255)
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
     def __str__(self):
1354
     def __str__(self):
1334
         return self.option
1355
         return self.option
1535
         related_name="images",
1556
         related_name="images",
1536
         verbose_name=_("Product"),
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
     original = models.ImageField(
1566
     original = models.ImageField(
1539
         _("Original"), upload_to=get_image_upload_path, max_length=255
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 查看文件

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 查看文件

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
+    ]

正在加载...
取消
保存