Compare commits

...

3 Commits

Author SHA1 Message Date
Aiirondev_dev e9006f5a07 Fix of an missing parethasys
Release Inventarsystem / release-docker (push) Has been cancelled
2026-08-11 00:38:48 +02:00
Aiirondev_dev a11bce17c5 Fixy of the api_library_items()
Release Inventarsystem / release-docker (push) Has been cancelled
2026-08-11 00:31:57 +02:00
Aiirondev_dev 743e5b1c16 Reviewed the edeting function
Release Inventarsystem / release-docker (push) Successful in 2m18s
2026-08-10 23:40:02 +02:00
2 changed files with 618 additions and 535 deletions
+66 -13
View File
@@ -3314,7 +3314,6 @@ def api_library_items():
query = {
'ItemType': {'$in': ['book', 'cd', 'dvd', 'schoolbook', 'schulbuch', 'Buch', 'Schulbuch']},
'IsGroupedSubItem': {'$ne': True},
'Deleted': {'$ne': True}
}
@@ -3332,7 +3331,12 @@ def api_library_items():
'User': 1,
'Ort': 1,
'Beschreibung': 1,
'Image': 1
'Image': 1,
'SeriesGroupId': 1,
'SeriesCount': 1,
'SeriesPosition': 1,
'IsGroupedSubItem': 1,
'ParentItemId': 1,
}
total_count = items_db.count_documents(query)
@@ -3360,6 +3364,10 @@ def api_library_items():
'Beschreibung': 1,
'Image': 1,
'ParentItemId': 1,
'SeriesGroupId': 1,
'SeriesCount': 1,
'SeriesPosition': 1,
'IsGroupedSubItem': 1,
}
child_items = list(items_db.find({
'ParentItemId': {'$in': parent_ids_list},
@@ -3473,6 +3481,48 @@ def api_library_items():
return jsonify({'error': 'An error occurred while fetching library items'}), 500
@app.route('/api/library_group/<series_group_id>')
def api_library_group(series_group_id):
"""Fetch all items belonging to one library series group."""
if 'username' not in session:
return jsonify({'items': []}), 401
try:
client = MongoClient(MONGODB_HOST, MONGODB_PORT)
db = client[MONGODB_DB]
items_col = db['items']
query = {
'SeriesGroupId': series_group_id,
'Deleted': {'$ne': True},
'ItemType': {'$in': ['book', 'cd', 'dvd', 'schoolbook', 'schulbuch', 'Buch', 'Schulbuch']},
}
projection = {
'Name': 1,
'ISBN': 1,
'Code_4': 1,
'Code4': 1,
'ItemType': 1,
'Ort': 1,
'Beschreibung': 1,
'SeriesGroupId': 1,
'SeriesCount': 1,
'SeriesPosition': 1,
'IsGroupedSubItem': 1,
'ParentItemId': 1,
}
items = list(items_col.find(query, projection).sort([('SeriesPosition', 1), ('Name', 1), ('_id', 1)]))
for item in items:
item['_id'] = str(item['_id'])
client.close()
return jsonify({'items': items, 'count': len(items), 'series_group_id': series_group_id})
except Exception as exc:
app.logger.error('Error loading library group %s: %s', series_group_id, exc)
return jsonify({'items': [], 'message': 'Gruppe konnte nicht geladen werden.'}), 500
@app.route('/api/library_scan_action', methods=['POST'])
def api_library_scan_action():
"""
@@ -6336,17 +6386,20 @@ def update_group():
# 1. Shared Fields (Group Logic)
# These apply to every item in the group
shared_update = {
'Name': data.get('name'),
'Ort': data.get('ort'),
'Beschreibung': data.get('beschreibung'),
'Anschaffungsjahr': data.get('ansch_jahr'),
'Anschaffungskosten': data.get('ansch_kost'),
'Reservierbar': data.get('reservierbar'),
'ISBN': data.get('isbn'),
'ItemType': data.get('item_type'),
'LastUpdated': datetime.datetime.now()
}
shared_update = {'LastUpdated': datetime.datetime.now()}
for source_key, target_key in (
('name', 'Name'),
('ort', 'Ort'),
('beschreibung', 'Beschreibung'),
('ansch_jahr', 'Anschaffungsjahr'),
('ansch_kost', 'Anschaffungskosten'),
('reservierbar', 'Reservierbar'),
('isbn', 'ISBN'),
('item_type', 'ItemType'),
):
value = data.get(source_key)
if value is not None:
shared_update[target_key] = value
# 2. Individual Updates (Specific Code Logic)
# Expected format: [{'id': '...', 'code_4': '...'}, ...]
File diff suppressed because it is too large Load Diff