Last active
December 11, 2015 02:18
-
-
Save tomviner/4529641 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# based on http://django-filer.readthedocs.org/en/0.9.2/upgrading.html#from-pre-0-9a3-develop-to-0-9 | |
import sys, os | |
from django.conf import settings | |
from filer.models import File | |
print 'PUBLIC\N' | |
for f in File.objects.filter(is_public=True): | |
sys.stdout.write(u'moving %s to public storage... ' % f.id) | |
f.is_public = False | |
f.file.name = "filer/%s" % f.file.name | |
if os.path.exists(os.path.join(settings.MEDIA_ROOT, f.file.name)): | |
f.save() | |
f.is_public = True | |
f.save() | |
sys.stdout.write(u'done\n') | |
else: | |
print 'not found:', f.file.name | |
print 'PRIVATE\N' | |
for f in File.objects.filter(is_public=False): | |
sys.stdout.write(u'moving %s to private storage... ' % f.id) | |
if os.path.exists(os.path.join(settings.MEDIA_ROOT, f.file.name)): | |
f.is_public = True | |
f.file.name = "filer/%s" % f.file.name | |
f.save() | |
f.is_public = False | |
f.save() | |
sys.stdout.write(u'done\n') | |
else: | |
print 'not found:', f.file.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment