Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Merge pull request #64 from theonion/change-storage-root-option-format
Browse files Browse the repository at this point in the history
Change storage root option format
  • Loading branch information
mparent61 committed Mar 31, 2016
2 parents 16b6cf0 + 83a99b2 commit b2640d8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Betty Cropper Change Log

## Version 2.0.3

- Management command `change_storage_root` uses older option format for compatibility with Django 1.7

## Version 2.0.2

- Added `settings.BETTY_CACHE_CROP_SEC` to allow configurable crop (and animated) cache times. Defaults to original `300` seconds.
Expand Down
2 changes: 1 addition & 1 deletion betty/__init__.py
Expand Up @@ -2,4 +2,4 @@

from .celery import app as celery_app # noqa

__version__ = "2.0.2"
__version__ = "2.0.3"
35 changes: 31 additions & 4 deletions betty/cropper/management/commands/change_storage_root.py
@@ -1,3 +1,5 @@
from optparse import make_option

from django.core.management.base import BaseCommand

from betty.cropper.models import Image
Expand All @@ -6,15 +8,40 @@
class Command(BaseCommand):
help = 'Change root path for Image file fields'

def add_arguments(self, parser):
parser.add_argument('--check', action='store_true', help='Dry-run (read-only) check mode')
parser.add_argument('--old', required=True, help='Old root path (ex: /var/betty-cropper)')
parser.add_argument('--new', required=True, help='New root path (ex: /testing/)')
# This needs to run on Django 1.7
option_list = BaseCommand.option_list + (
make_option('--check',
action='store_true',
dest='check',
default=False,
help='Dry-run (read-only) check mode'),
make_option('--old',
dest='old',
help='Old root path (ex: /var/betty-cropper/)'),
make_option('--new',
dest='new',
help='New root path (ex: /testing/)'),
)

# This only works on Django 1.8+
# def add_arguments(self, parser):
# parser.add_argument('--check', action='store_true', help='')
# parser.add_argument('--old', required=True, help='Old root path (ex: /var/betty-cropper)')
# parser.add_argument('--new', required=True, help='New root path (ex: /testing/)')

def handle(self, *args, **options):

if not options['old']:
raise Exception('Old root not provided')

if not options['new']:
raise Exception('New root not provided')

# Sanity check: Make sure same separator ending
assert options['old'].endswith('/') == options['new'].endswith('/')

self.stdout.write('Checking {} images...'.format(Image.objects.count()))

for image in Image.objects.iterator():

for field in [image.source,
Expand Down

0 comments on commit b2640d8

Please sign in to comment.