minor and major reworks: rename swb to SRU, add a test for pdf parsing
major: rework mail to send mail as plaintext instead of html, preventing the bleed-in of html text
This commit is contained in:
@@ -30,10 +30,9 @@ from src.backend.db import (
|
||||
from src.errors import AppPresentError, NoResultError
|
||||
from src.logic import ELSA, Apparat, ApparatData, BookData, Prof
|
||||
from src.logic.constants import SEMAP_MEDIA_ACCOUNTS
|
||||
from src.logic.semester import Semester
|
||||
from src.utils.blob import create_blob
|
||||
|
||||
from .semester import Semester
|
||||
|
||||
log = loguru.logger
|
||||
log.remove()
|
||||
log.add(sys.stdout, level="INFO")
|
||||
@@ -1873,7 +1872,7 @@ class Database:
|
||||
Returns:
|
||||
list[tuple]: A list of tuples containing the new editions data
|
||||
"""
|
||||
query = "SELECT * FROM neweditions WHERE for_apparat=?"
|
||||
query = "SELECT * FROM neweditions WHERE for_apparat=? AND ordered=0"
|
||||
results = self.query_db(query, (apparat_id,))
|
||||
res = []
|
||||
for result in results:
|
||||
@@ -1887,9 +1886,25 @@ class Database:
|
||||
query = "UPDATE neweditions SET ordered=1 WHERE id=?"
|
||||
self.query_db(query, (newBook_id,))
|
||||
|
||||
def getBooksWithNewEditions(self, app_id) -> List[BookData]:
|
||||
# select all bookdata from media, based on the old_edition_id in neweditions where for_apparat = app_id; also get the new_edition bookdata
|
||||
|
||||
query = "SELECT m.bookdata, new_bookdata FROM media m JOIN neweditions n ON m.id = n.old_edition_id WHERE n.for_apparat = ?"
|
||||
results = self.query_db(query, (app_id,))
|
||||
# store results in tuple old,new
|
||||
res = []
|
||||
for result in results:
|
||||
oldedition = BookData().from_string(result[0])
|
||||
newedition = BookData().from_string(result[1])
|
||||
res.append((oldedition, newedition))
|
||||
return res
|
||||
|
||||
def getNewEditionId(self, newBook: BookData):
|
||||
query = "SELECT id FROM neweditions WHERE new_bookdata=?"
|
||||
params = (newBook.to_dict,)
|
||||
query = "SELECT id FROM neweditions WHERE new_bookdata LIKE ?"
|
||||
args = (
|
||||
newBook.isbn[0] if newBook.isbn and len(newBook.isbn) > 0 else newBook.ppn
|
||||
)
|
||||
params = (f"%{args}%",)
|
||||
data = self.query_db(query, params, one=True)
|
||||
if data:
|
||||
return data[0]
|
||||
@@ -1897,6 +1912,14 @@ class Database:
|
||||
return None
|
||||
|
||||
def insertNewEdition(self, newBook: BookData, oldBookId: int, for_apparat: int):
|
||||
# check if new edition already in table, check based on newBook.ppn
|
||||
check_query = "SELECT id FROM neweditions WHERE new_bookdata LIKE ?"
|
||||
check_params = (f"%{newBook.ppn}%",)
|
||||
data = self.query_db(check_query, check_params, one=True)
|
||||
if data:
|
||||
log.info("New edition already in table, skipping insert")
|
||||
return
|
||||
|
||||
query = "INSERT INTO neweditions (new_bookdata, old_edition_id, for_apparat) VALUES (?,?,?)"
|
||||
params = (newBook.to_dict, oldBookId, for_apparat)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user