Changes to habe he template name right and the right correction for the library Item and a parameter mismatch
Release Inventarsystem / release-docker (push) Successful in 2m22s
Release Inventarsystem / release-docker (push) Successful in 2m22s
This commit is contained in:
+6
-8
@@ -6383,8 +6383,8 @@ def is_library_item(item):
|
|||||||
@app.route('/item_edit/<id>', methods=['GET', 'POST'])
|
@app.route('/item_edit/<id>', methods=['GET', 'POST'])
|
||||||
def item_edit(id):
|
def item_edit(id):
|
||||||
"""
|
"""
|
||||||
Complete endpoint for editing items. Processes Filters 1-3 for ALL items,
|
Endpoint for editing items. Correctly determines library vs inventory status
|
||||||
and applies Library-specific fields when the item is a Library item.
|
and renders Filter 1-3 for ALL item types.
|
||||||
"""
|
"""
|
||||||
if 'username' not in session:
|
if 'username' not in session:
|
||||||
if request.method == 'POST' and request.is_json:
|
if request.method == 'POST' and request.is_json:
|
||||||
@@ -6435,8 +6435,9 @@ def item_edit(id):
|
|||||||
|
|
||||||
current_item['IndividualCodes'] = '\n'.join(individual_codes)
|
current_item['IndividualCodes'] = '\n'.join(individual_codes)
|
||||||
|
|
||||||
|
# FIXED: Changed 'edit_library.html' to 'item_edit.html'
|
||||||
return render_template(
|
return render_template(
|
||||||
'edit_library.html',
|
'item_edit.html',
|
||||||
username=session['username'],
|
username=session['username'],
|
||||||
item=current_item,
|
item=current_item,
|
||||||
show_library_features=show_library_features,
|
show_library_features=show_library_features,
|
||||||
@@ -6499,19 +6500,17 @@ def item_edit(id):
|
|||||||
|
|
||||||
# Type-specific processing
|
# Type-specific processing
|
||||||
if show_library_features:
|
if show_library_features:
|
||||||
# --- LIBRARY ITEM SPECIFICS ---
|
|
||||||
isbn_raw = sanitize_form_value(request.form.get('isbn', ''))
|
isbn_raw = sanitize_form_value(request.form.get('isbn', ''))
|
||||||
item_isbn = normalize_and_validate_isbn(isbn_raw) if isbn_raw else ''
|
item_isbn = normalize_and_validate_isbn(isbn_raw) if isbn_raw else ''
|
||||||
item_type = sanitize_form_value(request.form.get('item_type_input', 'Buch'))
|
item_type = sanitize_form_value(request.form.get('item_type_input', 'Buch'))
|
||||||
library_category = sanitize_form_value(request.form.get('library_category', ''))
|
library_category = sanitize_form_value(request.form.get('library_category', ''))
|
||||||
images = current_item.get('Images', [])
|
images = current_item.get('Images', [])
|
||||||
else:
|
else:
|
||||||
# --- INVENTORY ITEM SPECIFICS ---
|
|
||||||
item_isbn = current_item.get('ISBN', '')
|
item_isbn = current_item.get('ISBN', '')
|
||||||
item_type = 'other'
|
item_type = 'other'
|
||||||
library_category = current_item.get('library_category', '')
|
library_category = current_item.get('library_category', '')
|
||||||
|
|
||||||
# Manage images for Inventory Mode
|
# Manage images for Inventory Items
|
||||||
images_to_keep = request.form.getlist('existing_images')
|
images_to_keep = request.form.getlist('existing_images')
|
||||||
original_images = current_item.get('Images', [])
|
original_images = current_item.get('Images', [])
|
||||||
images = [img for img in original_images if img in images_to_keep]
|
images = [img for img in original_images if img in images_to_keep]
|
||||||
@@ -6552,7 +6551,7 @@ def item_edit(id):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
app.logger.error(f"Image error for item {id}: {e}")
|
app.logger.error(f"Image error for item {id}: {e}")
|
||||||
|
|
||||||
# Auto-add location to predefined locations list if applicable
|
# Auto-add location if applicable
|
||||||
if ort and ort not in it.get_predefined_locations():
|
if ort and ort not in it.get_predefined_locations():
|
||||||
it.add_predefined_location(ort)
|
it.add_predefined_location(ort)
|
||||||
|
|
||||||
@@ -6586,7 +6585,6 @@ def item_edit(id):
|
|||||||
|
|
||||||
return redirect(redirect_target)
|
return redirect(redirect_target)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/update_group', methods=['POST'])
|
@app.route('/update_group', methods=['POST'])
|
||||||
def update_group():
|
def update_group():
|
||||||
|
|
||||||
|
|||||||
@@ -30,15 +30,22 @@ import Web.modules.inventarsystem.data_protection as dp
|
|||||||
def is_library_item(item):
|
def is_library_item(item):
|
||||||
"""
|
"""
|
||||||
Determines if an item belongs to the library system.
|
Determines if an item belongs to the library system.
|
||||||
Returns False for 'other', None, or empty ItemType (Inventory item).
|
Prioritizes explicit 'is_library' boolean field from MongoDB if set.
|
||||||
Returns True for any specific library type ('Buch', 'CD', 'DVD', etc.).
|
|
||||||
"""
|
"""
|
||||||
if not item:
|
if not item:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# 1. Check explicit boolean flag from MongoDB first
|
||||||
|
if 'is_library' in item and item['is_library'] is not None:
|
||||||
|
return bool(item['is_library'])
|
||||||
|
|
||||||
|
# 2. Fallback to ItemType check
|
||||||
item_type = item.get('ItemType', 'other')
|
item_type = item.get('ItemType', 'other')
|
||||||
if not item_type:
|
if not item_type:
|
||||||
return False
|
return False
|
||||||
return str(item_type).strip().lower() != 'other'
|
|
||||||
|
clean_type = str(item_type).strip().lower()
|
||||||
|
return clean_type not in ['other', 'general', '']
|
||||||
|
|
||||||
def safe_decrypt_user(encrypted_user):
|
def safe_decrypt_user(encrypted_user):
|
||||||
"""
|
"""
|
||||||
@@ -264,7 +271,10 @@ def get_group_item_ids(id):
|
|||||||
|
|
||||||
|
|
||||||
def update_item(id, name, ort, beschreibung, images, verfuegbar, filter1, filter2, filter3,
|
def update_item(id, name, ort, beschreibung, images, verfuegbar, filter1, filter2, filter3,
|
||||||
ansch_jahr, ansch_kost, code_4, reservierbar, isbn=None, item_type='general'):
|
ansch_jahr, ansch_kost, code_4, reservierbar, isbn="", item_type='other', library_category=""):
|
||||||
|
"""
|
||||||
|
Updates an item in MongoDB, keeping series groups synchronized.
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
client = MongoClient(cfg.MONGODB_HOST, cfg.MONGODB_PORT)
|
client = MongoClient(cfg.MONGODB_HOST, cfg.MONGODB_PORT)
|
||||||
db = client[cfg.MONGODB_DB]
|
db = client[cfg.MONGODB_DB]
|
||||||
@@ -272,29 +282,35 @@ def update_item(id, name, ort, beschreibung, images, verfuegbar, filter1, filter
|
|||||||
|
|
||||||
old_item = items.find_one({'_id': ObjectId(id)})
|
old_item = items.find_one({'_id': ObjectId(id)})
|
||||||
if not old_item:
|
if not old_item:
|
||||||
|
client.close()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
series_group_id = old_item.get('SeriesGroupId')
|
series_group_id = old_item.get('SeriesGroupId')
|
||||||
|
|
||||||
|
# Recalculate library status based on updated item_type
|
||||||
|
is_lib = is_library_item({'is_library': old_item.get('is_library'), 'ItemType': item_type})
|
||||||
|
|
||||||
shared_update = {
|
shared_update = {
|
||||||
'Name': name,
|
'Name': name,
|
||||||
'Ort': ort,
|
'Ort': ort,
|
||||||
'Beschreibung': beschreibung,
|
'Beschreibung': beschreibung,
|
||||||
'Images': images,
|
'Images': images if isinstance(images, list) else [],
|
||||||
'Filter': filter1,
|
'Filter': filter1 if isinstance(filter1, list) else [],
|
||||||
'Filter2': filter2,
|
'Filter2': filter2 if isinstance(filter2, list) else [],
|
||||||
'Filter3': filter3,
|
'Filter3': filter3 if isinstance(filter3, list) else [],
|
||||||
'Anschaffungsjahr': ansch_jahr,
|
'Anschaffungsjahr': ansch_jahr,
|
||||||
'Anschaffungskosten': ansch_kost,
|
'Anschaffungskosten': ansch_kost,
|
||||||
'Reservierbar': reservierbar,
|
'Reservierbar': bool(reservierbar),
|
||||||
'ISBN': isbn,
|
'ISBN': str(isbn) if isbn else '',
|
||||||
'ItemType': item_type,
|
'ItemType': item_type,
|
||||||
'Verfuegbar': verfuegbar,
|
'is_library': is_lib,
|
||||||
|
'library_category': library_category,
|
||||||
|
'Verfuegbar': bool(verfuegbar),
|
||||||
'LastUpdated': datetime.datetime.now()
|
'LastUpdated': datetime.datetime.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
specific_update = shared_update.copy()
|
specific_update = shared_update.copy()
|
||||||
specific_update['Code_4'] = code_4
|
specific_update['Code_4'] = str(code_4) if code_4 else ''
|
||||||
|
|
||||||
items.update_one({'_id': ObjectId(id)}, {'$set': specific_update})
|
items.update_one({'_id': ObjectId(id)}, {'$set': specific_update})
|
||||||
|
|
||||||
|
|||||||
@@ -271,7 +271,7 @@
|
|||||||
<small style="display:block; color:#666; margin-top: 5px;">Der Basis-Code steht oben. Alle weiteren Gruppenmitglieder werden hier untereinander aufgeführt.</small>
|
<small style="display:block; color:#666; margin-top: 5px;">Der Basis-Code steht oben. Alle weiteren Gruppenmitglieder werden hier untereinander aufgeführt.</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ================= SYSTEM FILTERS 1-3 (ALWAYS AVAILABLE) ================= -->
|
<!-- ================= SYSTEM FILTERS 1-3 (ALWAYS RENDERED) ================= -->
|
||||||
<div class="filter-inputs">
|
<div class="filter-inputs">
|
||||||
<h3>Unterrichtsfach (Filter 1):</h3>
|
<h3>Unterrichtsfach (Filter 1):</h3>
|
||||||
<div class="multi-filter">
|
<div class="multi-filter">
|
||||||
@@ -360,7 +360,6 @@
|
|||||||
let code4LastScanned = '';
|
let code4LastScanned = '';
|
||||||
let code4LastScannedAt = 0;
|
let code4LastScannedAt = 0;
|
||||||
|
|
||||||
// Load filter dropdown options and select current values
|
|
||||||
function loadAndSelectFilterValues(filterNumber) {
|
function loadAndSelectFilterValues(filterNumber) {
|
||||||
fetch(`/get_predefined_filter_values/${filterNumber}`)
|
fetch(`/get_predefined_filter_values/${filterNumber}`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
|
|||||||
Reference in New Issue
Block a user