From 30825e03efc4d9353ab045dce4832f68ab3c5ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 1 Oct 2017 17:21:02 +0200 Subject: [PATCH] add management command to clean auto tiles --- .../commands/gnm_clean_autotiles.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 combo_plugin_gnm/management/commands/gnm_clean_autotiles.py diff --git a/combo_plugin_gnm/management/commands/gnm_clean_autotiles.py b/combo_plugin_gnm/management/commands/gnm_clean_autotiles.py new file mode 100644 index 0000000..c6d2277 --- /dev/null +++ b/combo_plugin_gnm/management/commands/gnm_clean_autotiles.py @@ -0,0 +1,25 @@ +# combo-plugin-gnm - Combo GNM plugin +# Copyright (C) 2017 Entr'ouvert +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from django.core.management.base import BaseCommand +from django.utils.timezone import now, timedelta + +from combo.data.models import ConfigJsonCell + +class Command(BaseCommand): + def handle(self, *args, **options): + ConfigJsonCell.objects.filter(placeholder='_auto_tile', + last_update_timestamp__lte=now() - timedelta(days=2)).delete()