From b7062ca5ca4f3f80e626479de2dffaa878a62dde Mon Sep 17 00:00:00 2001
From: Calen Pennington <calen.pennington@gmail.com>
Date: Fri, 29 Jun 2012 16:05:20 -0400
Subject: [PATCH] Only set the xml slug if it isn't already set

---
 common/lib/keystore/xml.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/common/lib/keystore/xml.py b/common/lib/keystore/xml.py
index 0672e4a7ff3..b078474a007 100644
--- a/common/lib/keystore/xml.py
+++ b/common/lib/keystore/xml.py
@@ -40,11 +40,12 @@ class XMLModuleStore(ModuleStore):
                         except:
                             log.exception("Unable to parse xml: {xml}".format(xml=xml))
                             raise
-                        if xml_data.get('name'):
-                            xml_data.set('slug', Location.clean(xml_data.get('name')))
-                        else:
-                            self.unnamed_modules += 1
-                            xml_data.set('slug', '{tag}_{count}'.format(tag=xml_data.tag, count=self.unnamed_modules))
+                        if xml_data.get('slug') is None:
+                            if xml_data.get('name'):
+                                xml_data.set('slug', Location.clean(xml_data.get('name')))
+                            else:
+                                self.unnamed_modules += 1
+                                xml_data.set('slug', '{tag}_{count}'.format(tag=xml_data.tag, count=self.unnamed_modules))
 
                         module = XModuleDescriptor.load_from_xml(etree.tostring(xml_data), self, org, course, modulestore.default_class)
                         modulestore.modules[module.location] = module
-- 
GitLab