Przeglądaj źródła

Fixes #11379: Fix TypeError exception when bulk editing custom date fields

jeremystretch 3 lat temu
rodzic
commit
93ac0b77c9
1 zmienionych plików z 3 dodań i 3 usunięć
  1. 3 3
      netbox/netbox/views/generic/bulk_views.py

+ 3 - 3
netbox/netbox/views/generic/bulk_views.py

@@ -494,7 +494,7 @@ class BulkEditView(GetReturnURLMixin, BaseMultiObjectView):
         return get_permission_for_model(self.queryset.model, 'change')
         return get_permission_for_model(self.queryset.model, 'change')
 
 
     def _update_objects(self, form, request):
     def _update_objects(self, form, request):
-        custom_fields = getattr(form, 'custom_fields', [])
+        custom_fields = getattr(form, 'custom_fields', {})
         standard_fields = [
         standard_fields = [
             field for field in form.fields if field not in list(custom_fields) + ['pk']
             field for field in form.fields if field not in list(custom_fields) + ['pk']
         ]
         ]
@@ -532,13 +532,13 @@ class BulkEditView(GetReturnURLMixin, BaseMultiObjectView):
                     setattr(obj, name, form.cleaned_data[name])
                     setattr(obj, name, form.cleaned_data[name])
 
 
             # Update custom fields
             # Update custom fields
-            for name in custom_fields:
+            for name, customfield in custom_fields.items():
                 assert name.startswith('cf_')
                 assert name.startswith('cf_')
                 cf_name = name[3:]  # Strip cf_ prefix
                 cf_name = name[3:]  # Strip cf_ prefix
                 if name in form.nullable_fields and name in nullified_fields:
                 if name in form.nullable_fields and name in nullified_fields:
                     obj.custom_field_data[cf_name] = None
                     obj.custom_field_data[cf_name] = None
                 elif name in form.changed_data:
                 elif name in form.changed_data:
-                    obj.custom_field_data[cf_name] = form.fields[name].prepare_value(form.cleaned_data[name])
+                    obj.custom_field_data[cf_name] = customfield.serialize(form.cleaned_data[name])
 
 
             obj.full_clean()
             obj.full_clean()
             obj.save()
             obj.save()