Browse Source

Make category slugs dashboard-editable.

master
Samir Shah 5 years ago
parent
commit
b84f70fa1c
2 changed files with 14 additions and 2 deletions
  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 View File

67
 - Several models were updated to define a default ordering, to avoid issues with inconsistent ordering of
67
 - Several models were updated to define a default ordering, to avoid issues with inconsistent ordering of
68
   items in the dashboard and elsewhere. Database migrations are required for these changes.
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
 Dependency changes
72
 Dependency changes
71
 ~~~~~~~~~~~~~~~~~~
73
 ~~~~~~~~~~~~~~~~~~
72
 
74
 

+ 12
- 2
src/oscar/apps/dashboard/catalogue/forms.py View File

24
                                                   ('RelatedFieldWidgetWrapper',
24
                                                   ('RelatedFieldWidgetWrapper',
25
                                                    'RelatedMultipleFieldWidgetWrapper'))
25
                                                    'RelatedMultipleFieldWidgetWrapper'))
26
 
26
 
27
-CategoryForm = movenodeform_factory(
27
+
28
+BaseCategoryForm = movenodeform_factory(
28
     Category,
29
     Category,
29
-    fields=['name', 'description', 'image', 'is_public'],
30
+    fields=['name', 'slug', 'description', 'image', 'is_public'],
30
     exclude=['ancestors_are_public'])
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
 class ProductClassSelectForm(forms.Form):
43
 class ProductClassSelectForm(forms.Form):
34
     """
44
     """
35
     Form which is used before creating a product to select it's product class
45
     Form which is used before creating a product to select it's product class

Loading…
Cancel
Save