Commits

Hynek Cernoch committed f127361

Fixed more bugs in product export. Closes #1353

Comments (0)

Files changed (1)

satchmo/apps/product/forms.py

 log = logging.getLogger('product.forms')
 
 def export_choices():
-    fmts = serializers.get_serializer_formats()
+    fmts = serializers.get_public_serializer_formats()
     return zip(fmts,fmts)
 
 class InventoryForm(forms.Form):
                     images.append(image.picture)
             if include_categories:
                 for category in product.category.all():
-                    if category not in categories:
-                        categories[category] = 1
+                    wcategory = category
+                    while wcategory and wcategory not in categories:
+                        categories[wcategory] = 1
+                        wcategory = wcategory.parent
 
         # Export all categories, translations.  Export images,translations if
         # desired.
             raise CommandError("Unable to serialize database: %s" % e)
 
         if include_images:
-            filedir = settings.MEDIA_ROOT
             buf = StringIO()
             zf = zipfile.ZipFile(buf, 'a', zipfile.ZIP_STORED)
 
             zinfo.external_attr = 2175008768L
 
             for image in images:
-                f = os.path.join(filedir, image)
+                f = image.path
                 if os.path.exists(f):
                     zf.write(f, str(image))
 
         else:
             raw = StringIO(str(raw))
 
-        if not format in serializers.get_serializer_formats():
+        if not format in serializers.get_public_serializer_formats():
             errors.append(_('Unknown file format: %s') % format)
 
         if not errors: