Spaces:
Running
Running
| 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() | |