mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-23 20:06:35 +11:00
Code cleanup and update for Django 1.10. Fixed all warnings.
This commit is contained in:
parent
a39697bdeb
commit
b51c16bcbc
4 changed files with 14 additions and 10 deletions
|
@ -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'):
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from dpaste.settings.base import *
|
||||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
ADMINS = (
|
||||
#('Your Name', 'name@example.com'),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from django.conf.urls import patterns, url
|
||||
from django.conf.urls import url
|
||||
|
||||
from ..views import snippet_api
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue