Compare commits
2 Commits
7c742debdf
...
40b28134fc
| Author | SHA1 | Date | |
|---|---|---|---|
| 40b28134fc | |||
| d5fababd49 |
Binary file not shown.
Binary file not shown.
34
app.py
34
app.py
@@ -25,7 +25,7 @@ import sqlalchemy
|
|||||||
from models import (
|
from models import (
|
||||||
db, User, Thought, Comment, MindMapNode, ThoughtRelation, ThoughtRating,
|
db, User, Thought, Comment, MindMapNode, ThoughtRelation, ThoughtRating,
|
||||||
RelationType, Category, UserMindmap, UserMindmapNode, MindmapNote,
|
RelationType, Category, UserMindmap, UserMindmapNode, MindmapNote,
|
||||||
node_thought_association, user_thought_bookmark, node_relationship, ForumCategory, ForumPost
|
node_thought_association, user_thought_bookmark, node_relationship
|
||||||
)
|
)
|
||||||
|
|
||||||
# Lade .env-Datei
|
# Lade .env-Datei
|
||||||
@@ -191,31 +191,6 @@ def create_default_categories():
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
print("Standard-Kategorien wurden erstellt!")
|
print("Standard-Kategorien wurden erstellt!")
|
||||||
|
|
||||||
def create_forum_categories():
|
|
||||||
"""Erstellt Forum-Kategorien basierend auf Hauptknotenpunkten der Mindmap"""
|
|
||||||
# Hauptknotenpunkte abrufen (nur die, die keine Elternknoten haben)
|
|
||||||
main_nodes = MindMapNode.query.filter(~MindMapNode.id.in_(
|
|
||||||
db.session.query(node_relationship.c.child_id)
|
|
||||||
)).all()
|
|
||||||
|
|
||||||
for node in main_nodes:
|
|
||||||
# Prüfen, ob eine Forum-Kategorie für diesen Knoten bereits existiert
|
|
||||||
existing_category = ForumCategory.query.filter_by(node_id=node.id).first()
|
|
||||||
if existing_category:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Neue Kategorie erstellen
|
|
||||||
forum_category = ForumCategory(
|
|
||||||
node_id=node.id,
|
|
||||||
title=node.name,
|
|
||||||
description=node.description,
|
|
||||||
is_active=True
|
|
||||||
)
|
|
||||||
db.session.add(forum_category)
|
|
||||||
|
|
||||||
db.session.commit()
|
|
||||||
print("Forum-Kategorien wurden für alle Hauptknotenpunkte erstellt!")
|
|
||||||
|
|
||||||
def initialize_database():
|
def initialize_database():
|
||||||
"""Initialisiert die Datenbank mit Grunddaten, falls diese leer ist"""
|
"""Initialisiert die Datenbank mit Grunddaten, falls diese leer ist"""
|
||||||
try:
|
try:
|
||||||
@@ -245,9 +220,6 @@ def initialize_database():
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
print("Admin-Benutzer wurde erstellt!")
|
print("Admin-Benutzer wurde erstellt!")
|
||||||
|
|
||||||
# Forum-Kategorien erstellen
|
|
||||||
create_forum_categories()
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Fehler bei Datenbank-Initialisierung: {e}")
|
print(f"Fehler bei Datenbank-Initialisierung: {e}")
|
||||||
@@ -1838,13 +1810,13 @@ def refresh_mindmap():
|
|||||||
def mindmap_page():
|
def mindmap_page():
|
||||||
return render_template('mindmap.html')
|
return render_template('mindmap.html')
|
||||||
|
|
||||||
# Einfache Umleitungen für Community/Forum-Routen
|
# Weiterleitung für Community/Forum-Routen
|
||||||
@app.route('/community')
|
@app.route('/community')
|
||||||
@app.route('/Community')
|
@app.route('/Community')
|
||||||
@app.route('/forum')
|
@app.route('/forum')
|
||||||
@app.route('/Forum')
|
@app.route('/Forum')
|
||||||
@app.route('/community_forum')
|
@app.route('/community_forum')
|
||||||
def redirect_to_index():
|
def redirect_community():
|
||||||
"""Leitet alle Community/Forum-URLs zur Startseite um"""
|
"""Leitet alle Community/Forum-URLs zur Startseite um"""
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
|||||||
@@ -657,6 +657,10 @@
|
|||||||
:class="darkMode ? 'text-gray-300 hover:text-white' : 'text-gray-600 hover:text-gray-900'">
|
:class="darkMode ? 'text-gray-300 hover:text-white' : 'text-gray-600 hover:text-gray-900'">
|
||||||
Mindmap
|
Mindmap
|
||||||
</a>
|
</a>
|
||||||
|
<a href="{{ url_for('search_thoughts_page') }}" class="text-sm transition-all duration-200"
|
||||||
|
:class="darkMode ? 'text-gray-300 hover:text-white' : 'text-gray-600 hover:text-gray-900'">
|
||||||
|
Suche
|
||||||
|
</a>
|
||||||
{% if current_user.is_authenticated %}
|
{% if current_user.is_authenticated %}
|
||||||
<a href="{{ url_for('profile') }}" class="text-sm transition-all duration-200"
|
<a href="{{ url_for('profile') }}" class="text-sm transition-all duration-200"
|
||||||
:class="darkMode ? 'text-gray-300 hover:text-white' : 'text-gray-600 hover:text-gray-900'">
|
:class="darkMode ? 'text-gray-300 hover:text-white' : 'text-gray-600 hover:text-gray-900'">
|
||||||
|
|||||||
Reference in New Issue
Block a user