diff --git a/dpaste/management/commands/cleanup_snippets.py b/dpaste/management/commands/cleanup_snippets.py index cec58e4..37776b0 100644 --- a/dpaste/management/commands/cleanup_snippets.py +++ b/dpaste/management/commands/cleanup_snippets.py @@ -1,26 +1,29 @@ import sys from optparse import make_option -from django.core.management.base import LabelCommand +from django.core.management.base import BaseCommand from django.utils import timezone from dpaste.models import Snippet -class Command(LabelCommand): - option_list = LabelCommand.option_list + ( - make_option('--dry-run', '-d', action='store_true', dest='dry_run', - help='Don\'t do anything.'), - ) +class Command(BaseCommand): help = "Purges snippets that are expired" + def add_arguments(self, parser): + parser.add_argument('--dry-run', action='store_true', dest='dry_run', + help='Don\'t do anything.'), + def handle(self, *args, **options): deleteable_snippets = Snippet.objects.filter( expires__isnull=False, expire_type=Snippet.EXPIRE_TIME, expires__lte=timezone.now() ) - self.stdout.write(u"%s snippets gets deleted:\n" % deleteable_snippets.count()) + if len(deleteable_snippets) == 0: + self.stdout.write(u"No snippets to delete.") + return None + self.stdout.write(u"Will delete %s snippet(s):\n" % deleteable_snippets.count()) for d in deleteable_snippets: self.stdout.write(u"- %s (%s)\n" % (d.secret_id, d.expires)) if options.get('dry_run'): diff --git a/dpaste/settings/local.py.example b/dpaste/settings/local.py.example index b9e789a..5c5ffcf 100644 --- a/dpaste/settings/local.py.example +++ b/dpaste/settings/local.py.example @@ -1,7 +1,6 @@ from dpaste.settings.base import * DEBUG = True -TEMPLATE_DEBUG = DEBUG ADMINS = ( #('Your Name', 'name@example.com'), diff --git a/dpaste/urls/dpaste_api.py b/dpaste/urls/dpaste_api.py index df419e4..64f6334 100644 --- a/dpaste/urls/dpaste_api.py +++ b/dpaste/urls/dpaste_api.py @@ -1,4 +1,4 @@ -from django.conf.urls import patterns, url +from django.conf.urls import url from ..views import snippet_api diff --git a/runtests.py b/runtests.py index 770f4e4..2338e5b 100755 --- a/runtests.py +++ b/runtests.py @@ -40,7 +40,9 @@ SETTINGS = { ), 'STATIC_ROOT': '/tmp/dpaste_test_static/', 'STATIC_URL': '/static/', - 'ROOT_URLCONF': 'dpaste.urls' + 'ROOT_URLCONF': 'dpaste.urls', + 'LANGUAGE_CODE': 'en', + 'LANGUAGES': (('en', 'English'),), } def runtests(*test_args):