Esempio n. 1
0
    def create_classification(self):

        sess = Database().session()

        sess.add(
            DBClassification(
                created_at=self.created_at,
                result=self.result,
            ))

        sess.commit()
        sess.close()
from database.document import Document
from database.consultee import Consultee

from service.downloader import Downloader
from service.document_parser import DocumentParser
from service.database import Database
from service.file_manager import FileManager
from io import BytesIO

RESET_DB = False
RESET_FILES = False

if RESET_DB:
    Database.delete_all(Consultee)
    Database.commit()
    print(f'Emptied the consultee table.\n')

saved_documents = Document.query.filter(Document.type == 'consultee_list')

for document in saved_documents:
    if not RESET_DB and document.consultee_list != []:
        print(f'Consultees for remiss {document.remiss_id} already saved.')
        continue
    elif RESET_DB:
        Consultee.query.filter(
                Consultee.consultee_list_id == document.id
                              ).delete()

    filepath = f'tmp/{document.remiss_id}/{document.id}.pdf'