|
|
@@ -255,10 +255,6 @@ class ProductCreateUpdateView(generic.UpdateView):
|
|
255
|
255
|
if is_valid and cross_form_validation_result:
|
|
256
|
256
|
return self.forms_valid(form, formsets)
|
|
257
|
257
|
else:
|
|
258
|
|
- # Delete the temporary product again
|
|
259
|
|
- if self.creating and self.object and self.object.pk is not None:
|
|
260
|
|
- self.object.delete()
|
|
261
|
|
- self.object = None
|
|
262
|
258
|
return self.forms_invalid(form, formsets)
|
|
263
|
259
|
|
|
264
|
260
|
# form_valid and form_invalid are called depending on the validation result
|
|
|
@@ -293,6 +289,20 @@ class ProductCreateUpdateView(generic.UpdateView):
|
|
293
|
289
|
return HttpResponseRedirect(self.get_success_url())
|
|
294
|
290
|
|
|
295
|
291
|
def forms_invalid(self, form, formsets):
|
|
|
292
|
+ # delete the temporary product again
|
|
|
293
|
+ if self.creating and self.object and self.object.pk is not None:
|
|
|
294
|
+ self.object.delete()
|
|
|
295
|
+ self.object = None
|
|
|
296
|
+
|
|
|
297
|
+ # We currently don't hold on to images if the other formsets didn't
|
|
|
298
|
+ # validate. But as the browser won't re-POST any images, we can do no
|
|
|
299
|
+ # better than re-bind the image formset, which means the user will
|
|
|
300
|
+ # have to re-select the images
|
|
|
301
|
+ image_formset_class = self.formsets.get('image_formset')
|
|
|
302
|
+ if 'image_formset' in formsets and image_formset_class is not None:
|
|
|
303
|
+ formsets['image_formset'] = image_formset_class(
|
|
|
304
|
+ self.product_class, self.request.user, instance=self.object)
|
|
|
305
|
+
|
|
296
|
306
|
messages.error(self.request,
|
|
297
|
307
|
_("Your submitted data was not valid - please "
|
|
298
|
308
|
"correct the below errors"))
|