constec 0.7.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- constec/db/__init__.py +11 -0
- constec/db/apps.py +8 -0
- constec/db/migrations/0001_initial.py +551 -0
- constec/db/migrations/0002_module_level.py +38 -0
- constec/db/migrations/0003_remove_module_level.py +15 -0
- constec/db/migrations/0004_rename_entities_company_cuit_idx_entities_company_e2c50f_idx_and_more.py +345 -0
- constec/db/migrations/0005_event.py +46 -0
- constec/db/migrations/0006_automation_trigger_action_executionlog_notificationtemplate.py +275 -0
- constec/db/migrations/0007_add_organization_to_automations.py +91 -0
- constec/db/migrations/0008_refactor_creator_fields.py +173 -0
- constec/db/migrations/0009_rename_user_to_companyuser.py +40 -0
- constec/db/migrations/__init__.py +0 -0
- constec/db/models/__init__.py +110 -0
- constec/db/models/automation.py +488 -0
- constec/db/models/base.py +23 -0
- constec/db/models/company.py +36 -0
- constec/db/models/contact.py +71 -0
- constec/db/models/erp.py +101 -0
- constec/db/models/erp_entity.py +122 -0
- constec/db/models/flow.py +138 -0
- constec/db/models/group.py +36 -0
- constec/db/models/module.py +67 -0
- constec/db/models/organization.py +62 -0
- constec/db/models/person.py +28 -0
- constec/db/models/session.py +89 -0
- constec/db/models/tag.py +70 -0
- constec/db/models/user.py +74 -0
- constec/py.typed +0 -0
- constec/services/__init__.py +14 -0
- constec/services/encryption.py +92 -0
- constec/shared/__init__.py +20 -0
- constec/shared/exceptions.py +48 -0
- constec/utils/__init__.py +20 -0
- constec/utils/cuit.py +107 -0
- constec/utils/password.py +62 -0
- constec-0.7.1.dist-info/METADATA +94 -0
- constec-0.7.1.dist-info/RECORD +40 -0
- constec-0.7.1.dist-info/WHEEL +5 -0
- constec-0.7.1.dist-info/licenses/LICENSE +21 -0
- constec-0.7.1.dist-info/top_level.txt +1 -0
constec/db/migrations/0004_rename_entities_company_cuit_idx_entities_company_e2c50f_idx_and_more.py
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
# Generated by Django 6.0.1 on 2026-01-29 13:27
|
|
2
|
+
|
|
3
|
+
import django.utils.timezone
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
('constec_db', '0003_remove_module_level'),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
operations = [
|
|
14
|
+
migrations.AddField(
|
|
15
|
+
model_name='company',
|
|
16
|
+
name='created_at',
|
|
17
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
18
|
+
preserve_default=False,
|
|
19
|
+
),
|
|
20
|
+
migrations.AddField(
|
|
21
|
+
model_name='company',
|
|
22
|
+
name='updated_at',
|
|
23
|
+
field=models.DateTimeField(auto_now=True),
|
|
24
|
+
),
|
|
25
|
+
migrations.AddField(
|
|
26
|
+
model_name='companymodule',
|
|
27
|
+
name='created_at',
|
|
28
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
29
|
+
preserve_default=False,
|
|
30
|
+
),
|
|
31
|
+
migrations.AddField(
|
|
32
|
+
model_name='companymodule',
|
|
33
|
+
name='is_active',
|
|
34
|
+
field=models.BooleanField(default=True),
|
|
35
|
+
),
|
|
36
|
+
migrations.AddField(
|
|
37
|
+
model_name='companymodule',
|
|
38
|
+
name='updated_at',
|
|
39
|
+
field=models.DateTimeField(auto_now=True),
|
|
40
|
+
),
|
|
41
|
+
migrations.AddField(
|
|
42
|
+
model_name='contact',
|
|
43
|
+
name='created_at',
|
|
44
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
45
|
+
preserve_default=False,
|
|
46
|
+
),
|
|
47
|
+
migrations.AddField(
|
|
48
|
+
model_name='contact',
|
|
49
|
+
name='is_active',
|
|
50
|
+
field=models.BooleanField(default=True),
|
|
51
|
+
),
|
|
52
|
+
migrations.AddField(
|
|
53
|
+
model_name='contact',
|
|
54
|
+
name='updated_at',
|
|
55
|
+
field=models.DateTimeField(auto_now=True),
|
|
56
|
+
),
|
|
57
|
+
migrations.AddField(
|
|
58
|
+
model_name='contacttype',
|
|
59
|
+
name='created_at',
|
|
60
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
61
|
+
preserve_default=False,
|
|
62
|
+
),
|
|
63
|
+
migrations.AddField(
|
|
64
|
+
model_name='contacttype',
|
|
65
|
+
name='is_active',
|
|
66
|
+
field=models.BooleanField(default=True),
|
|
67
|
+
),
|
|
68
|
+
migrations.AddField(
|
|
69
|
+
model_name='contacttype',
|
|
70
|
+
name='updated_at',
|
|
71
|
+
field=models.DateTimeField(auto_now=True),
|
|
72
|
+
),
|
|
73
|
+
migrations.AddField(
|
|
74
|
+
model_name='entity',
|
|
75
|
+
name='created_at',
|
|
76
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
77
|
+
preserve_default=False,
|
|
78
|
+
),
|
|
79
|
+
migrations.AddField(
|
|
80
|
+
model_name='entity',
|
|
81
|
+
name='is_active',
|
|
82
|
+
field=models.BooleanField(default=True),
|
|
83
|
+
),
|
|
84
|
+
migrations.AddField(
|
|
85
|
+
model_name='entity',
|
|
86
|
+
name='updated_at',
|
|
87
|
+
field=models.DateTimeField(auto_now=True),
|
|
88
|
+
),
|
|
89
|
+
migrations.AddField(
|
|
90
|
+
model_name='message',
|
|
91
|
+
name='is_active',
|
|
92
|
+
field=models.BooleanField(default=True),
|
|
93
|
+
),
|
|
94
|
+
migrations.AddField(
|
|
95
|
+
model_name='message',
|
|
96
|
+
name='updated_at',
|
|
97
|
+
field=models.DateTimeField(auto_now=True),
|
|
98
|
+
),
|
|
99
|
+
migrations.AddField(
|
|
100
|
+
model_name='module',
|
|
101
|
+
name='created_at',
|
|
102
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
103
|
+
preserve_default=False,
|
|
104
|
+
),
|
|
105
|
+
migrations.AddField(
|
|
106
|
+
model_name='module',
|
|
107
|
+
name='updated_at',
|
|
108
|
+
field=models.DateTimeField(auto_now=True),
|
|
109
|
+
),
|
|
110
|
+
migrations.AddField(
|
|
111
|
+
model_name='organization',
|
|
112
|
+
name='created_at',
|
|
113
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
114
|
+
preserve_default=False,
|
|
115
|
+
),
|
|
116
|
+
migrations.AddField(
|
|
117
|
+
model_name='organization',
|
|
118
|
+
name='is_active',
|
|
119
|
+
field=models.BooleanField(default=True),
|
|
120
|
+
),
|
|
121
|
+
migrations.AddField(
|
|
122
|
+
model_name='organization',
|
|
123
|
+
name='updated_at',
|
|
124
|
+
field=models.DateTimeField(auto_now=True),
|
|
125
|
+
),
|
|
126
|
+
migrations.AddField(
|
|
127
|
+
model_name='organizationmodule',
|
|
128
|
+
name='is_active',
|
|
129
|
+
field=models.BooleanField(default=True),
|
|
130
|
+
),
|
|
131
|
+
migrations.AddField(
|
|
132
|
+
model_name='organizationrole',
|
|
133
|
+
name='created_at',
|
|
134
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
135
|
+
preserve_default=False,
|
|
136
|
+
),
|
|
137
|
+
migrations.AddField(
|
|
138
|
+
model_name='organizationrole',
|
|
139
|
+
name='is_active',
|
|
140
|
+
field=models.BooleanField(default=True),
|
|
141
|
+
),
|
|
142
|
+
migrations.AddField(
|
|
143
|
+
model_name='organizationrole',
|
|
144
|
+
name='updated_at',
|
|
145
|
+
field=models.DateTimeField(auto_now=True),
|
|
146
|
+
),
|
|
147
|
+
migrations.AddField(
|
|
148
|
+
model_name='organizationuser',
|
|
149
|
+
name='created_at',
|
|
150
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
151
|
+
preserve_default=False,
|
|
152
|
+
),
|
|
153
|
+
migrations.AddField(
|
|
154
|
+
model_name='organizationuser',
|
|
155
|
+
name='is_active',
|
|
156
|
+
field=models.BooleanField(default=True),
|
|
157
|
+
),
|
|
158
|
+
migrations.AddField(
|
|
159
|
+
model_name='organizationuser',
|
|
160
|
+
name='updated_at',
|
|
161
|
+
field=models.DateTimeField(auto_now=True),
|
|
162
|
+
),
|
|
163
|
+
migrations.AddField(
|
|
164
|
+
model_name='person',
|
|
165
|
+
name='created_at',
|
|
166
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
167
|
+
preserve_default=False,
|
|
168
|
+
),
|
|
169
|
+
migrations.AddField(
|
|
170
|
+
model_name='person',
|
|
171
|
+
name='is_active',
|
|
172
|
+
field=models.BooleanField(default=True),
|
|
173
|
+
),
|
|
174
|
+
migrations.AddField(
|
|
175
|
+
model_name='person',
|
|
176
|
+
name='updated_at',
|
|
177
|
+
field=models.DateTimeField(auto_now=True),
|
|
178
|
+
),
|
|
179
|
+
migrations.AddField(
|
|
180
|
+
model_name='personcontact',
|
|
181
|
+
name='created_at',
|
|
182
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
183
|
+
preserve_default=False,
|
|
184
|
+
),
|
|
185
|
+
migrations.AddField(
|
|
186
|
+
model_name='personcontact',
|
|
187
|
+
name='is_active',
|
|
188
|
+
field=models.BooleanField(default=True),
|
|
189
|
+
),
|
|
190
|
+
migrations.AddField(
|
|
191
|
+
model_name='personcontact',
|
|
192
|
+
name='updated_at',
|
|
193
|
+
field=models.DateTimeField(auto_now=True),
|
|
194
|
+
),
|
|
195
|
+
migrations.AddField(
|
|
196
|
+
model_name='persontag',
|
|
197
|
+
name='created_at',
|
|
198
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
199
|
+
preserve_default=False,
|
|
200
|
+
),
|
|
201
|
+
migrations.AddField(
|
|
202
|
+
model_name='persontag',
|
|
203
|
+
name='is_active',
|
|
204
|
+
field=models.BooleanField(default=True),
|
|
205
|
+
),
|
|
206
|
+
migrations.AddField(
|
|
207
|
+
model_name='persontag',
|
|
208
|
+
name='updated_at',
|
|
209
|
+
field=models.DateTimeField(auto_now=True),
|
|
210
|
+
),
|
|
211
|
+
migrations.AddField(
|
|
212
|
+
model_name='persontagged',
|
|
213
|
+
name='created_at',
|
|
214
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
215
|
+
preserve_default=False,
|
|
216
|
+
),
|
|
217
|
+
migrations.AddField(
|
|
218
|
+
model_name='persontagged',
|
|
219
|
+
name='is_active',
|
|
220
|
+
field=models.BooleanField(default=True),
|
|
221
|
+
),
|
|
222
|
+
migrations.AddField(
|
|
223
|
+
model_name='persontagged',
|
|
224
|
+
name='updated_at',
|
|
225
|
+
field=models.DateTimeField(auto_now=True),
|
|
226
|
+
),
|
|
227
|
+
migrations.AddField(
|
|
228
|
+
model_name='role',
|
|
229
|
+
name='created_at',
|
|
230
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
231
|
+
preserve_default=False,
|
|
232
|
+
),
|
|
233
|
+
migrations.AddField(
|
|
234
|
+
model_name='role',
|
|
235
|
+
name='is_active',
|
|
236
|
+
field=models.BooleanField(default=True),
|
|
237
|
+
),
|
|
238
|
+
migrations.AddField(
|
|
239
|
+
model_name='role',
|
|
240
|
+
name='updated_at',
|
|
241
|
+
field=models.DateTimeField(auto_now=True),
|
|
242
|
+
),
|
|
243
|
+
migrations.AddField(
|
|
244
|
+
model_name='system',
|
|
245
|
+
name='is_active',
|
|
246
|
+
field=models.BooleanField(default=True),
|
|
247
|
+
),
|
|
248
|
+
migrations.AddField(
|
|
249
|
+
model_name='tagcategory',
|
|
250
|
+
name='created_at',
|
|
251
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
252
|
+
preserve_default=False,
|
|
253
|
+
),
|
|
254
|
+
migrations.AddField(
|
|
255
|
+
model_name='tagcategory',
|
|
256
|
+
name='is_active',
|
|
257
|
+
field=models.BooleanField(default=True),
|
|
258
|
+
),
|
|
259
|
+
migrations.AddField(
|
|
260
|
+
model_name='tagcategory',
|
|
261
|
+
name='updated_at',
|
|
262
|
+
field=models.DateTimeField(auto_now=True),
|
|
263
|
+
),
|
|
264
|
+
migrations.AddField(
|
|
265
|
+
model_name='user',
|
|
266
|
+
name='created_at',
|
|
267
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
268
|
+
preserve_default=False,
|
|
269
|
+
),
|
|
270
|
+
migrations.AddField(
|
|
271
|
+
model_name='user',
|
|
272
|
+
name='is_active',
|
|
273
|
+
field=models.BooleanField(default=True),
|
|
274
|
+
),
|
|
275
|
+
migrations.AddField(
|
|
276
|
+
model_name='user',
|
|
277
|
+
name='updated_at',
|
|
278
|
+
field=models.DateTimeField(auto_now=True),
|
|
279
|
+
),
|
|
280
|
+
migrations.AddField(
|
|
281
|
+
model_name='usercompanyaccess',
|
|
282
|
+
name='created_at',
|
|
283
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
284
|
+
preserve_default=False,
|
|
285
|
+
),
|
|
286
|
+
migrations.AddField(
|
|
287
|
+
model_name='usercompanyaccess',
|
|
288
|
+
name='is_active',
|
|
289
|
+
field=models.BooleanField(default=True),
|
|
290
|
+
),
|
|
291
|
+
migrations.AddField(
|
|
292
|
+
model_name='usercompanyaccess',
|
|
293
|
+
name='updated_at',
|
|
294
|
+
field=models.DateTimeField(auto_now=True),
|
|
295
|
+
),
|
|
296
|
+
migrations.AddField(
|
|
297
|
+
model_name='usergroup',
|
|
298
|
+
name='created_at',
|
|
299
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
300
|
+
preserve_default=False,
|
|
301
|
+
),
|
|
302
|
+
migrations.AddField(
|
|
303
|
+
model_name='usergroup',
|
|
304
|
+
name='is_active',
|
|
305
|
+
field=models.BooleanField(default=True),
|
|
306
|
+
),
|
|
307
|
+
migrations.AddField(
|
|
308
|
+
model_name='usergroup',
|
|
309
|
+
name='updated_at',
|
|
310
|
+
field=models.DateTimeField(auto_now=True),
|
|
311
|
+
),
|
|
312
|
+
migrations.AddField(
|
|
313
|
+
model_name='userrole',
|
|
314
|
+
name='created_at',
|
|
315
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
316
|
+
preserve_default=False,
|
|
317
|
+
),
|
|
318
|
+
migrations.AddField(
|
|
319
|
+
model_name='userrole',
|
|
320
|
+
name='is_active',
|
|
321
|
+
field=models.BooleanField(default=True),
|
|
322
|
+
),
|
|
323
|
+
migrations.AddField(
|
|
324
|
+
model_name='userrole',
|
|
325
|
+
name='updated_at',
|
|
326
|
+
field=models.DateTimeField(auto_now=True),
|
|
327
|
+
),
|
|
328
|
+
migrations.AlterField(
|
|
329
|
+
model_name='entityauth',
|
|
330
|
+
name='is_active',
|
|
331
|
+
field=models.BooleanField(default=True),
|
|
332
|
+
),
|
|
333
|
+
migrations.AlterField(
|
|
334
|
+
model_name='system',
|
|
335
|
+
name='created_at',
|
|
336
|
+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
|
337
|
+
preserve_default=False,
|
|
338
|
+
),
|
|
339
|
+
migrations.AlterField(
|
|
340
|
+
model_name='system',
|
|
341
|
+
name='updated_at',
|
|
342
|
+
field=models.DateTimeField(auto_now=True, default=django.utils.timezone.now),
|
|
343
|
+
preserve_default=False,
|
|
344
|
+
),
|
|
345
|
+
]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Generated manually on 2026-02-02 for automations schema
|
|
2
|
+
|
|
3
|
+
import uuid
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.db import migrations, models
|
|
6
|
+
import django.db.models.deletion
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Migration(migrations.Migration):
|
|
10
|
+
|
|
11
|
+
dependencies = [
|
|
12
|
+
('constec_db', '0004_rename_entities_company_cuit_idx_entities_company_e2c50f_idx_and_more'),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
migrations.CreateModel(
|
|
17
|
+
name='Event',
|
|
18
|
+
fields=[
|
|
19
|
+
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
|
20
|
+
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
21
|
+
('updated_at', models.DateTimeField(auto_now=True)),
|
|
22
|
+
('event_type', models.CharField(choices=[('notification', 'Notification'), ('automation', 'Automation')], max_length=50)),
|
|
23
|
+
('title', models.CharField(max_length=255)),
|
|
24
|
+
('description', models.TextField(blank=True)),
|
|
25
|
+
('status', models.CharField(choices=[('active', 'Active'), ('paused', 'Paused'), ('completed', 'Completed'), ('failed', 'Failed'), ('cancelled', 'Cancelled')], default='active', max_length=20)),
|
|
26
|
+
('recurrence_type', models.CharField(choices=[('punctual', 'Punctual'), ('periodic', 'Periodic')], help_text='Tipo de recurrencia: puntual (fechas específicas) o periódico', max_length=20)),
|
|
27
|
+
('recurrence_config', models.JSONField(help_text='Configuración de recurrencia en formato JSON')),
|
|
28
|
+
('config', models.JSONField(default=dict, help_text='Configuración específica según event_type (mensaje, URL, etc.)')),
|
|
29
|
+
('next_execution_at', models.DateTimeField(blank=True, db_index=True, help_text='Próxima fecha/hora de ejecución calculada', null=True)),
|
|
30
|
+
('last_executed_at', models.DateTimeField(blank=True, help_text='Última vez que se ejecutó', null=True)),
|
|
31
|
+
('execution_count', models.IntegerField(default=0, help_text='Cantidad de veces que se ha ejecutado')),
|
|
32
|
+
('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='constec_db.company')),
|
|
33
|
+
('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='created_events', to=settings.AUTH_USER_MODEL)),
|
|
34
|
+
],
|
|
35
|
+
options={
|
|
36
|
+
'db_table': '"automations"."events"',
|
|
37
|
+
'ordering': ['next_execution_at'],
|
|
38
|
+
'indexes': [
|
|
39
|
+
models.Index(fields=['company', 'event_type'], name='automations_company_ebe85a_idx'),
|
|
40
|
+
models.Index(fields=['status', 'next_execution_at'], name='automations_status_a3d45f_idx'),
|
|
41
|
+
models.Index(fields=['recurrence_type'], name='automations_recurre_5d8b2c_idx'),
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
bases=(models.Model,),
|
|
45
|
+
),
|
|
46
|
+
]
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# Generated manually on 2026-02-03 for automations redesign (Fase 1)
|
|
2
|
+
|
|
3
|
+
import uuid
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.db import migrations, models
|
|
6
|
+
import django.db.models.deletion
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Migration(migrations.Migration):
|
|
10
|
+
|
|
11
|
+
dependencies = [
|
|
12
|
+
('constec_db', '0005_event'),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
# Create Automation model
|
|
17
|
+
migrations.CreateModel(
|
|
18
|
+
name='Automation',
|
|
19
|
+
fields=[
|
|
20
|
+
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
|
21
|
+
('is_active', models.BooleanField(default=True)),
|
|
22
|
+
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
23
|
+
('updated_at', models.DateTimeField(auto_now=True)),
|
|
24
|
+
('name', models.CharField(max_length=255)),
|
|
25
|
+
('description', models.TextField(blank=True)),
|
|
26
|
+
('status', models.CharField(
|
|
27
|
+
choices=[('active', 'Active'), ('paused', 'Paused'), ('archived', 'Archived'), ('draft', 'Draft')],
|
|
28
|
+
default='draft',
|
|
29
|
+
max_length=20
|
|
30
|
+
)),
|
|
31
|
+
('execution_mode', models.CharField(
|
|
32
|
+
choices=[('sequential', 'Sequential'), ('parallel', 'Parallel')],
|
|
33
|
+
default='sequential',
|
|
34
|
+
max_length=20
|
|
35
|
+
)),
|
|
36
|
+
('max_executions', models.IntegerField(
|
|
37
|
+
blank=True,
|
|
38
|
+
help_text='Máximo número de ejecuciones (null = ilimitado)',
|
|
39
|
+
null=True
|
|
40
|
+
)),
|
|
41
|
+
('execution_count', models.IntegerField(default=0)),
|
|
42
|
+
('on_error', models.CharField(
|
|
43
|
+
choices=[('stop', 'Stop'), ('continue', 'Continue'), ('retry', 'Retry')],
|
|
44
|
+
default='stop',
|
|
45
|
+
max_length=20
|
|
46
|
+
)),
|
|
47
|
+
('retry_count', models.IntegerField(default=3)),
|
|
48
|
+
('retry_delay_seconds', models.IntegerField(default=60)),
|
|
49
|
+
('last_executed_at', models.DateTimeField(blank=True, null=True)),
|
|
50
|
+
('next_execution_at', models.DateTimeField(blank=True, db_index=True, null=True)),
|
|
51
|
+
('tags', models.JSONField(blank=True, default=list)),
|
|
52
|
+
('metadata', models.JSONField(blank=True, default=dict)),
|
|
53
|
+
('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='constec_db.company')),
|
|
54
|
+
('created_by', models.ForeignKey(
|
|
55
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
56
|
+
related_name='created_automations',
|
|
57
|
+
to=settings.AUTH_USER_MODEL
|
|
58
|
+
)),
|
|
59
|
+
],
|
|
60
|
+
options={
|
|
61
|
+
'db_table': '"automations"."automations"',
|
|
62
|
+
'ordering': ['-created_at'],
|
|
63
|
+
'indexes': [
|
|
64
|
+
models.Index(fields=['company', 'status'], name='automations_auto_company_status_idx'),
|
|
65
|
+
models.Index(fields=['status', 'next_execution_at'], name='automations_auto_status_next_idx'),
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
bases=(models.Model,),
|
|
69
|
+
),
|
|
70
|
+
|
|
71
|
+
# Create Trigger model
|
|
72
|
+
migrations.CreateModel(
|
|
73
|
+
name='Trigger',
|
|
74
|
+
fields=[
|
|
75
|
+
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
|
76
|
+
('is_active', models.BooleanField(default=True)),
|
|
77
|
+
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
78
|
+
('updated_at', models.DateTimeField(auto_now=True)),
|
|
79
|
+
('trigger_type', models.CharField(
|
|
80
|
+
choices=[('schedule', 'Schedule'), ('webhook', 'Webhook'), ('manual', 'Manual'), ('event', 'Event')],
|
|
81
|
+
max_length=20
|
|
82
|
+
)),
|
|
83
|
+
('name', models.CharField(max_length=255)),
|
|
84
|
+
('description', models.TextField(blank=True)),
|
|
85
|
+
('is_enabled', models.BooleanField(default=True)),
|
|
86
|
+
('config', models.JSONField(
|
|
87
|
+
default=dict,
|
|
88
|
+
help_text='Configuración específica del tipo de trigger (schedule, webhook, etc.)'
|
|
89
|
+
)),
|
|
90
|
+
('last_triggered_at', models.DateTimeField(blank=True, null=True)),
|
|
91
|
+
('trigger_count', models.IntegerField(default=0)),
|
|
92
|
+
('priority', models.IntegerField(default=50, help_text='0-100, mayor = más prioridad')),
|
|
93
|
+
('automation', models.ForeignKey(
|
|
94
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
95
|
+
related_name='triggers',
|
|
96
|
+
to='constec_db.automation'
|
|
97
|
+
)),
|
|
98
|
+
],
|
|
99
|
+
options={
|
|
100
|
+
'db_table': '"automations"."triggers"',
|
|
101
|
+
'ordering': ['-priority', 'created_at'],
|
|
102
|
+
'indexes': [
|
|
103
|
+
models.Index(fields=['automation', 'is_enabled'], name='automations_trig_automation_enabled_idx'),
|
|
104
|
+
models.Index(fields=['trigger_type', 'is_enabled'], name='automations_trig_type_enabled_idx'),
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
bases=(models.Model,),
|
|
108
|
+
),
|
|
109
|
+
|
|
110
|
+
# Create Action model
|
|
111
|
+
migrations.CreateModel(
|
|
112
|
+
name='Action',
|
|
113
|
+
fields=[
|
|
114
|
+
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
|
115
|
+
('is_active', models.BooleanField(default=True)),
|
|
116
|
+
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
117
|
+
('updated_at', models.DateTimeField(auto_now=True)),
|
|
118
|
+
('action_type', models.CharField(
|
|
119
|
+
choices=[('notification', 'Notification'), ('webhook', 'Webhook'), ('batch_task', 'Batch Task'), ('flow_execution', 'Flow Execution')],
|
|
120
|
+
max_length=20
|
|
121
|
+
)),
|
|
122
|
+
('name', models.CharField(max_length=255)),
|
|
123
|
+
('description', models.TextField(blank=True)),
|
|
124
|
+
('is_enabled', models.BooleanField(default=True)),
|
|
125
|
+
('order', models.IntegerField(default=0, help_text='Orden de ejecución')),
|
|
126
|
+
('config', models.JSONField(
|
|
127
|
+
default=dict,
|
|
128
|
+
help_text='Configuración específica del tipo de acción'
|
|
129
|
+
)),
|
|
130
|
+
('on_error', models.CharField(
|
|
131
|
+
blank=True,
|
|
132
|
+
choices=[('stop', 'Stop'), ('continue', 'Continue'), ('retry', 'Retry')],
|
|
133
|
+
help_text='Override del on_error de la automation',
|
|
134
|
+
max_length=20,
|
|
135
|
+
null=True
|
|
136
|
+
)),
|
|
137
|
+
('retry_count', models.IntegerField(
|
|
138
|
+
blank=True,
|
|
139
|
+
help_text='Override del retry_count de la automation',
|
|
140
|
+
null=True
|
|
141
|
+
)),
|
|
142
|
+
('condition', models.JSONField(
|
|
143
|
+
blank=True,
|
|
144
|
+
help_text='Condición JSONLogic para ejecutar esta acción',
|
|
145
|
+
null=True
|
|
146
|
+
)),
|
|
147
|
+
('last_executed_at', models.DateTimeField(blank=True, null=True)),
|
|
148
|
+
('execution_count', models.IntegerField(default=0)),
|
|
149
|
+
('success_count', models.IntegerField(default=0)),
|
|
150
|
+
('failure_count', models.IntegerField(default=0)),
|
|
151
|
+
('automation', models.ForeignKey(
|
|
152
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
153
|
+
related_name='actions',
|
|
154
|
+
to='constec_db.automation'
|
|
155
|
+
)),
|
|
156
|
+
],
|
|
157
|
+
options={
|
|
158
|
+
'db_table': '"automations"."actions"',
|
|
159
|
+
'ordering': ['order', 'created_at'],
|
|
160
|
+
'indexes': [
|
|
161
|
+
models.Index(fields=['automation', 'order'], name='automations_act_automation_order_idx'),
|
|
162
|
+
models.Index(fields=['action_type', 'is_enabled'], name='automations_act_type_enabled_idx'),
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
bases=(models.Model,),
|
|
166
|
+
),
|
|
167
|
+
|
|
168
|
+
# Create ExecutionLog model
|
|
169
|
+
migrations.CreateModel(
|
|
170
|
+
name='ExecutionLog',
|
|
171
|
+
fields=[
|
|
172
|
+
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
|
173
|
+
('is_active', models.BooleanField(default=True)),
|
|
174
|
+
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
175
|
+
('updated_at', models.DateTimeField(auto_now=True)),
|
|
176
|
+
('status', models.CharField(
|
|
177
|
+
choices=[('pending', 'Pending'), ('running', 'Running'), ('completed', 'Completed'), ('failed', 'Failed'), ('partial', 'Partial')],
|
|
178
|
+
default='pending',
|
|
179
|
+
max_length=20
|
|
180
|
+
)),
|
|
181
|
+
('triggered_by', models.CharField(
|
|
182
|
+
choices=[('schedule', 'Schedule'), ('webhook', 'Webhook'), ('manual', 'Manual'), ('system', 'System')],
|
|
183
|
+
max_length=20
|
|
184
|
+
)),
|
|
185
|
+
('started_at', models.DateTimeField(auto_now_add=True)),
|
|
186
|
+
('completed_at', models.DateTimeField(blank=True, null=True)),
|
|
187
|
+
('duration_seconds', models.IntegerField(blank=True, null=True)),
|
|
188
|
+
('execution_context', models.JSONField(
|
|
189
|
+
default=dict,
|
|
190
|
+
help_text='Variables y contexto disponible durante la ejecución'
|
|
191
|
+
)),
|
|
192
|
+
('actions_total', models.IntegerField(default=0)),
|
|
193
|
+
('actions_succeeded', models.IntegerField(default=0)),
|
|
194
|
+
('actions_failed', models.IntegerField(default=0)),
|
|
195
|
+
('actions_skipped', models.IntegerField(default=0)),
|
|
196
|
+
('action_logs', models.JSONField(
|
|
197
|
+
default=list,
|
|
198
|
+
help_text='Array de logs detallados de cada acción ejecutada'
|
|
199
|
+
)),
|
|
200
|
+
('error_message', models.TextField(blank=True)),
|
|
201
|
+
('error_traceback', models.TextField(blank=True)),
|
|
202
|
+
('automation', models.ForeignKey(
|
|
203
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
204
|
+
related_name='execution_logs',
|
|
205
|
+
to='constec_db.automation'
|
|
206
|
+
)),
|
|
207
|
+
('trigger', models.ForeignKey(
|
|
208
|
+
blank=True,
|
|
209
|
+
null=True,
|
|
210
|
+
on_delete=django.db.models.deletion.SET_NULL,
|
|
211
|
+
related_name='execution_logs',
|
|
212
|
+
to='constec_db.trigger'
|
|
213
|
+
)),
|
|
214
|
+
('triggered_by_user', models.ForeignKey(
|
|
215
|
+
blank=True,
|
|
216
|
+
null=True,
|
|
217
|
+
on_delete=django.db.models.deletion.SET_NULL,
|
|
218
|
+
related_name='triggered_executions',
|
|
219
|
+
to=settings.AUTH_USER_MODEL
|
|
220
|
+
)),
|
|
221
|
+
],
|
|
222
|
+
options={
|
|
223
|
+
'db_table': '"automations"."execution_logs"',
|
|
224
|
+
'ordering': ['-started_at'],
|
|
225
|
+
'indexes': [
|
|
226
|
+
models.Index(fields=['automation', 'started_at'], name='automations_exec_automation_started_idx'),
|
|
227
|
+
models.Index(fields=['status', 'started_at'], name='automations_exec_status_started_idx'),
|
|
228
|
+
models.Index(fields=['triggered_by', 'started_at'], name='automations_exec_triggered_started_idx'),
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
bases=(models.Model,),
|
|
232
|
+
),
|
|
233
|
+
|
|
234
|
+
# Create NotificationTemplate model
|
|
235
|
+
migrations.CreateModel(
|
|
236
|
+
name='NotificationTemplate',
|
|
237
|
+
fields=[
|
|
238
|
+
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
|
239
|
+
('is_active', models.BooleanField(default=True)),
|
|
240
|
+
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
241
|
+
('updated_at', models.DateTimeField(auto_now=True)),
|
|
242
|
+
('name', models.CharField(max_length=255)),
|
|
243
|
+
('description', models.TextField(blank=True)),
|
|
244
|
+
('channel', models.CharField(
|
|
245
|
+
choices=[('email', 'Email'), ('whatsapp', 'WhatsApp'), ('sms', 'SMS'), ('push', 'Push Notification')],
|
|
246
|
+
max_length=20
|
|
247
|
+
)),
|
|
248
|
+
('subject', models.CharField(
|
|
249
|
+
blank=True,
|
|
250
|
+
help_text='Asunto (solo para email)',
|
|
251
|
+
max_length=255
|
|
252
|
+
)),
|
|
253
|
+
('body', models.TextField(help_text='Cuerpo del mensaje con variables {{variable}}')),
|
|
254
|
+
('variables', models.JSONField(
|
|
255
|
+
default=list,
|
|
256
|
+
help_text="Array de nombres de variables esperadas ['customer_name', 'amount']"
|
|
257
|
+
)),
|
|
258
|
+
# is_active inherited from UUIDModel
|
|
259
|
+
('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='constec_db.company')),
|
|
260
|
+
('created_by', models.ForeignKey(
|
|
261
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
262
|
+
related_name='created_templates',
|
|
263
|
+
to=settings.AUTH_USER_MODEL
|
|
264
|
+
)),
|
|
265
|
+
],
|
|
266
|
+
options={
|
|
267
|
+
'db_table': '"automations"."notification_templates"',
|
|
268
|
+
'ordering': ['name'],
|
|
269
|
+
'indexes': [
|
|
270
|
+
models.Index(fields=['company', 'channel', 'is_active'], name='automations_tmpl_company_channel_idx'),
|
|
271
|
+
],
|
|
272
|
+
},
|
|
273
|
+
bases=(models.Model,),
|
|
274
|
+
),
|
|
275
|
+
]
|