Make PDF upload an atomic operation
Currently if an exception is raised somewhere in the PDF processing, the database is left in an inconsistent state (wrt. the business logic) because some of the solutions have already been written to the database.
Ideally we would do first the time-consuming part (treating images etc), reading the data into pure Python data structures, and then do a tight loop where
we do all of the database writes. inside a single db_session
. This guarantees that if an exception is raised then the whole transaction is rolled back.
We either import all the solutions into the database, or none at all