2017-11-10 22:50:06 +01:00
|
|
|
import os
|
|
|
|
|
2017-11-10 18:36:16 +01:00
|
|
|
from django.conf import settings
|
2017-07-05 22:42:50 +02:00
|
|
|
from django.core.management.base import BaseCommand
|
2017-11-10 18:36:16 +01:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2017-07-05 22:42:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = 'clear the mapdata cache'
|
|
|
|
|
2017-11-10 22:50:06 +01:00
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument('--include-history', action='store_const', const=True, default=False,
|
|
|
|
help=_('incluce all history as well'))
|
|
|
|
|
2017-07-05 22:42:50 +02:00
|
|
|
def handle(self, *args, **options):
|
|
|
|
from c3nav.mapdata.models import MapUpdate
|
|
|
|
MapUpdate.objects.create(type='management')
|
2017-11-10 18:36:16 +01:00
|
|
|
|
2017-11-10 22:50:06 +01:00
|
|
|
if options['include_history']:
|
|
|
|
for file in os.listdir(settings.CACHE_ROOT):
|
|
|
|
if file.startswith('level_'):
|
|
|
|
os.remove(os.path.join(settings.CACHE_ROOT, file))
|
|
|
|
|
2017-11-10 18:36:16 +01:00
|
|
|
if not settings.HAS_REAL_CACHE:
|
|
|
|
print(_('You have no external cache configured, so don\'t forget to restart your c3nav instance!'))
|