diff --git a/Web/app.py b/Web/app.py index 967c23d..26c3bdb 100755 --- a/Web/app.py +++ b/Web/app.py @@ -3589,40 +3589,41 @@ def api_item_detail(item_id): except Exception: return str(dt) if dt else '' - # Build HTML for borrow records (if any) borrows_html = '' if borrow_records: rows = [] for rec in borrow_records: user_raw = rec.get('User') try: - # FIX: Cast to string before decrypting - user = decrypt_text(str(user_raw)) if user_raw is not None else '' + user = decrypt_text(user_raw) if user_raw is not None else '' except Exception: - # FIX: Ensure the fallback is also a string for html.escape - user = str(user_raw) if user_raw is not None else '' - + user = user_raw status = rec.get('Status', '') start = fmt_dt(rec.get('Start')) end = fmt_dt(rec.get('End')) notes = html.escape(str(rec.get('Notes') or '')) - rows.append(f"
  • {html.escape(user or '-')} — {html.escape(status)} — {html.escape(start)} → {html.escape(end)}{(' — ' + notes) if notes else ''}
  • ") + rows.append( + f"
  • {html.escape(str(user or '-'))} — " + f"{html.escape(str(status))} — " + f"{html.escape(str(start))} → {html.escape(str(end))}" + f"{(' — ' + notes) if notes else ''}
  • " + ) borrows_html = f"

    Ausleihhistorie

    " - # Basic detail HTML detail_html = f""" -

    {html.escape(item.get('Name', 'Untitled'))}

    -

    ISBN: {html.escape(item.get('ISBN', item.get('Code4', '-')))}

    -

    Anzahl: {html.escape(item.get('SeriesCount', '-'))}

    -

    Ort: {html.escape(item.get('Ort', '-'))}

    -

    Typ: {html.escape(item.get('ItemType', '-'))}

    -

    Kategorie: {html.escape(item.get('library_category', '-'))}

    -

    Beschreibung: {html.escape(item.get('Beschreibung', '-'))}

    -

    Status: {html.escape(status_label)}

    - {f'

    Ausgeliehen von: {html.escape(borrower_value)}

    ' if borrower_value and status_label == 'Ausgeliehen' else ''} +

    {html.escape(str(item.get('Name', 'Untitled')))}

    +

    ISBN: {html.escape(str(item.get('ISBN', item.get('Code4', '-'))))}

    +

    Anzahl: {html.escape(str(item.get('SeriesCount', '-')))}

    +

    Ort: {html.escape(str(item.get('Ort', '-')))}

    +

    Typ: {html.escape(str(item.get('ItemType', '-')))}

    +

    Kategorie: {html.escape(str(item.get('library_category', '-')))}

    +

    Beschreibung: {html.escape(str(item.get('Beschreibung', '-')))}

    +

    Status: {html.escape(str(status_label))}

    + {f'

    Ausgeliehen von: {html.escape(str(borrower_value))}

    ' if borrower_value and status_label == 'Ausgeliehen' else ''} {borrows_html} """ + client.close() return detail_html, 200 except Exception as e: @@ -5158,7 +5159,6 @@ def upload_item(): item_type_input = sanitize_form_value(request.form.get('item_type_input', '')) library_category = sanitize_form_value(request.form.get('library_category', '')) - app.logger.info(f"Upload attempt by {encrypt_text(username)}: name={name!r}, ort={ort!r}, beschreibung length={len(beschreibung)}, images count={len(images)}, filters={filter_upload}, filters2={filter_upload2}, filters3={filter_upload3}, anschaffungs_jahr={anschaffungs_jahr}, anschaffungs_kosten={anschaffungs_kosten}, code_4={code_4}, isbn={isbn_raw!r}, upload_mode={upload_mode!r}, item_count={item_count_raw!r}, item_type_input={item_type_input!r}, individual_codes={individual_codes_raw!r}") try: item_count = int(item_count_raw) if item_count_raw else 1 except (TypeError, ValueError): @@ -5170,14 +5170,12 @@ def upload_item(): if individual_codes_raw: individual_codes = [c.strip() for c in str(individual_codes_raw).replace(',', '\n').splitlines() if c.strip()] - app.logger.info(f"DEBUG: Parsed individual codes: {individual_codes}, count: {len(individual_codes)}") # Check if this is a duplication is_duplicating = request.form.get('is_duplicating') == 'true' # Get duplicate_images if duplicating duplicate_images = request.form.getlist('duplicate_images') if is_duplicating else [] - print(f"DEBUG: Duplicate images from form: {duplicate_images}, count: {len(duplicate_images)}") # Make sure duplicate_images is always a list, even if there's only one if is_duplicating and duplicate_images and not isinstance(duplicate_images, list): @@ -5287,8 +5285,6 @@ def upload_item(): for c in extra_codes: if c not in all_item_codes: all_item_codes.append(c) - - app.logger.info(f"DEBUG: Unified item codes: {all_item_codes}, total count: {len(all_item_codes)}") # ------------------------------------------------------------------- # 2. OVERRIDE ITEM COUNT @@ -6010,9 +6006,6 @@ def upload_item(): else: app.logger.warning(f"Book cover image not found: {book_cover_image}") - # Log image processing stats - app.logger.info(f"Upload stats: processed={processed_count}, errors={error_count}, skipped={skipped_count}, duplicates={len(duplicate_images) if duplicate_images else 0}") - # If location is not in the predefined list, add it predefined_locations = it.get_predefined_locations() if ort and ort not in predefined_locations: