nordabiz/scripts/mark_test_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

46 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Oznacz wszystkie obecne wątki forum jako testowe."""
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
def main():
db = SessionLocal()
# Pobierz wszystkie wątki
topics = db.query(ForumTopic).all()
print(f"Znaleziono {len(topics)} wątków do oznaczenia jako testowe...")
print()
for topic in topics:
old_category = topic.category
topic.category = 'test'
print(f" ID {topic.id}: {topic.title[:50]}... ({old_category} → test)")
# Oznacz też odpowiedzi jako AI-generated (jeśli są testowe)
replies = db.query(ForumReply).all()
for reply in replies:
reply.is_ai_generated = True
print()
print(f"Oznaczono {len(topics)} wątków jako 'test'")
print(f"Oznaczono {len(replies)} odpowiedzi jako AI-generated")
db.commit()
db.close()
print()
print("Gotowe!")
if __name__ == "__main__":
main()