Added the Renderable mixin because DRY

This commit is contained in:
Daniel Quinn
2016-02-11 22:05:38 +00:00
parent ef1639208c
commit 7aadab23cc
5 changed files with 27 additions and 23 deletions

View File

@@ -7,9 +7,10 @@ from django.core.management.base import BaseCommand, CommandError
from ...consumer import Consumer, ConsumerError
from ...mail import MailFetcher, MailFetcherError
from ...mixins import Renderable
class Command(BaseCommand):
class Command(Renderable, BaseCommand):
"""
On every iteration of an infinite loop, consume what we can from the
consumption directory, and fetch any mail available.
@@ -62,7 +63,3 @@ class Command(BaseCommand):
delta = self.mail_fetcher.last_checked + self.MAIL_DELTA
if delta > datetime.datetime.now():
self.mail_fetcher.pull()
def _render(self, text, verbosity):
if self.verbosity >= verbosity:
print(text)

View File

@@ -8,8 +8,10 @@ from django.core.management.base import BaseCommand, CommandError
from documents.models import Document
from paperless.db import GnuPG
from ...mixins import Renderable
class Command(BaseCommand):
class Command(Renderable, BaseCommand):
help = """
Decrypt and rename all files in our collection into a given target
@@ -50,7 +52,3 @@ class Command(BaseCommand):
f.write(GnuPG.decrypted(document.source_file))
t = int(time.mktime(document.created.timetuple()))
os.utime(target, times=(t, t))
def _render(self, text, verbosity):
if self.verbosity >= verbosity:
print(text)

View File

@@ -2,8 +2,10 @@ from django.core.management.base import BaseCommand
from documents.models import Document, Tag
from ...mixins import Renderable
class Command(BaseCommand):
class Command(Renderable, BaseCommand):
help = """
Using the current set of tagging rules, apply said rules to all
@@ -28,7 +30,3 @@ class Command(BaseCommand):
self._render(
'Tagging {} with "{}"'.format(document, tag), 1)
document.tags.add(tag)
def _render(self, text, verbosity):
if self.verbosity >= verbosity:
print(text)