mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Added the Renderable mixin because DRY
This commit is contained in:
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user