Преглед изворни кода

Re-bind image formset if other product formsets fail to validate

We currently don't hold on to images that are uploaded if any of the
other formsets fail when editing/creating products. To prevent
issue #1126, we need to re-bind the formset.

This behaviour should be improved as part of #856.
master
Maik Hoepfel пре 12 година
родитељ
комит
05c185fcfe
1 измењених фајлова са 6 додато и 0 уклоњено
  1. 6
    0
      oscar/apps/dashboard/catalogue/views.py

+ 6
- 0
oscar/apps/dashboard/catalogue/views.py Прегледај датотеку

267
             if self.creating and form.is_valid():
267
             if self.creating and form.is_valid():
268
                 self.object.delete()
268
                 self.object.delete()
269
                 self.object = None
269
                 self.object = None
270
+            # We currently don't hold on to images if the other formsets didn't
271
+            # validate. But as the browser won't re-POST any images, we can do
272
+            # no better than re-bind the image formset, which means the user
273
+            # will have to re-select the images (see #1126)
274
+            image_formset = self.image_formset(instance=self.object)
275
+
270
             return self.forms_invalid(
276
             return self.forms_invalid(
271
                 form, stockrecord_formset, category_formset,
277
                 form, stockrecord_formset, category_formset,
272
                 image_formset, recommended_formset)
278
                 image_formset, recommended_formset)

Loading…
Откажи
Сачувај