import os import sys # Dodaj główny katalog do PYTHONPATH, aby moduły z 'core' były widoczne sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from sqlalchemy.orm import Session from core.subscription.db import SessionLocal from core.subscription.models import User # IMPORT REQUIRED TO REGISTER User MODEL from core.projects.models import ProjectSectionTemplate TEMPLATES = [ # SMART { "program_type": "SMART", "section_type": "project_summary", "order": 1, "title": "Informacje ogólne o projekcie", "is_required": True, }, { "program_type": "SMART", "section_type": "applicant", "order": 2, "title": "Wnioskodawca i powiązania", "is_required": True, }, { "program_type": "SMART", "section_type": "team", "order": 3, "title": "Zespół zarządzający i projektowy", "is_required": True, }, { "program_type": "SMART", "section_type": "market", "order": 4, "title": "Analiza zapotrzebowania i rynku", "is_required": True, }, { "program_type": "SMART", "section_type": "innovation", "order": 5, "title": "Innowacyjność (TRL) i znaczenie projektu", "is_required": True, }, { "program_type": "SMART", "section_type": "module_br", "order": 6, "title": "Moduł B+R: Plan prac", "is_required": True, }, { "program_type": "SMART", "section_type": "module_implementation", "order": 7, "title": "Moduł Wdrożenie Innowacji", "is_required": True, }, { "program_type": "SMART", "section_type": "module_infrastructure", "order": 8, "title": "Moduł Infrastruktura B+R", "is_required": False, }, { "program_type": "SMART", "section_type": "module_digitalization", "order": 9, "title": "Moduł Cyfryzacja", "is_required": False, }, { "program_type": "SMART", "section_type": "module_green", "order": 10, "title": "Moduł Zazielenienie przedsiębiorstw", "is_required": False, }, { "program_type": "SMART", "section_type": "module_internationalization", "order": 11, "title": "Moduł Internacjonalizacja", "is_required": False, }, { "program_type": "SMART", "section_type": "module_competence", "order": 12, "title": "Moduł Kompetencje", "is_required": False, }, { "program_type": "SMART", "section_type": "sustainable", "order": 13, "title": "Zrównoważony rozwój i zasada DNSH", "is_required": True, }, { "program_type": "SMART", "section_type": "budget", "order": 14, "title": "Montaż finansowy i koszty", "is_required": True, }, { "program_type": "SMART", "section_type": "kpi_risk", "order": 15, "title": "Wskaźniki KPI i analiza ryzyka", "is_required": True, }, { "program_type": "SMART", "section_type": "attachments", "order": 16, "title": "Załączniki i Oświadczenia", "is_required": True, }, # ARIMR { "program_type": "ARIMR", "section_type": "description", "order": 1, "title": "Opis inwestycji", "is_required": True, }, { "program_type": "ARIMR", "section_type": "animals", "order": 2, "title": "Dobrostan zwierząt / modernizacja", "is_required": True, }, { "program_type": "ARIMR", "section_type": "profitability", "order": 3, "title": "Analiza opłacalności", "is_required": True, }, { "program_type": "ARIMR", "section_type": "environment", "order": 4, "title": "Wpływ na środowisko", "is_required": True, }, { "program_type": "ARIMR", "section_type": "budget", "order": 5, "title": "Budżet i harmonogram", "is_required": True, }, { "program_type": "ARIMR", "section_type": "technical_attachments", "order": 6, "title": "Załączniki techniczne", "is_required": True, }, # ZUS_BHP { "program_type": "ZUS_BHP", "section_type": "risk_assessment", "order": 1, "title": "Ocena ryzyka zawodowego", "is_required": True, }, { "program_type": "ZUS_BHP", "section_type": "improvement_plan", "order": 2, "title": "Plan poprawy warunków pracy", "is_required": True, }, { "program_type": "ZUS_BHP", "section_type": "scope", "order": 3, "title": "Zakres inwestycji BHP", "is_required": True, }, { "program_type": "ZUS_BHP", "section_type": "budget", "order": 4, "title": "Budżet", "is_required": True, }, { "program_type": "ZUS_BHP", "section_type": "results", "order": 5, "title": "Oczekiwane efekty", "is_required": True, }, ] def seed_templates(): db: Session = SessionLocal() try: # Usuwamy poprzednie szablony aby zapenić idempotentność db.query(ProjectSectionTemplate).delete() for tmpl in TEMPLATES: new_template = ProjectSectionTemplate(**tmpl) db.add(new_template) db.commit() print(f"Dodano {len(TEMPLATES)} szablonów do bazy danych.") except Exception as e: db.rollback() print(f"Wystąpił błąd: {e}") finally: db.close() if __name__ == "__main__": seed_templates()