1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

In order to not worry about long usernames when deleting objects, just rename fields to include the date

and include the name/description in the new description when deleting objects.

Also updated deletion script to understand that.
This commit is contained in:
Michael DeHaan 2013-07-27 18:55:42 -04:00
parent ac3ab82cc6
commit af43954ca8
2 changed files with 8 additions and 2 deletions

View File

@ -55,7 +55,7 @@ class Command(BaseCommand):
return
qs = model.objects.filter(**{
active_field: False,
'%s__startswith' % name_field: '_deleted_',
'%s__startswith' % name_field: '_d',
})
self.logger.debug('cleaning up model %s', model)
for instance in qs:

View File

@ -98,7 +98,13 @@ class PrimordialModel(models.Model):
if self.active:
if 'name' in self._meta.get_all_field_names():
self.name = "_deleted_%s_%s" % (now().isoformat(), self.name)
# 0 1
# 01234567890123
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.active = False
if save:
self.save()