django_ocr_server/models.py
def ttl():
        """
        Removes all instances of OCRedFile whose OCRedFile.uploaded+OCR_TTL lower current datetime
             if OCR_TTL does not 0, (NOTE: if OCR_TTL<0 all instances of OCRedFile will be removed, use only for tests).
        Removes all OCRedFile.files whose OCRedFile.uploaded+OCR_FILES_TTL lower current datetime
             if OCR_FILES_TTL does not 0,
             (NOTE: if OCR_FILES_TTL<0 all OCRedFile.files will be removed, use only for tests).
        Removes all OCRedFile.ocred_pdfs whose OCRedFile.uploaded+OCR_PDF_TTL lower current datetime
             if OCR_PDF_TTL does not 0,
             (NOTE: if OCR_PDF_TTL<0 all OCRedFile.ocred_pdfs will be removed, use only for tests). 2019-04-13
        :return: (removed OCRedFiles counter, removed OCRedFile.files counter, removed OCRedFile.ocred_pdfs counter)
        """
        ttl = getattr(settings, 'OCR_TTL', ocr_default_settings.TTL)
        files_ttl = getattr(settings, 'OCR_FILES_TTL', ocr_default_settings.FILES_TTL)
        pdf_ttl = getattr(settings, 'OCR_PDF_TTL', ocr_default_settings.PDF_TTL)
        current_datetime = timezone.now()
        counter = 0
        files_counter = 0
        pdf_counter = 0
        if ttl != 0:
            removing_datetime = current_datetime - ttl
            for ocred_file in OCRedFile.objects.filter(uploaded__lt=removing_datetime):
                ocred_file.delete()
                counter += 1
        if files_ttl != 0:
            files_removing_datetime = current_datetime - files_ttl
            for ocred_file in OCRedFile.objects.filter(uploaded__lt=files_removing_datetime):
                ocred_file.remove_file()
                files_counter += 1
        if pdf_ttl != 0:
            pdf_removing_datetime = current_datetime - pdf_ttl
            for ocred_file in OCRedFile.objects.filter(uploaded__lt=pdf_removing_datetime):
                ocred_file.remove_pdf()
                pdf_counter += 1
        return counter, files_counter, pdf_counter

        Removes all instances of OCRedFile whose OCRedFile.uploaded+OCR_TTL lower current datetime
             if OCR_TTL does not 0, (NOTE: if OCR_TTL<0 all instances of OCRedFile will be removed, use only for tests).
        Removes all OCRedFile.files whose OCRedFile.uploaded+OCR_FILES_TTL lower current datetime
             if OCR_FILES_TTL does not 0,
             (NOTE: if OCR_FILES_TTL<0 all OCRedFile.files will be removed, use only for tests).
        Removes all OCRedFile.ocred_pdfs whose OCRedFile.uploaded+OCR_PDF_TTL lower current datetime
             if OCR_PDF_TTL does not 0,
             (NOTE: if OCR_PDF_TTL<0 all OCRedFile.ocred_pdfs will be removed, use only for tests). 2019-04-13
        :return: (removed OCRedFiles counter, removed OCRedFile.files counter, removed OCRedFile.ocred_pdfs counter)
        
