Summary: Make the pruning of empty BOF charters look at a history for

empty files too
 - Legacy-Id: 10187
This commit is contained in:
Ole Laursen 2015-10-12 13:19:45 +00:00
parent 5b480c4aee
commit 20f79316ff

View file

@ -21,20 +21,28 @@ def get_rid_of_empty_charters(apps, schema_editor):
if group.charter:
charter = group.charter
# clean up any empty files left behind
revisions = set()
revisions.add(charter.rev)
for h in charter.history_set.all():
revisions.add(h.rev)
for rev in revisions:
path = os.path.join(settings.CHARTER_PATH, '%s-%s.txt' % (charter.name, rev))
try:
if os.path.exists(path):
with open(path, 'r') as f:
if f.read() == "":
os.remove(path)
except IOError:
pass
group.charter = None
group.save()
path = os.path.join(settings.CHARTER_PATH, '%s-%s.txt' % (charter.name, charter.rev))
try:
if os.path.exists(path):
with open(path, 'r') as f:
if f.read() == "":
os.remove(path)
except IOError:
pass
charter.delete()
def fix_empty_rrg_charter(apps, schema_editor):
Document = apps.get_model("doc", "Document")
DocEvent = apps.get_model("doc", "DocEvent")