From fcc6210dc9a438e3cf4dddf905f546dd7a8e46da Mon Sep 17 00:00:00 2001 From: geistling <34081638+geistling@users.noreply.github.com> Date: Thu, 8 Aug 2024 12:13:06 -0400 Subject: [PATCH] remove zones for archived projects --- .../plugins/sftocf/management/commands/update_zones.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/coldfront/plugins/sftocf/management/commands/update_zones.py b/coldfront/plugins/sftocf/management/commands/update_zones.py index 686c08ed3..f563607d4 100644 --- a/coldfront/plugins/sftocf/management/commands/update_zones.py +++ b/coldfront/plugins/sftocf/management/commands/update_zones.py @@ -147,9 +147,13 @@ def handle(self, *args, **options): print(project, project.pk) zone = sf.get_zones(project.sf_zone) zone_paths_not_in_cf = [p for p in zone['paths'] if p.split(':')[0] not in sf_cf_vols] - # delete any zones that have no paths - if not zone_paths_not_in_cf: + # delete any zones that have no paths or belong to inactive projects + if not zone_paths_not_in_cf or project.status.name == 'Archived': if not dry_run: + if project.status.name == 'Archived': + logger.warning('Project %s is archived; deleting zone', project) + elif not zone_paths_not_in_cf: + logger.warning('Zone %s has no paths; deleting', zone['name']) sf.delete_zone(zone['id']) # delete projectattribute project.projectattribute_set.get(