nordabiz/scripts/list_forum_topics.py
Maciej Pienczyn 08d6c0b069 feat: Add 'test' category for forum topics to separate test content
- Add 'test' to ForumTopic.CATEGORIES with Polish label 'Testowy'
- Add gray styling for test topics (badge + card opacity)
- Add scripts to list and mark test topics
2026-01-13 11:48:08 +01:00

41 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Lista wszystkich wątków forum z autorami."""
import os
import sys
from dotenv import load_dotenv
# Load .env first
load_dotenv()
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from database import SessionLocal, ForumTopic, ForumReply, User
def main():
db = SessionLocal()
threads = db.query(ForumTopic).order_by(ForumTopic.created_at).all()
print("=== WĄTKI FORUM ===")
print()
for t in threads:
author = db.query(User).filter(User.id == t.author_id).first()
author_name = author.name if author else 'Unknown'
author_email = author.email if author else ''
replies_count = db.query(ForumReply).filter(ForumReply.topic_id == t.id).count()
date_str = t.created_at.strftime('%Y-%m-%d')
print(f"ID: {t.id}")
print(f" Tytuł: {t.title}")
print(f" Autor: {author_name} ({author_email})")
print(f" Data: {date_str}")
print(f" Odpowiedzi: {replies_count}")
print(f" Przypięty: {t.is_pinned}")
print()
db.close()
if __name__ == "__main__":
main()