forked from ierror/BeautifulMind.io
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] mgmt command to delete exports older than one day
- Loading branch information
Showing
4 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Empty file.
20 changes: 20 additions & 0 deletions
20
beautifulmind/mindmap/management/commands/mindmap_clean_exports.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
import datetime | ||
from sockjs.tornado.router import SockJSRouter | ||
from django.core.files.storage import default_storage | ||
from django.core.management.base import BaseCommand | ||
from beautifulmind.mindmap.settings import EXPORTS_SAVE_PATH | ||
|
||
|
||
class Command(BaseCommand): | ||
can_import_settings = True | ||
|
||
def handle(self, *args, **options): | ||
for exported_file in default_storage.listdir(EXPORTS_SAVE_PATH)[1]: | ||
if exported_file == 'DONOTDELTETHISFOLDER': | ||
continue | ||
|
||
exported_file = '%s%s' % (EXPORTS_SAVE_PATH, exported_file) | ||
modified_time_delta = datetime.datetime.now() - default_storage.modified_time(exported_file) | ||
if modified_time_delta > datetime.timedelta(days=1): | ||
default_storage.delete(exported_file) |