chore: Änderungen commited
This commit is contained in:
Binary file not shown.
161
app.py
161
app.py
@@ -122,6 +122,33 @@ socketio = SocketIO(app)
|
|||||||
|
|
||||||
migrate = Migrate(app, db)
|
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
|
# Automatische Datenbankinitialisierung - Aktualisiert für Flask 2.2+ Kompatibilität
|
||||||
def initialize_app():
|
def initialize_app():
|
||||||
"""Initialisierung der Anwendung"""
|
"""Initialisierung der Anwendung"""
|
||||||
@@ -155,31 +182,129 @@ def initialize_app():
|
|||||||
with app.app_context():
|
with app.app_context():
|
||||||
initialize_app()
|
initialize_app()
|
||||||
|
|
||||||
def create_default_users():
|
def create_sample_mindmap():
|
||||||
"""Erstellt Standardbenutzer für die Anwendung"""
|
"""Erstellt eine Beispiel-Mindmap mit Knoten und Beziehungen"""
|
||||||
users = [
|
|
||||||
|
# Kategorien für die Zuordnung
|
||||||
|
categories = Category.query.all()
|
||||||
|
category_map = {cat.name: cat for cat in categories}
|
||||||
|
|
||||||
|
# Beispielknoten erstellen
|
||||||
|
nodes = [
|
||||||
{
|
{
|
||||||
'username': 'admin',
|
'name': 'Wissensmanagement',
|
||||||
'email': 'admin@example.com',
|
'description': 'Systematische Erfassung, Speicherung und Nutzung von Wissen in Organisationen.',
|
||||||
'password': 'admin',
|
'color_code': '#6366f1',
|
||||||
'role': 'admin'
|
'icon': 'database',
|
||||||
|
'category': category_map.get('Philosophie'),
|
||||||
|
'x': 0,
|
||||||
|
'y': 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'username': 'user',
|
'name': 'Mind-Mapping',
|
||||||
'email': 'user@example.com',
|
'description': 'Technik zur visuellen Darstellung von Informationen und Zusammenhängen.',
|
||||||
'password': 'user',
|
'color_code': '#10b981',
|
||||||
'role': 'user'
|
'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:
|
# Erstelle einen zentralen "Wissen"-Knoten
|
||||||
password = user_data.pop('password')
|
wissen_node = MindMapNode.query.filter_by(name="Wissen").first()
|
||||||
user = User(**user_data)
|
if not wissen_node:
|
||||||
user.set_password(password)
|
wissen_node = MindMapNode(
|
||||||
db.session.add(user)
|
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()
|
db.session.commit()
|
||||||
print(f"{len(users)} Benutzer wurden erstellt.")
|
print("Beispiel-Mindmap wurde erstellt!")
|
||||||
|
|
||||||
def create_default_categories():
|
def create_default_categories():
|
||||||
"""Erstellt die Standardkategorien für die Mindmap"""
|
"""Erstellt die Standardkategorien für die Mindmap"""
|
||||||
@@ -1918,7 +2043,7 @@ def admin_update_database():
|
|||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
try:
|
try:
|
||||||
import update_db
|
import utils.update_db as update_db
|
||||||
update_success = update_db.update_user_table()
|
update_success = update_db.update_user_table()
|
||||||
if update_success:
|
if update_success:
|
||||||
message = "Die Datenbank wurde erfolgreich aktualisiert."
|
message = "Die Datenbank wurde erfolgreich aktualisiert."
|
||||||
|
|||||||
Binary file not shown.
BIN
systades.db
BIN
systades.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user