File size: 5,946 Bytes
afd56bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
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()