Files
mayan-edms/mayan/apps/sources/handlers.py

43 lines
1.3 KiB
Python

from __future__ import unicode_literals
from django.db.models import get_model
from django.utils.translation import ugettext_lazy as _
from .literals import SOURCE_UNCOMPRESS_CHOICE_ASK
def create_default_document_source(sender, **kwargs):
WebFormSource = get_model('sources', 'WebFormSource')
if not WebFormSource.objects.count():
WebFormSource.objects.create(
label=_('Default'), uncompress=SOURCE_UNCOMPRESS_CHOICE_ASK
)
def copy_transformations_to_version(sender, **kwargs):
Transformation = get_model('converter', 'Transformation')
instance = kwargs['instance']
# TODO: Fix this, source should be previous version
# TODO: Fix this, shouldn't this be at the documents app
Transformation.objects.copy(
source=instance.document, targets=instance.pages.all()
)
def initialize_periodic_tasks(sender, **kwargs):
POP3Email = get_model('sources', 'POP3Email')
IMAPEmail = get_model('sources', 'IMAPEmail')
WatchFolderSource = get_model('sources', 'WatchFolderSource')
for source in POP3Email.objects.filter(enabled=True):
source.save()
for source in IMAPEmail.objects.filter(enabled=True):
source.save()
for source in WatchFolderSource.objects.filter(enabled=True):
source.save()