mirror of
https://github.com/ansible/awx.git
synced 2026-04-10 20:49:24 -02:30
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:
@@ -55,7 +55,7 @@ class Command(BaseCommand):
|
|||||||
return
|
return
|
||||||
qs = model.objects.filter(**{
|
qs = model.objects.filter(**{
|
||||||
active_field: False,
|
active_field: False,
|
||||||
'%s__startswith' % name_field: '_deleted_',
|
'%s__startswith' % name_field: '_d',
|
||||||
})
|
})
|
||||||
self.logger.debug('cleaning up model %s', model)
|
self.logger.debug('cleaning up model %s', model)
|
||||||
for instance in qs:
|
for instance in qs:
|
||||||
|
|||||||
@@ -98,7 +98,13 @@ class PrimordialModel(models.Model):
|
|||||||
|
|
||||||
if self.active:
|
if self.active:
|
||||||
if 'name' in self._meta.get_all_field_names():
|
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
|
self.active = False
|
||||||
if save:
|
if save:
|
||||||
self.save()
|
self.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user