Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2421f867ed | |||
| 921915e92f | |||
| a4b0866293 | |||
| e10d86da4b | |||
| f160f23e9c | |||
| ca272542de | |||
| 7df9b65389 | |||
| e4af76c9c1 | |||
| f5944bf090 | |||
| 4e68da2368 | |||
| 0d6aca4e8c | |||
| 2bb0cbe599 | |||
| 339487b4d4 | |||
| 3f90e2d4f1 | |||
| b238b52fbf |
+1
-2
@@ -8,5 +8,4 @@ INVENTAR_APP_MEM_SWAP_LIMIT=768m
|
||||
INVENTAR_WORKERS=4
|
||||
INVENTAR_THREADS=2
|
||||
INVENTAR_WORKER_TIMEOUT=30
|
||||
INVENTAR_WORKER_CONNECTIONS=100
|
||||
|
||||
INVENTAR_WORKER_CONNECTIONS=100
|
||||
@@ -1,5 +1,7 @@
|
||||
services:
|
||||
app:
|
||||
working_dir: /app/Web
|
||||
command: ["gunicorn", "app:app", "--bind", "0.0.0.0:8000", "--workers", "4", "--threads", "2", "--timeout", "30", "--graceful-timeout", "20", "--worker-connections", "100", "--max-requests", "1000", "--max-requests-jitter", "100", "--log-level", "info", "--access-logfile", "-", "--error-logfile", "-"]
|
||||
image: ghcr.io/aiirondev/legendary-octo-garbanzo:v0.7.42
|
||||
build: null
|
||||
ports:
|
||||
|
||||
+122
-49
@@ -26,7 +26,6 @@ from jinja2 import TemplateNotFound
|
||||
import os
|
||||
import sys
|
||||
from bs4 import BeautifulSoup
|
||||
import requests
|
||||
|
||||
# Ensure imports work regardless of whether gunicorn starts in /app or /app/Web.
|
||||
_CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
@@ -1737,7 +1736,6 @@ def is_valid_isbn13(isbn13):
|
||||
check_digit = (10 - (checksum % 10)) % 10
|
||||
return check_digit == int(isbn13[12])
|
||||
|
||||
|
||||
def normalize_and_validate_isbn(isbn_raw):
|
||||
"""Normalize ISBN and return a valid canonical ISBN-13/10 or empty string."""
|
||||
isbn = normalize_isbn(isbn_raw)
|
||||
@@ -1997,7 +1995,7 @@ def _upload_student_cards_excel():
|
||||
synonyms = {
|
||||
'ausweis_id': ['ausweis_id', 'ausweisid', 'ausweis-id', 'karte', 'kartennummer', 'card_id', 'id'],
|
||||
'student_name': ['student_name', 'schuelername', 'schülername', 'schueler', 'schüler', 'name', 'vollname', 'vorname_nachname', 'nachname_vorname'],
|
||||
'first_name': ['vorname', 'first_name', 'firstname'],
|
||||
'first_name': ['vorname', 'first_name', 'firstname', 'rufname'],
|
||||
'last_name': ['nachname', 'last_name', 'lastname'],
|
||||
'class_name': ['klasse', 'class', 'class_name', 'jahrgang', 'jahrgangsstufe', 'stufe', 'gruppe', 'asv_klasse'],
|
||||
'notes': ['notizen', 'notes', 'bemerkungen', 'bemerkung', 'hinweis', 'hinweise'],
|
||||
@@ -4125,10 +4123,13 @@ def student_card_barcode_download():
|
||||
c.setLineWidth(2)
|
||||
c.line(x_pos, y_pos - 10*mm, x_pos + card_width, y_pos - 10*mm)
|
||||
|
||||
|
||||
school_name = cfg.get_school_info()
|
||||
school_name = school_name["name"]
|
||||
# "SCHÜLERAUSWEIS" text in header
|
||||
c.setFont("Helvetica-Bold", 9)
|
||||
c.setFillColor(white)
|
||||
c.drawString(x_pos + 3*mm, y_pos - 6.5*mm, "SCHÜLERAUSWEIS")
|
||||
c.drawString(x_pos + 3*mm, y_pos - 6.5*mm, f"SCHÜLERAUSWEIS - {str(school_name)}")
|
||||
|
||||
# Student name - large and bold
|
||||
c.setFillColor(text_dark)
|
||||
@@ -4152,7 +4153,11 @@ def student_card_barcode_download():
|
||||
c.setFillColor(text_dark)
|
||||
c.setFont("Helvetica-Bold", 9)
|
||||
c.drawString(x_pos + 3*mm, y_pos - 28*mm, card['Klasse'])
|
||||
|
||||
c.drawString(x_pos + 3*mm, y_pos - 31*mm, "-")
|
||||
c.drawString(x_pos + 3*mm, y_pos - 34*mm, "-")
|
||||
c.drawString(x_pos + 3*mm, y_pos - 37*mm, "-")
|
||||
c.drawString(x_pos + 3*mm, y_pos - 40*mm, "-")
|
||||
|
||||
# Right barcode section with border highlight
|
||||
barcode_x_start = x_pos + info_width + 1*mm
|
||||
c.setFillColor(accent_color)
|
||||
@@ -4292,10 +4297,12 @@ def student_card_single_barcode_download(card_id):
|
||||
c.setLineWidth(2.5)
|
||||
c.line(x_pos, y_pos - 10*mm, x_pos + card_width, y_pos - 10*mm)
|
||||
|
||||
school_name = cfg.get_school_info()
|
||||
school_name = school_name["name"]
|
||||
# "SCHÜLERAUSWEIS" text in header
|
||||
c.setFont("Helvetica-Bold", 11)
|
||||
c.setFillColor(white)
|
||||
c.drawString(x_pos + 4*mm, y_pos - 6.5*mm, "SCHÜLERAUSWEIS")
|
||||
c.drawString(x_pos + 4*mm, y_pos - 6.5*mm, f"SCHÜLERAUSWEIS - {str(school_name)}")
|
||||
|
||||
# Student name - large and prominent
|
||||
c.setFillColor(text_dark)
|
||||
@@ -5108,6 +5115,7 @@ def upload_item():
|
||||
upload_mode = sanitize_form_value(request.form.get('upload_mode', 'item'))
|
||||
individual_codes_raw = sanitize_form_value(request.form.get('individual_codes', ''))
|
||||
item_count_raw = sanitize_form_value(request.form.get('item_count', '1'))
|
||||
item_type_input = sanitize_form_value(request.form.get('item_type_input', ''))
|
||||
|
||||
try:
|
||||
item_count = int(item_count_raw) if item_count_raw else 1
|
||||
@@ -5187,6 +5195,8 @@ def upload_item():
|
||||
item_isbn = isbn_raw
|
||||
if upload_mode == 'library':
|
||||
item_type = 'book'
|
||||
if item_type_input != "":
|
||||
item_type = item_type_input
|
||||
|
||||
if upload_mode == 'library':
|
||||
if not cfg.MODULES.is_enabled('library'):
|
||||
@@ -9543,70 +9553,125 @@ def _fetch_from_open_library(clean_isbn):
|
||||
|
||||
def _fetch_from_isbn_de(clean_isbn):
|
||||
"""
|
||||
Source 4: isbn.de (Web Scraping für deutsche Schulbücher)
|
||||
Sehr gute Trefferquote für Klett, Cornelsen, Westermann etc.
|
||||
Source 4: isbn.de (Maßgeschneidertes Scraping basierend auf realem HTML)
|
||||
Extrahiert alle Buchdaten inklusive Preise aus den Meta-Tags und der Sidebar.
|
||||
"""
|
||||
try:
|
||||
# Die URL leitet meist automatisch auf den richtigen Buch-Slug weiter
|
||||
url = f"https://www.isbn.de/buch/{clean_isbn}"
|
||||
|
||||
# Ein User-Agent ist wichtig, da Webseiten simple Python-Scripte oft blockieren
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
||||
}
|
||||
|
||||
response = requests.get(url, headers=headers, timeout=5)
|
||||
|
||||
if response.status_code != 200:
|
||||
return None
|
||||
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
|
||||
# Prüfen, ob wirklich ein Buch gefunden wurde
|
||||
# (isbn.de wirft manchmal keinen 404, sondern zeigt eine Suchseite ohne Treffer)
|
||||
title_elem = soup.find('h1')
|
||||
if not title_elem or "nicht gefunden" in title_elem.text.lower() or "Suche" in title_elem.text:
|
||||
# 1. Titel aus Meta-Tags extrahieren (extrem zuverlässig)
|
||||
title_meta = soup.find('meta', property='og:title')
|
||||
title = title_meta.get('content', '').strip() if title_meta else None
|
||||
if not title:
|
||||
h1_elem = soup.find('h1')
|
||||
title = h1_elem.text.strip() if h1_elem else "Unknown Title"
|
||||
|
||||
# Falls Fehler- oder Suchseite
|
||||
if "nicht gefunden" in title.lower() or "suche" in title.lower():
|
||||
return None
|
||||
|
||||
title = title_elem.text.strip()
|
||||
|
||||
# --- Hilfsfunktion zum Parsen der .infotab-Sidebar-Struktur ---
|
||||
def get_sidebar_value(keyword):
|
||||
infotab = soup.find(class_='infotab')
|
||||
if infotab:
|
||||
for d in infotab.find_all('div'):
|
||||
if d.text.strip().lower() == keyword.lower():
|
||||
parent = d.parent
|
||||
# Label vom Gesamttext abziehen, um nur den Wert zu erhalten
|
||||
return parent.text.replace(d.text, '', 1).strip()
|
||||
return None
|
||||
|
||||
# 2. Verlag holen
|
||||
publisher = get_sidebar_value('verlag')
|
||||
if not publisher:
|
||||
publisher = "Unknown Publisher"
|
||||
|
||||
# 3. Erscheinungsdatum (Aus Meta-Tag oder Sidebar)
|
||||
date_meta = soup.find('meta', property='og:book:release_date')
|
||||
if date_meta and date_meta.get('content'):
|
||||
published_date = date_meta.get('content', '').strip()
|
||||
else:
|
||||
published_date = get_sidebar_value('erschienen am')
|
||||
|
||||
# isbn.de nutzt oft Schema.org Tags (itemprop), was das Auslesen sehr sicher macht
|
||||
authors = "Unknown Author"
|
||||
author_elem = soup.find(itemprop="author")
|
||||
if author_elem:
|
||||
authors = author_elem.text.strip()
|
||||
|
||||
publisher = "Unknown Publisher"
|
||||
publisher_elem = soup.find(itemprop="publisher")
|
||||
if publisher_elem:
|
||||
publisher = publisher_elem.text.strip()
|
||||
|
||||
pub_date = "Unknown Date"
|
||||
date_elem = soup.find(itemprop="datePublished")
|
||||
if date_elem:
|
||||
pub_date = date_elem.text.strip()
|
||||
|
||||
if not published_date:
|
||||
published_date = "Unknown Date"
|
||||
|
||||
# 4. Autor (Da Schulbuch-Workbooks oft keinen Einzelautor haben, kluger Fallback)
|
||||
author_meta = soup.find('meta', property='og:book:author')
|
||||
author = author_meta.get('content', '').strip() if author_meta else ""
|
||||
if not author:
|
||||
author = get_sidebar_value('autor') or get_sidebar_value('herausgeber')
|
||||
|
||||
if not author:
|
||||
author = f"{publisher} Redaktion" if publisher != "Unknown Publisher" else "Unknown Author"
|
||||
|
||||
# 5. Seitenanzahl
|
||||
page_count = get_sidebar_value('seiten') or get_sidebar_value('umfang')
|
||||
if page_count:
|
||||
match = re.search(r'\d+', page_count)
|
||||
page_count = match.group(0) if match else "Unknown"
|
||||
else:
|
||||
page_count = "Unknown"
|
||||
|
||||
# 6. Beschreibung aus ID 'bookdesc' holen und Whitespace-Fluss säubern
|
||||
description = "Keine Beschreibung verfügbar"
|
||||
desc_elem = soup.find(itemprop="description")
|
||||
if desc_elem:
|
||||
description = desc_elem.text.strip()
|
||||
|
||||
desc_div = soup.find(id='bookdesc')
|
||||
if desc_div:
|
||||
# Holt den Text inklusive aller Listenpunkte (li) und formatiert ihn sauber
|
||||
description = " ".join(desc_div.text.split())
|
||||
|
||||
# 7. Cover-Bild (Nutzt hochauflösenden Link aus den Metas)
|
||||
thumbnail = ""
|
||||
img_elem = soup.find('img', itemprop="image")
|
||||
if img_elem and 'src' in img_elem.attrs:
|
||||
thumbnail = img_elem['src']
|
||||
# Falls der Link relativ ist (z.B. /cover/...)
|
||||
if thumbnail.startswith('/'):
|
||||
thumbnail = "https://www.isbn.de" + thumbnail
|
||||
img_meta = soup.find('meta', property='og:image')
|
||||
if img_meta:
|
||||
thumbnail = img_meta.get('content', '').strip()
|
||||
else:
|
||||
img_tag = soup.find('img', id='ISBNcover')
|
||||
if img_tag:
|
||||
thumbnail = img_tag.get('data-big') or img_tag.get('src')
|
||||
|
||||
if thumbnail and thumbnail.startswith('/'):
|
||||
thumbnail = "https://www.isbn.de" + thumbnail
|
||||
|
||||
# 8. PREIS EXTRAHIEREN (Neu integriert)
|
||||
price = None
|
||||
# Option A: Aus dem standardisierten Meta-Tag extrahieren (Ergibt z.B. 12.25)
|
||||
price_meta = soup.find('meta', property='product:price:amount')
|
||||
if price_meta and price_meta.get('content'):
|
||||
try:
|
||||
price = float(price_meta.get('content').strip())
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
# Option B: Fallback über die Infotab-Sidebar (Falls Meta fehlt, filtert "12,25 €*" zu Float)
|
||||
if price is None:
|
||||
price_str = get_sidebar_value('preis')
|
||||
if price_str:
|
||||
# Findet Zahlen wie "12,25" oder "12.25"
|
||||
match = re.search(r'\d+([.,]\d+)?', price_str)
|
||||
if match:
|
||||
try:
|
||||
price = float(match.group(0).replace(',', '.'))
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
return {
|
||||
"title": title,
|
||||
"authors": authors,
|
||||
"authors": author,
|
||||
"publisher": publisher,
|
||||
"publishedDate": pub_date,
|
||||
"publishedDate": published_date,
|
||||
"description": description,
|
||||
"pageCount": "Unknown", # Seitenanzahl ist oft nicht standardisiert hinterlegt
|
||||
"price": None,
|
||||
"pageCount": page_count,
|
||||
"price": price, # Gibt nun z.B. 12.25 als float zurück
|
||||
"thumbnail": thumbnail,
|
||||
"source": "isbn-de"
|
||||
}
|
||||
@@ -10206,10 +10271,18 @@ def notifications_unread_status():
|
||||
@app.route('/admin/damaged_items')
|
||||
def admin_damaged_items():
|
||||
"""Dedicated admin management window for damaged items."""
|
||||
if 'username' not in session or not us.check_admin(session['username']):
|
||||
if 'username' not in session:
|
||||
flash('Administratorrechte erforderlich.', 'error')
|
||||
return redirect(url_for('login'))
|
||||
|
||||
'''
|
||||
permissions = _get_current_user_permissions()
|
||||
if not _action_access_allowed(permissions, 'can_manage_settings'):
|
||||
flash('Sie haben keine Berechtigung, die Schulstammdaten zu ändern.', 'error')
|
||||
if cfg.MODULES.is_enabled('library'):
|
||||
return redirect(url_for('library_admin'))
|
||||
'''
|
||||
|
||||
client = None
|
||||
try:
|
||||
client = MongoClient(MONGODB_HOST, MONGODB_PORT)
|
||||
|
||||
@@ -284,7 +284,6 @@ def _match_inventory(path):
|
||||
if path == '/' or path.startswith('/home'): return True
|
||||
return path.startswith(('/scanner', '/inventory', '/upload_admin', '/manage_filters', '/manage_locations', '/admin_borrowings', '/admin_damaged_items', '/admin/borrowings', '/admin/damaged_items'))
|
||||
|
||||
|
||||
def _match_terminplan(path):
|
||||
if not path:
|
||||
return False
|
||||
@@ -292,7 +291,7 @@ def _match_terminplan(path):
|
||||
|
||||
def _match_library(path):
|
||||
if not path: return False
|
||||
return path.startswith(('/library', '/library_', '/student_cards'))
|
||||
return path.startswith(('/library', '/library_', '/student_cards', '/admin_damaged_items', '/admin_borrowings', '/admin/library'))
|
||||
|
||||
def _match_student_cards(path):
|
||||
if not path: return False
|
||||
|
||||
@@ -432,7 +432,7 @@ def check_password_strength(password):
|
||||
|
||||
def hashing(password):
|
||||
"""
|
||||
Hash a password using SHA-512.
|
||||
Hash a password using scrypt.
|
||||
|
||||
Args:
|
||||
password (str): Password to hash
|
||||
@@ -440,7 +440,8 @@ def hashing(password):
|
||||
Returns:
|
||||
str: Hexadecimal digest of the hashed password
|
||||
"""
|
||||
return hashlib.sha512(password.encode()).hexdigest()
|
||||
hashed = hashlib.scrypt(password.encode(), salt=b'some_salt', n=16384, r=8, p=1)
|
||||
return hashed.hex()
|
||||
|
||||
|
||||
def check_nm_pwd(username, password):
|
||||
|
||||
@@ -788,7 +788,19 @@
|
||||
{% if show_library_features %}
|
||||
<!-- Library Mode: Single Customizable Filter -->
|
||||
<div class="filter-inputs">
|
||||
<h3>Kategorie/Typ (customisierbar):</h3>
|
||||
<h3>Medientyp</h3>
|
||||
<div class="form-group">
|
||||
<select name="item_type_input" id="item_type_input">
|
||||
<option value="" disabled selected>Medientyp auswählen...</option>
|
||||
<option value="Buch">Buch</option>
|
||||
<option value="Schulbuch">Schulbuch</option>
|
||||
<option value="CD">CD</option>
|
||||
<option value="DVD">DVD</option>
|
||||
<option value="Sonstiges">Sonstiges</option>
|
||||
</select>
|
||||
<small style="display:block; color:#666;">Wählen Sie einen Medientyp aus zur Klassifizierung.</small>
|
||||
</div>
|
||||
<h3>Kategorie/Typ:</h3>
|
||||
<div class="form-group">
|
||||
<input type="text" name="library_category" id="library_category" placeholder="z.B. Belletristik, Sachbücher, Nachschlagewerke, etc.">
|
||||
<small style="display:block; color:#666;">Geben Sie hier eine beliebige Kategorie ein zur freien Klassifizierung.</small>
|
||||
@@ -1563,6 +1575,7 @@
|
||||
// Get form fields
|
||||
const nameField = document.getElementById('name');
|
||||
const descriptionField = document.getElementById('beschreibung');
|
||||
const priceField = document.getElementById('anschaffungskosten'); // <-- NEU
|
||||
|
||||
if (!nameField || !descriptionField) {
|
||||
alert('Fehler: Formularfelder nicht gefunden.');
|
||||
@@ -1600,6 +1613,13 @@
|
||||
nameField.value = bookTitle;
|
||||
descriptionField.value = description;
|
||||
|
||||
// Preis in das Formularfeld eintragen
|
||||
if (priceField && currentBookData.price !== null && currentBookData.price !== undefined) {
|
||||
// Wandelt den Float (z.B. 12.25) in einen String mit Komma (12,25) um
|
||||
let formattedPrice = currentBookData.price.toString().replace('.', ',');
|
||||
priceField.value = formattedPrice;
|
||||
}
|
||||
|
||||
// Download and import book cover image if available
|
||||
if (currentBookData.thumbnail) {
|
||||
downloadBookCover(currentBookData.thumbnail);
|
||||
|
||||
Reference in New Issue
Block a user