delete orphaned labels when jt or j deleted

This commit is contained in:
Chris Meyers
2016-04-26 17:48:23 -04:00
parent 2f18a9f2c1
commit 1925742da1
6 changed files with 73 additions and 9 deletions

View File

@@ -449,8 +449,10 @@ class DeleteLastUnattachLabelMixin(object):
res = super(DeleteLastUnattachLabelMixin, self).unattach_by_id(request, sub_id)
if Label.is_detached(sub_id):
Label.objects.get(id=sub_id).delete()
label = Label.objects.get(id=sub_id)
if label.is_detached():
label.delete()
return res