constec 0.5.1__tar.gz → 0.5.3__tar.gz

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.
Files changed (43) hide show
  1. {constec-0.5.1 → constec-0.5.3}/PKG-INFO +1 -1
  2. {constec-0.5.1 → constec-0.5.3}/constec/db/migrations/0006_automation_trigger_action_executionlog_notificationtemplate.py +5 -0
  3. constec-0.5.3/constec/db/migrations/0007_add_organization_to_automations.py +91 -0
  4. {constec-0.5.1 → constec-0.5.3}/constec/db/models/automation.py +50 -4
  5. {constec-0.5.1 → constec-0.5.3}/constec.egg-info/PKG-INFO +1 -1
  6. {constec-0.5.1 → constec-0.5.3}/constec.egg-info/SOURCES.txt +1 -0
  7. {constec-0.5.1 → constec-0.5.3}/pyproject.toml +1 -1
  8. {constec-0.5.1 → constec-0.5.3}/LICENSE +0 -0
  9. {constec-0.5.1 → constec-0.5.3}/README.md +0 -0
  10. {constec-0.5.1 → constec-0.5.3}/constec/db/__init__.py +0 -0
  11. {constec-0.5.1 → constec-0.5.3}/constec/db/apps.py +0 -0
  12. {constec-0.5.1 → constec-0.5.3}/constec/db/migrations/0001_initial.py +0 -0
  13. {constec-0.5.1 → constec-0.5.3}/constec/db/migrations/0002_module_level.py +0 -0
  14. {constec-0.5.1 → constec-0.5.3}/constec/db/migrations/0003_remove_module_level.py +0 -0
  15. {constec-0.5.1 → constec-0.5.3}/constec/db/migrations/0004_rename_entities_company_cuit_idx_entities_company_e2c50f_idx_and_more.py +0 -0
  16. {constec-0.5.1 → constec-0.5.3}/constec/db/migrations/0005_event.py +0 -0
  17. {constec-0.5.1 → constec-0.5.3}/constec/db/migrations/__init__.py +0 -0
  18. {constec-0.5.1 → constec-0.5.3}/constec/db/models/__init__.py +0 -0
  19. {constec-0.5.1 → constec-0.5.3}/constec/db/models/base.py +0 -0
  20. {constec-0.5.1 → constec-0.5.3}/constec/db/models/company.py +0 -0
  21. {constec-0.5.1 → constec-0.5.3}/constec/db/models/contact.py +0 -0
  22. {constec-0.5.1 → constec-0.5.3}/constec/db/models/erp.py +0 -0
  23. {constec-0.5.1 → constec-0.5.3}/constec/db/models/erp_entity.py +0 -0
  24. {constec-0.5.1 → constec-0.5.3}/constec/db/models/flow.py +0 -0
  25. {constec-0.5.1 → constec-0.5.3}/constec/db/models/group.py +0 -0
  26. {constec-0.5.1 → constec-0.5.3}/constec/db/models/module.py +0 -0
  27. {constec-0.5.1 → constec-0.5.3}/constec/db/models/organization.py +0 -0
  28. {constec-0.5.1 → constec-0.5.3}/constec/db/models/person.py +0 -0
  29. {constec-0.5.1 → constec-0.5.3}/constec/db/models/session.py +0 -0
  30. {constec-0.5.1 → constec-0.5.3}/constec/db/models/tag.py +0 -0
  31. {constec-0.5.1 → constec-0.5.3}/constec/db/models/user.py +0 -0
  32. {constec-0.5.1 → constec-0.5.3}/constec/py.typed +0 -0
  33. {constec-0.5.1 → constec-0.5.3}/constec/services/__init__.py +0 -0
  34. {constec-0.5.1 → constec-0.5.3}/constec/services/encryption.py +0 -0
  35. {constec-0.5.1 → constec-0.5.3}/constec/shared/__init__.py +0 -0
  36. {constec-0.5.1 → constec-0.5.3}/constec/shared/exceptions.py +0 -0
  37. {constec-0.5.1 → constec-0.5.3}/constec/utils/__init__.py +0 -0
  38. {constec-0.5.1 → constec-0.5.3}/constec/utils/cuit.py +0 -0
  39. {constec-0.5.1 → constec-0.5.3}/constec/utils/password.py +0 -0
  40. {constec-0.5.1 → constec-0.5.3}/constec.egg-info/dependency_links.txt +0 -0
  41. {constec-0.5.1 → constec-0.5.3}/constec.egg-info/requires.txt +0 -0
  42. {constec-0.5.1 → constec-0.5.3}/constec.egg-info/top_level.txt +0 -0
  43. {constec-0.5.1 → constec-0.5.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: constec
3
- Version: 0.5.1
3
+ Version: 0.5.3
4
4
  Summary: Base library for the Constec ecosystem - shared utilities, models, and namespace foundation
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/TpmyCT/constec-python
@@ -18,6 +18,7 @@ class Migration(migrations.Migration):
18
18
  name='Automation',
19
19
  fields=[
20
20
  ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
21
+ ('is_active', models.BooleanField(default=True)),
21
22
  ('created_at', models.DateTimeField(auto_now_add=True)),
22
23
  ('updated_at', models.DateTimeField(auto_now=True)),
23
24
  ('name', models.CharField(max_length=255)),
@@ -72,6 +73,7 @@ class Migration(migrations.Migration):
72
73
  name='Trigger',
73
74
  fields=[
74
75
  ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
76
+ ('is_active', models.BooleanField(default=True)),
75
77
  ('created_at', models.DateTimeField(auto_now_add=True)),
76
78
  ('updated_at', models.DateTimeField(auto_now=True)),
77
79
  ('trigger_type', models.CharField(
@@ -110,6 +112,7 @@ class Migration(migrations.Migration):
110
112
  name='Action',
111
113
  fields=[
112
114
  ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
115
+ ('is_active', models.BooleanField(default=True)),
113
116
  ('created_at', models.DateTimeField(auto_now_add=True)),
114
117
  ('updated_at', models.DateTimeField(auto_now=True)),
115
118
  ('action_type', models.CharField(
@@ -167,6 +170,7 @@ class Migration(migrations.Migration):
167
170
  name='ExecutionLog',
168
171
  fields=[
169
172
  ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
173
+ ('is_active', models.BooleanField(default=True)),
170
174
  ('created_at', models.DateTimeField(auto_now_add=True)),
171
175
  ('updated_at', models.DateTimeField(auto_now=True)),
172
176
  ('status', models.CharField(
@@ -232,6 +236,7 @@ class Migration(migrations.Migration):
232
236
  name='NotificationTemplate',
233
237
  fields=[
234
238
  ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
239
+ ('is_active', models.BooleanField(default=True)),
235
240
  ('created_at', models.DateTimeField(auto_now_add=True)),
236
241
  ('updated_at', models.DateTimeField(auto_now=True)),
237
242
  ('name', models.CharField(max_length=255)),
@@ -0,0 +1,91 @@
1
+ # Generated manually for constec automation organization support
2
+
3
+ from django.db import migrations, models
4
+ import django.db.models.deletion
5
+ from django.db.models import Q
6
+
7
+
8
+ class Migration(migrations.Migration):
9
+
10
+ dependencies = [
11
+ ('constec_db', '0006_automation_trigger_action_executionlog_notificationtemplate'),
12
+ ]
13
+
14
+ operations = [
15
+ # Add organization field to Automation
16
+ migrations.AddField(
17
+ model_name='automation',
18
+ name='organization',
19
+ field=models.ForeignKey(
20
+ blank=True,
21
+ db_index=True,
22
+ help_text='Organization para automations compartidas (opcional si se define company)',
23
+ null=True,
24
+ on_delete=django.db.models.deletion.CASCADE,
25
+ to='constec_db.organization'
26
+ ),
27
+ ),
28
+ # Make company field nullable in Automation
29
+ migrations.AlterField(
30
+ model_name='automation',
31
+ name='company',
32
+ field=models.ForeignKey(
33
+ blank=True,
34
+ db_index=True,
35
+ help_text='Company específica (opcional si se define organization)',
36
+ null=True,
37
+ on_delete=django.db.models.deletion.CASCADE,
38
+ to='constec_db.company'
39
+ ),
40
+ ),
41
+ # Add organization field to NotificationTemplate
42
+ migrations.AddField(
43
+ model_name='notificationtemplate',
44
+ name='organization',
45
+ field=models.ForeignKey(
46
+ blank=True,
47
+ db_index=True,
48
+ help_text='Organization para templates compartidos (opcional si se define company)',
49
+ null=True,
50
+ on_delete=django.db.models.deletion.CASCADE,
51
+ to='constec_db.organization'
52
+ ),
53
+ ),
54
+ # Make company field nullable in NotificationTemplate
55
+ migrations.AlterField(
56
+ model_name='notificationtemplate',
57
+ name='company',
58
+ field=models.ForeignKey(
59
+ blank=True,
60
+ db_index=True,
61
+ help_text='Company específica (opcional si se define organization)',
62
+ null=True,
63
+ on_delete=django.db.models.deletion.CASCADE,
64
+ to='constec_db.company'
65
+ ),
66
+ ),
67
+ # Add indexes for organization
68
+ migrations.AddIndex(
69
+ model_name='automation',
70
+ index=models.Index(fields=['organization', 'status'], name='automations_org_status_idx'),
71
+ ),
72
+ migrations.AddIndex(
73
+ model_name='notificationtemplate',
74
+ index=models.Index(fields=['organization', 'channel', 'is_active'], name='templates_org_channel_active_idx'),
75
+ ),
76
+ # Add constraint: at least one of company or organization must be set
77
+ migrations.AddConstraint(
78
+ model_name='automation',
79
+ constraint=models.CheckConstraint(
80
+ check=Q(company__isnull=False) | Q(organization__isnull=False),
81
+ name='automation_requires_company_or_organization'
82
+ ),
83
+ ),
84
+ migrations.AddConstraint(
85
+ model_name='notificationtemplate',
86
+ constraint=models.CheckConstraint(
87
+ check=Q(company__isnull=False) | Q(organization__isnull=False),
88
+ name='template_requires_company_or_organization'
89
+ ),
90
+ ),
91
+ ]
@@ -2,9 +2,11 @@
2
2
 
3
3
  import uuid
4
4
  from django.db import models
5
+ from django.db.models import Q
5
6
  from django.core.exceptions import ValidationError
6
7
  from .base import UUIDModel
7
8
  from .company import Company
9
+ from .organization import Organization
8
10
  from .user import User
9
11
 
10
12
 
@@ -34,8 +36,23 @@ class Automation(UUIDModel):
34
36
  ('retry', 'Retry'),
35
37
  ]
36
38
 
37
- # FKs
38
- company = models.ForeignKey(Company, on_delete=models.CASCADE, db_index=True)
39
+ # FKs - Al menos uno debe estar presente
40
+ company = models.ForeignKey(
41
+ Company,
42
+ on_delete=models.CASCADE,
43
+ null=True,
44
+ blank=True,
45
+ db_index=True,
46
+ help_text="Company específica (opcional si se define organization)"
47
+ )
48
+ organization = models.ForeignKey(
49
+ Organization,
50
+ on_delete=models.CASCADE,
51
+ null=True,
52
+ blank=True,
53
+ db_index=True,
54
+ help_text="Organization para automations compartidas (opcional si se define company)"
55
+ )
39
56
  created_by = models.ForeignKey(
40
57
  User,
41
58
  on_delete=models.CASCADE,
@@ -82,9 +99,16 @@ class Automation(UUIDModel):
82
99
  app_label = 'constec_db'
83
100
  indexes = [
84
101
  models.Index(fields=['company', 'status']),
102
+ models.Index(fields=['organization', 'status']),
85
103
  models.Index(fields=['status', 'next_execution_at']),
86
104
  ]
87
105
  ordering = ['-created_at']
106
+ constraints = [
107
+ models.CheckConstraint(
108
+ check=Q(company__isnull=False) | Q(organization__isnull=False),
109
+ name='automation_requires_company_or_organization'
110
+ )
111
+ ]
88
112
 
89
113
  def __str__(self):
90
114
  return f"{self.name} ({self.status})"
@@ -333,8 +357,23 @@ class NotificationTemplate(UUIDModel):
333
357
  ('push', 'Push Notification'),
334
358
  ]
335
359
 
336
- # FKs
337
- company = models.ForeignKey(Company, on_delete=models.CASCADE, db_index=True)
360
+ # FKs - Al menos uno debe estar presente
361
+ company = models.ForeignKey(
362
+ Company,
363
+ on_delete=models.CASCADE,
364
+ null=True,
365
+ blank=True,
366
+ db_index=True,
367
+ help_text="Company específica (opcional si se define organization)"
368
+ )
369
+ organization = models.ForeignKey(
370
+ Organization,
371
+ on_delete=models.CASCADE,
372
+ null=True,
373
+ blank=True,
374
+ db_index=True,
375
+ help_text="Organization para templates compartidos (opcional si se define company)"
376
+ )
338
377
  created_by = models.ForeignKey(
339
378
  User,
340
379
  on_delete=models.CASCADE,
@@ -367,8 +406,15 @@ class NotificationTemplate(UUIDModel):
367
406
  app_label = 'constec_db'
368
407
  indexes = [
369
408
  models.Index(fields=['company', 'channel', 'is_active']),
409
+ models.Index(fields=['organization', 'channel', 'is_active']),
370
410
  ]
371
411
  ordering = ['name']
412
+ constraints = [
413
+ models.CheckConstraint(
414
+ check=Q(company__isnull=False) | Q(organization__isnull=False),
415
+ name='template_requires_company_or_organization'
416
+ )
417
+ ]
372
418
 
373
419
  def __str__(self):
374
420
  return f"{self.channel}: {self.name}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: constec
3
- Version: 0.5.1
3
+ Version: 0.5.3
4
4
  Summary: Base library for the Constec ecosystem - shared utilities, models, and namespace foundation
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/TpmyCT/constec-python
@@ -15,6 +15,7 @@ constec/db/migrations/0003_remove_module_level.py
15
15
  constec/db/migrations/0004_rename_entities_company_cuit_idx_entities_company_e2c50f_idx_and_more.py
16
16
  constec/db/migrations/0005_event.py
17
17
  constec/db/migrations/0006_automation_trigger_action_executionlog_notificationtemplate.py
18
+ constec/db/migrations/0007_add_organization_to_automations.py
18
19
  constec/db/migrations/__init__.py
19
20
  constec/db/models/__init__.py
20
21
  constec/db/models/automation.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "constec"
7
- version = "0.5.1"
7
+ version = "0.5.3"
8
8
  description = "Base library for the Constec ecosystem - shared utilities, models, and namespace foundation"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes