✨ feat: update environment config and add community preview template
This commit is contained in:
57
app.py
57
app.py
@@ -1477,20 +1477,49 @@ def refresh_mindmap():
|
||||
'error': 'Datenbankverbindung konnte nicht hergestellt werden'
|
||||
}), 500
|
||||
|
||||
|
||||
# Route zur Mindmap HTML-Seite
|
||||
@app.route('/mindmap')
|
||||
def mindmap_page():
|
||||
return render_template('mindmap.html')
|
||||
|
||||
# Community-Forum-Routen
|
||||
# Weiterleitung für Groß-/Kleinschreibung
|
||||
@app.route('/Community')
|
||||
def Community():
|
||||
# Direkte Umleitung ohne url_for zu verwenden, um Kreisverweise zu vermeiden
|
||||
return redirect('/')
|
||||
|
||||
# Vermeidung der direkten Community-Route, die Probleme verursacht
|
||||
@app.route('/community')
|
||||
@login_required
|
||||
def community():
|
||||
"""Hauptseite des Community-Forums"""
|
||||
forum_categories = ForumCategory.query.filter_by(is_active=True).all()
|
||||
"""Vermeidet direkten Zugriff auf Community-Forum"""
|
||||
return redirect('/')
|
||||
|
||||
# Alternative Route für Community-Forum, die über das Menü erreichbar ist
|
||||
@app.route('/forum')
|
||||
def forum():
|
||||
"""Alternative Route zum Community-Forum"""
|
||||
if not current_user.is_authenticated:
|
||||
# Wenn Benutzer nicht angemeldet ist, zeige eine Vorschauversion
|
||||
forum_categories = ForumCategory.query.filter_by(is_active=True).limit(5).all()
|
||||
categories_data = []
|
||||
for category in forum_categories:
|
||||
total_posts = ForumPost.query.filter_by(category_id=category.id, parent_id=None).count()
|
||||
total_replies = ForumPost.query.filter(
|
||||
ForumPost.category_id == category.id,
|
||||
ForumPost.parent_id != None
|
||||
).count()
|
||||
|
||||
categories_data.append({
|
||||
'category': category,
|
||||
'total_posts': total_posts,
|
||||
'total_replies': total_replies,
|
||||
'latest_post': None
|
||||
})
|
||||
|
||||
return render_template('community/preview.html', categories_data=categories_data)
|
||||
|
||||
# Statistiken für jede Kategorie berechnen
|
||||
# Angemeldete Benutzer bekommen die vollständige Version
|
||||
forum_categories = ForumCategory.query.filter_by(is_active=True).all()
|
||||
categories_data = []
|
||||
for category in forum_categories:
|
||||
total_posts = ForumPost.query.filter_by(category_id=category.id, parent_id=None).count()
|
||||
@@ -1510,7 +1539,7 @@ def community():
|
||||
|
||||
return render_template('community/index.html', categories_data=categories_data)
|
||||
|
||||
@app.route('/community/category/<int:category_id>')
|
||||
@app.route('/forum/category/<int:category_id>')
|
||||
@login_required
|
||||
def forum_category(category_id):
|
||||
"""Zeigt alle Themen in einer bestimmten Kategorie an"""
|
||||
@@ -1540,7 +1569,7 @@ def forum_category(category_id):
|
||||
threads_data=threads_data,
|
||||
node=category.node)
|
||||
|
||||
@app.route('/community/post/<int:post_id>')
|
||||
@app.route('/forum/post/<int:post_id>')
|
||||
@login_required
|
||||
def forum_post(post_id):
|
||||
"""Zeigt einen Beitrag und alle seine Antworten an"""
|
||||
@@ -1563,7 +1592,7 @@ def forum_post(post_id):
|
||||
replies=replies,
|
||||
category=post.category)
|
||||
|
||||
@app.route('/community/new-post/<int:category_id>', methods=['GET', 'POST'])
|
||||
@app.route('/forum/new-post/<int:category_id>', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def new_post(category_id):
|
||||
"""Erstellt einen neuen Beitrag in einer Kategorie"""
|
||||
@@ -1592,7 +1621,7 @@ def new_post(category_id):
|
||||
|
||||
return render_template('community/new_post.html', category=category)
|
||||
|
||||
@app.route('/community/reply/<int:post_id>', methods=['POST'])
|
||||
@app.route('/forum/reply/<int:post_id>', methods=['POST'])
|
||||
@login_required
|
||||
def reply_to_post(post_id):
|
||||
"""Antwortet auf einen bestehenden Beitrag"""
|
||||
@@ -1623,7 +1652,7 @@ def reply_to_post(post_id):
|
||||
flash('Deine Antwort wurde erfolgreich hinzugefügt.', 'success')
|
||||
return redirect(url_for('forum_post', post_id=post_id))
|
||||
|
||||
@app.route('/community/edit-post/<int:post_id>', methods=['GET', 'POST'])
|
||||
@app.route('/forum/edit-post/<int:post_id>', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def edit_post(post_id):
|
||||
"""Bearbeitet einen bestehenden Beitrag"""
|
||||
@@ -1653,7 +1682,7 @@ def edit_post(post_id):
|
||||
|
||||
return render_template('community/edit_post.html', post=post)
|
||||
|
||||
@app.route('/community/delete-post/<int:post_id>', methods=['POST'])
|
||||
@app.route('/forum/delete-post/<int:post_id>', methods=['POST'])
|
||||
@login_required
|
||||
def delete_post(post_id):
|
||||
"""Löscht einen Beitrag"""
|
||||
@@ -1680,7 +1709,7 @@ def delete_post(post_id):
|
||||
flash('Der Beitrag wurde erfolgreich gelöscht.', 'success')
|
||||
return redirect(redirect_url)
|
||||
|
||||
@app.route('/community/toggle-pin/<int:post_id>', methods=['POST'])
|
||||
@app.route('/forum/toggle-pin/<int:post_id>', methods=['POST'])
|
||||
@login_required
|
||||
def toggle_pin_post(post_id):
|
||||
"""Fixiert oder löst einen Beitrag von der Fixierung"""
|
||||
@@ -1704,7 +1733,7 @@ def toggle_pin_post(post_id):
|
||||
flash(f'Der Beitrag ist jetzt {status}.', 'success')
|
||||
return redirect(url_for('forum_post', post_id=post_id))
|
||||
|
||||
@app.route('/community/toggle-lock/<int:post_id>', methods=['POST'])
|
||||
@app.route('/forum/toggle-lock/<int:post_id>', methods=['POST'])
|
||||
@login_required
|
||||
def toggle_lock_post(post_id):
|
||||
"""Sperrt oder entsperrt einen Beitrag für weitere Antworten"""
|
||||
|
||||
Reference in New Issue
Block a user