This may be a little paranoid but don't assume everything has a description.

This commit is contained in:
Michael DeHaan
2013-07-27 19:14:04 -04:00
parent af43954ca8
commit 8f379b2397

View File

@@ -100,10 +100,15 @@ class PrimordialModel(models.Model):
if 'name' in self._meta.get_all_field_names(): if 'name' in self._meta.get_all_field_names():
# 0 1 # 0 1
# 01234567890123 # 01234567890123
old_desc = self.description has_description = False
self.description = "deleted: %s" % self.name if 'description' in self._meta.get_all_field_names():
if old_desc: has_description = True
self.description = "%s (%s)" % (self.description, old_desc) old_desc = ''
if has_description:
old_desc = self.description
self.description = "deleted: %s" % self.name
if old_desc:
self.description = "%s (%s)" % (self.description, old_desc)
self.name = "_d_%s" % (now().isoformat()) self.name = "_d_%s" % (now().isoformat())
self.active = False self.active = False
if save: if save: