Skip to content

Commit

Permalink
Use BaseCommand instead of NoArgsCommand, thanks to @bittner, close #460
Browse files Browse the repository at this point in the history
  • Loading branch information
Fantomas42 committed Mar 8, 2016
1 parent 0a6bcee commit 61fbac0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions zinnia/management/commands/count_discussions.py
@@ -1,13 +1,15 @@
"""Management command for re-counting the discussions on Entry"""
"""
Management command for re-counting the discussions on Entry.
"""
import sys

from django.utils.encoding import smart_str
from django.core.management.base import NoArgsCommand
from django.core.management.base import BaseCommand

from zinnia.models.entry import Entry


class Command(NoArgsCommand):
class Command(BaseCommand):
"""
Command for re-counting the discussions on entries
in case of problems.
Expand All @@ -22,7 +24,7 @@ def write_out(self, message, verbosity_level=1):
sys.stdout.write(smart_str(message))
sys.stdout.flush()

def handle_noargs(self, **options):
def handle(self, *args, **options):
self.verbosity = int(options.get('verbosity', 1))
for entry in Entry.objects.all():
self.write_out('Processing %s\n' % entry.title)
Expand Down
10 changes: 6 additions & 4 deletions zinnia/management/commands/spam_cleanup.py
@@ -1,20 +1,22 @@
"""Spam cleanup command module for Zinnia"""
"""
Spam cleanup command module for Zinnia.
"""
from django.core.management.base import BaseCommand
from django.contrib.contenttypes.models import ContentType
from django.core.management.base import NoArgsCommand

import django_comments as comments

from zinnia.models.entry import Entry


class Command(NoArgsCommand):
class Command(BaseCommand):
"""
Command object for removing comments
marked as non-public and removed.
"""
help = "Delete the entries's comments marked as non-public and removed."

def handle_noargs(self, **options):
def handle(self, *args, **options):
verbosity = int(options.get('verbosity', 1))

content_type = ContentType.objects.get_for_model(Entry)
Expand Down

0 comments on commit 61fbac0

Please sign in to comment.