瀏覽代碼

Make category slugs dashboard-editable.

master
Samir Shah 5 年之前
父節點
當前提交
b84f70fa1c
共有 2 個檔案被更改,包括 14 行新增2 行删除
  1. 2
    0
      docs/source/releases/v3.0.rst
  2. 12
    2
      src/oscar/apps/dashboard/catalogue/forms.py

+ 2
- 0
docs/source/releases/v3.0.rst 查看文件

@@ -67,6 +67,8 @@ Minor changes
67 67
 - Several models were updated to define a default ordering, to avoid issues with inconsistent ordering of
68 68
   items in the dashboard and elsewhere. Database migrations are required for these changes.
69 69
 
70
+- Category slugs can now be edited via the dashboard.
71
+
70 72
 Dependency changes
71 73
 ~~~~~~~~~~~~~~~~~~
72 74
 

+ 12
- 2
src/oscar/apps/dashboard/catalogue/forms.py 查看文件

@@ -24,12 +24,22 @@ ProductSelect = get_class('dashboard.catalogue.widgets', 'ProductSelect')
24 24
                                                   ('RelatedFieldWidgetWrapper',
25 25
                                                    'RelatedMultipleFieldWidgetWrapper'))
26 26
 
27
-CategoryForm = movenodeform_factory(
27
+
28
+BaseCategoryForm = movenodeform_factory(
28 29
     Category,
29
-    fields=['name', 'description', 'image', 'is_public'],
30
+    fields=['name', 'slug', 'description', 'image', 'is_public'],
30 31
     exclude=['ancestors_are_public'])
31 32
 
32 33
 
34
+class CategoryForm(BaseCategoryForm):
35
+
36
+    def __init__(self, *args, **kwargs):
37
+        super().__init__(*args, **kwargs)
38
+        if 'slug' in self.fields:
39
+            self.fields['slug'].required = False
40
+            self.fields['slug'].help_text = _('Leave blank to generate from category name')
41
+
42
+
33 43
 class ProductClassSelectForm(forms.Form):
34 44
     """
35 45
     Form which is used before creating a product to select it's product class

Loading…
取消
儲存