Everything appears to be working

This commit is contained in:
Daniel Quinn
2016-03-28 19:47:11 +01:00
parent 40b2ea02b7
commit cb2df58b27
6 changed files with 98 additions and 2 deletions

View File

@@ -8,9 +8,11 @@ class DocumentsConfig(AppConfig):
def ready(self):
from .signals import document_consumption_finished
from .signals.handlers import set_correspondent, set_tags
from .signals.handlers import (
set_correspondent, set_tags, run_external_script)
document_consumption_finished.connect(set_tags)
document_consumption_finished.connect(set_correspondent)
document_consumption_finished.connect(run_external_script)
AppConfig.ready(self)

View File

@@ -1,5 +1,9 @@
import logging
from subprocess import Popen
from django.conf import settings
from ..models import Correspondent, Tag
@@ -51,3 +55,21 @@ def set_tags(sender, document=None, logging_group=None, **kwargs):
)
document.tags.add(*relevant_tags)
def run_external_script(sender, document, **kwargs):
if not settings.POST_CONSUME_SCRIPT:
return
Popen((
settings.POST_CONSUME_SCRIPT,
document.file_name,
document.source_path,
document.thumbnail_path,
document.download_url,
document.thumbnail_url,
str(document.id),
str(document.correspondent),
str(",".join(document.tags.all().values_list("slug", flat=True)))
)).wait()