diff --git a/__pycache__/app.cpython-313.pyc b/__pycache__/app.cpython-313.pyc index 15b0325..3e75dff 100644 Binary files a/__pycache__/app.cpython-313.pyc and b/__pycache__/app.cpython-313.pyc differ diff --git a/app.py b/app.py index 7883c5f..ccb0314 100644 --- a/app.py +++ b/app.py @@ -122,6 +122,33 @@ socketio = SocketIO(app) migrate = Migrate(app, db) +# Funktion zum Erstellen von Standardbenutzern +def create_default_users(): + """Erstellt Standardbenutzer für die Anwendung""" + users = [ + { + 'username': 'admin', + 'email': 'admin@example.com', + 'password': 'admin', + 'role': 'admin' + }, + { + 'username': 'user', + 'email': 'user@example.com', + 'password': 'user', + 'role': 'user' + } + ] + + for user_data in users: + password = user_data.pop('password') + user = User(**user_data) + user.set_password(password) + db.session.add(user) + + db.session.commit() + print(f"{len(users)} Benutzer wurden erstellt.") + # Automatische Datenbankinitialisierung - Aktualisiert für Flask 2.2+ Kompatibilität def initialize_app(): """Initialisierung der Anwendung""" @@ -155,31 +182,129 @@ def initialize_app(): with app.app_context(): initialize_app() -def create_default_users(): - """Erstellt Standardbenutzer für die Anwendung""" - users = [ +def create_sample_mindmap(): + """Erstellt eine Beispiel-Mindmap mit Knoten und Beziehungen""" + + # Kategorien für die Zuordnung + categories = Category.query.all() + category_map = {cat.name: cat for cat in categories} + + # Beispielknoten erstellen + nodes = [ { - 'username': 'admin', - 'email': 'admin@example.com', - 'password': 'admin', - 'role': 'admin' + 'name': 'Wissensmanagement', + 'description': 'Systematische Erfassung, Speicherung und Nutzung von Wissen in Organisationen.', + 'color_code': '#6366f1', + 'icon': 'database', + 'category': category_map.get('Philosophie'), + 'x': 0, + 'y': 0 }, { - 'username': 'user', - 'email': 'user@example.com', - 'password': 'user', - 'role': 'user' + 'name': 'Mind-Mapping', + 'description': 'Technik zur visuellen Darstellung von Informationen und Zusammenhängen.', + 'color_code': '#10b981', + 'icon': 'git-branch', + 'category': category_map.get('Technologie'), + 'x': 200, + 'y': -150 + }, + { + 'name': 'Cytoscape.js', + 'description': 'JavaScript-Bibliothek für die Visualisierung und Manipulation von Graphen.', + 'color_code': '#3b82f6', + 'icon': 'code', + 'category': category_map.get('Technologie'), + 'x': 350, + 'y': -50 + }, + { + 'name': 'Socket.IO', + 'description': 'Bibliothek für Echtzeit-Kommunikation zwischen Client und Server.', + 'color_code': '#3b82f6', + 'icon': 'zap', + 'category': category_map.get('Technologie'), + 'x': 350, + 'y': 100 + }, + { + 'name': 'Kollaboration', + 'description': 'Zusammenarbeit mehrerer Benutzer an gemeinsamen Inhalten.', + 'color_code': '#f59e0b', + 'icon': 'users', + 'category': category_map.get('Psychologie'), + 'x': 200, + 'y': 150 + }, + { + 'name': 'SQLite', + 'description': 'Leichtgewichtige relationale Datenbank, die ohne Server-Prozess auskommt.', + 'color_code': '#3b82f6', + 'icon': 'database', + 'category': category_map.get('Technologie'), + 'x': 0, + 'y': 200 + }, + { + 'name': 'Flask', + 'description': 'Leichtgewichtiges Python-Webframework für die Entwicklung von Webanwendungen.', + 'color_code': '#3b82f6', + 'icon': 'server', + 'category': category_map.get('Technologie'), + 'x': -200, + 'y': 150 + }, + { + 'name': 'REST API', + 'description': 'Architekturstil für verteilte Systeme, insbesondere Webanwendungen.', + 'color_code': '#10b981', + 'icon': 'link', + 'category': category_map.get('Wissenschaft'), + 'x': -200, + 'y': -150 } ] - for user_data in users: - password = user_data.pop('password') - user = User(**user_data) - user.set_password(password) - db.session.add(user) + # Erstelle einen zentralen "Wissen"-Knoten + wissen_node = MindMapNode.query.filter_by(name="Wissen").first() + if not wissen_node: + wissen_node = MindMapNode( + name="Wissen", + description="Zentrale Wissensbasis", + color_code="#4299E1", + icon="brain", + is_public=True + ) + db.session.add(wissen_node) + db.session.flush() + + # Erstelle die Knoten und verbinde sie mit dem Wissen-Knoten + created_nodes = [] + for node_data in nodes: + node = MindMapNode( + name=node_data['name'], + description=node_data['description'], + color_code=node_data['color_code'], + icon=node_data.get('icon', 'circle'), + is_public=True, + category=node_data.get('category') + ) + db.session.add(node) + db.session.flush() + + # Verbinde mit dem Wissen-Knoten + wissen_node.children.append(node) + created_nodes.append(node) + + # Erstelle einige Verbindungen zwischen den Knoten + if len(created_nodes) >= 2: + # Verbinde einige Knoten miteinander + created_nodes[0].children.append(created_nodes[1]) # Wissensmanagement -> Mind-Mapping + if len(created_nodes) >= 3: + created_nodes[1].children.append(created_nodes[2]) # Mind-Mapping -> Cytoscape.js db.session.commit() - print(f"{len(users)} Benutzer wurden erstellt.") + print("Beispiel-Mindmap wurde erstellt!") def create_default_categories(): """Erstellt die Standardkategorien für die Mindmap""" @@ -1918,7 +2043,7 @@ def admin_update_database(): if request.method == 'POST': try: - import update_db + import utils.update_db as update_db update_success = update_db.update_user_table() if update_success: message = "Die Datenbank wurde erfolgreich aktualisiert." diff --git a/database/systades.db b/database/systades.db index 2b37256..3dc01aa 100644 Binary files a/database/systades.db and b/database/systades.db differ diff --git a/systades.db b/systades.db deleted file mode 100644 index 019eb0c..0000000 Binary files a/systades.db and /dev/null differ diff --git a/utils/__pycache__/db_rebuild.cpython-313.pyc b/utils/__pycache__/db_rebuild.cpython-313.pyc index 49f3705..e52baf0 100644 Binary files a/utils/__pycache__/db_rebuild.cpython-313.pyc and b/utils/__pycache__/db_rebuild.cpython-313.pyc differ diff --git a/utils/__pycache__/db_test.cpython-313.pyc b/utils/__pycache__/db_test.cpython-313.pyc index bd43f5f..39ed7c3 100644 Binary files a/utils/__pycache__/db_test.cpython-313.pyc and b/utils/__pycache__/db_test.cpython-313.pyc differ diff --git a/utils/__pycache__/server.cpython-313.pyc b/utils/__pycache__/server.cpython-313.pyc index ccc45a0..96ce9cd 100644 Binary files a/utils/__pycache__/server.cpython-313.pyc and b/utils/__pycache__/server.cpython-313.pyc differ diff --git a/utils/__pycache__/user_manager.cpython-313.pyc b/utils/__pycache__/user_manager.cpython-313.pyc index f8c0dcc..d77e2b1 100644 Binary files a/utils/__pycache__/user_manager.cpython-313.pyc and b/utils/__pycache__/user_manager.cpython-313.pyc differ diff --git a/update_db.py b/utils/update_db.py similarity index 100% rename from update_db.py rename to utils/update_db.py