diff --git a/__pycache__/app.cpython-313.pyc b/__pycache__/app.cpython-313.pyc index 2114fd3..b1146c1 100644 Binary files a/__pycache__/app.cpython-313.pyc and b/__pycache__/app.cpython-313.pyc differ diff --git a/__pycache__/models.cpython-313.pyc b/__pycache__/models.cpython-313.pyc index fd841b7..9d46b03 100644 Binary files a/__pycache__/models.cpython-313.pyc and b/__pycache__/models.cpython-313.pyc differ diff --git a/app.py b/app.py index 201bd84..414eb22 100644 --- a/app.py +++ b/app.py @@ -25,7 +25,7 @@ import sqlalchemy from models import ( db, User, Thought, Comment, MindMapNode, ThoughtRelation, ThoughtRating, 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 @@ -191,31 +191,6 @@ def create_default_categories(): db.session.commit() 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(): """Initialisiert die Datenbank mit Grunddaten, falls diese leer ist""" try: @@ -245,9 +220,6 @@ def initialize_database(): db.session.commit() print("Admin-Benutzer wurde erstellt!") - # Forum-Kategorien erstellen - create_forum_categories() - return True except Exception as e: print(f"Fehler bei Datenbank-Initialisierung: {e}") @@ -1838,73 +1810,20 @@ def refresh_mindmap(): def mindmap_page(): 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('/forum') @app.route('/Forum') @app.route('/community_forum') -def forum_index(): - """Community-Forum-Startseite""" - # Kategorien und ihre Daten abrufen - categories = ForumCategory.query.all() - categories_data = [] - - for category in categories: - posts = ForumPost.query.filter_by(category_id=category.id, parent_id=None).count() - replies = ForumPost.query.filter(ForumPost.category_id == category.id, ForumPost.parent_id != None).count() - latest_post = ForumPost.query.filter_by(category_id=category.id).order_by(ForumPost.created_at.desc()).first() - - categories_data.append({ - 'category': category, - 'total_posts': posts, - 'total_replies': replies, - 'latest_post': latest_post - }) - - return render_template('community/index.html', categories_data=categories_data) +def redirect_community(): + """Leitet alle Community/Forum-URLs zur Startseite um""" + return redirect(url_for('index')) -@app.route('/community/category/') -def forum_category(category_id): - """Zeigt alle Posts einer bestimmten Kategorie an""" - category = ForumCategory.query.get_or_404(category_id) - posts = ForumPost.query.filter_by(category_id=category_id).order_by(ForumPost.created_at.desc()).all() - return render_template('community/category.html', category=category, posts=posts) - -@app.route('/community/post/') -def forum_post(post_id): - """Zeigt einen einzelnen Forumsbeitrag mit seinen Antworten an""" - post = ForumPost.query.get_or_404(post_id) - return render_template('community/post.html', post=post) - -@app.route('/community/new-post', methods=['GET', 'POST']) -@login_required -def forum_new_post(): - """Erstellen eines neuen Forumsbeitrags""" - if request.method == 'POST': - title = request.form.get('title') - content = request.form.get('content') - category_id = request.form.get('category') - - if not title or not content or not category_id: - flash('Bitte fülle alle erforderlichen Felder aus.', 'warning') - return redirect(url_for('forum_new_post')) - - post = ForumPost( - title=title, - content=content, - user_id=current_user.id, - category_id=category_id - ) - - db.session.add(post) - db.session.commit() - - flash('Dein Beitrag wurde erfolgreich erstellt!', 'success') - return redirect(url_for('forum_post', post_id=post.id)) - - categories = ForumCategory.query.all() - return render_template('community/new_post.html', categories=categories) +@app.route('/static/js/mindmap-init.js') +def serve_mindmap_init_js(): + """Bedient die Mindmap-Initialisierungsdatei.""" + return app.send_static_file('js/mindmap-init.js'), 200, {'Content-Type': 'application/javascript'} # Datenbank-Update-Route (admin-geschützt) @app.route('/admin/update-database', methods=['GET', 'POST']) @@ -1928,9 +1847,4 @@ def admin_update_database(): message = f"Fehler: {str(e)}" success = False - return render_template('admin/update_database.html', message=message, success=success) - -@app.route('/static/js/mindmap-init.js') -def serve_mindmap_init_js(): - """Bedient die Mindmap-Initialisierungsdatei.""" - return app.send_static_file('js/mindmap-init.js'), 200, {'Content-Type': 'application/javascript'} \ No newline at end of file + return render_template('admin/update_database.html', message=message, success=success) \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 620064a..362eb77 100644 --- a/templates/base.html +++ b/templates/base.html @@ -657,9 +657,9 @@ :class="darkMode ? 'text-gray-300 hover:text-white' : 'text-gray-600 hover:text-gray-900'"> Mindmap - - Community + Suche {% if current_user.is_authenticated %}