Removes all instances of OCRedFile whose OCRedFile.uploaded+OCR_TTL lower current datetime
if OCR_TTL does not 0, (NOTE: if OCR_TTL<0 all instances of OCRedFile will be removed, use only for tests).
Removes all OCRedFile.files whose OCRedFile.uploaded+OCR_FILES_TTL lower current datetime
if OCR_FILES_TTL does not 0,
(NOTE: if OCR_FILES_TTL<0 all OCRedFile.files will be removed, use only for tests).
Removes all instances of OCRedFile whose OCRedFile . uploaded + OCR_TTL lower current datetime if OCR_TTL does not 0 ( NOTE : if OCR_TTL<0 all instances of OCRedFile will be removed use only for tests ) . Removes all OCRedFile . files whose OCRedFile . uploaded + OCR_FILES_TTL lower current datetime if OCR_FILES_TTL does not 0 ( NOTE : if OCR_FILES_TTL<0 all OCRedFile . files will be removed use only for tests ) .
def ttl():
        ttl = getattr(settings, 'OCR_TTL', ocr_default_settings.TTL)
        files_ttl = getattr(settings, 'OCR_FILES_TTL', ocr_default_settings.FILES_TTL)
        pdf_ttl = getattr(settings, 'OCR_PDF_TTL', ocr_default_settings.PDF_TTL)
        current_datetime = timezone.now()
        counter = 0
        files_counter = 0
        pdf_counter = 0
        if ttl != 0:
            removing_datetime = current_datetime - ttl
            for ocred_file in OCRedFile.objects.filter(uploaded__lt=removing_datetime):
                ocred_file.delete()
                counter += 1
        if files_ttl != 0:
            files_removing_datetime = current_datetime - files_ttl
            for ocred_file in OCRedFile.objects.filter(uploaded__lt=files_removing_datetime):
                ocred_file.remove_file()
                files_counter += 1
        if pdf_ttl != 0:
            pdf_removing_datetime = current_datetime - pdf_ttl
            for ocred_file in OCRedFile.objects.filter(uploaded__lt=pdf_removing_datetime):
                ocred_file.remove_pdf()
                pdf_counter += 1
        return counter, files_counter, pdf_counter
def ttl ( ) : ttl = getattr ( settings , 'OCR_TTL' , ocr_default_settings . TTL ) files_ttl = getattr ( settings , 'OCR_FILES_TTL' , ocr_default_settings . FILES_TTL ) pdf_ttl = getattr ( settings , 'OCR_PDF_TTL' , ocr_default_settings . PDF_TTL ) current_datetime = timezone . now ( ) counter = 0 files_counter = 0 pdf_counter = 0 if ttl != 0 : removing_datetime = current_datetime - ttl for ocred_file in OCRedFile . objects . filter ( uploaded__lt = removing_datetime ) : ocred_file . delete ( ) counter += 1 if files_ttl != 0 : files_removing_datetime = current_datetime - files_ttl for ocred_file in OCRedFile . objects . filter ( uploaded__lt = files_removing_datetime ) : ocred_file . remove_file ( ) files_counter += 1 if pdf_ttl != 0 : pdf_removing_datetime = current_datetime - pdf_ttl for ocred_file in OCRedFile . objects . filter ( uploaded__lt = pdf_removing_datetime ) : ocred_file . remove_pdf ( ) pdf_counter += 1 return counter , files_counter , pdf_counter
Removes all instances of OCRedFile whose OCRedFile.uploaded+OCR_TTL lower current datetime
if OCR_TTL does not 0, (NOTE: if OCR_TTL<0 all instances of OCRedFile will be removed, use only for tests).
Removes all instances of OCRedFile whose OCRedFile . uploaded + OCR_TTL lower current datetime if OCR_TTL does not 0 ( NOTE : if OCR_TTL<0 all instances of OCRedFile will be removed use only for tests ) .
"""
        Removes all instances of OCRedFile whose OCRedFile.uploaded+OCR_TTL lower current datetime
             if OCR_TTL does not 0, (NOTE: if OCR_TTL<0 all instances of OCRedFile will be removed, use only for tests).
        Removes all OCRedFile.files whose OCRedFile.uploaded+OCR_FILES_TTL lower current datetime
             if OCR_FILES_TTL does not 0,
             (NOTE: if OCR_FILES_TTL<0 all OCRedFile.files will be removed, use only for tests).
        Removes all OCRedFile.ocred_pdfs whose OCRedFile.uploaded+OCR_PDF_TTL lower current datetime
             if OCR_PDF_TTL does not 0,
             (NOTE: if OCR_PDF_TTL<0 all OCRedFile.ocred_pdfs will be removed, use only for tests). 2019-04-13
        :return: (removed OCRedFiles counter, removed OCRedFile.files counter, removed OCRedFile.ocred_pdfs counter)
        """
(removed OCRedFiles counter, removed OCRedFile.files counter, removed OCRedFile.ocred_pdfs counter)
( removed OCRedFiles counter removed OCRedFile . files counter removed OCRedFile . ocred_pdfs counter )