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
|
@@ -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
|
+
]
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Generated manually - Refactor creator fields to support User and OrganizationUser
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
import django.db.models.deletion
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def migrate_creator_data(apps, schema_editor):
|
|
8
|
+
"""Migrate existing created_by data to created_by_user."""
|
|
9
|
+
Automation = apps.get_model('constec_db', 'Automation')
|
|
10
|
+
NotificationTemplate = apps.get_model('constec_db', 'NotificationTemplate')
|
|
11
|
+
|
|
12
|
+
# Migrate Automation creators
|
|
13
|
+
for automation in Automation.objects.all():
|
|
14
|
+
if automation.created_by:
|
|
15
|
+
automation.created_by_user = automation.created_by
|
|
16
|
+
automation.save(update_fields=['created_by_user'])
|
|
17
|
+
|
|
18
|
+
# Migrate NotificationTemplate creators
|
|
19
|
+
for template in NotificationTemplate.objects.all():
|
|
20
|
+
if template.created_by:
|
|
21
|
+
template.created_by_user = template.created_by
|
|
22
|
+
template.save(update_fields=['created_by_user'])
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Migration(migrations.Migration):
|
|
26
|
+
|
|
27
|
+
dependencies = [
|
|
28
|
+
('constec_db', '0007_add_organization_to_automations'),
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
operations = [
|
|
32
|
+
# 1. Add new creator fields to Automation (nullable temporarily for data migration)
|
|
33
|
+
migrations.AddField(
|
|
34
|
+
model_name='automation',
|
|
35
|
+
name='created_by_user',
|
|
36
|
+
field=models.ForeignKey(
|
|
37
|
+
blank=True,
|
|
38
|
+
help_text='User creator (company-level)',
|
|
39
|
+
null=True,
|
|
40
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
41
|
+
related_name='created_automations',
|
|
42
|
+
to='constec_db.user'
|
|
43
|
+
),
|
|
44
|
+
),
|
|
45
|
+
migrations.AddField(
|
|
46
|
+
model_name='automation',
|
|
47
|
+
name='created_by_org_user',
|
|
48
|
+
field=models.ForeignKey(
|
|
49
|
+
blank=True,
|
|
50
|
+
help_text='OrganizationUser creator (org-level)',
|
|
51
|
+
null=True,
|
|
52
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
53
|
+
related_name='created_automations',
|
|
54
|
+
to='constec_db.organizationuser'
|
|
55
|
+
),
|
|
56
|
+
),
|
|
57
|
+
|
|
58
|
+
# 2. Add new creator fields to NotificationTemplate (nullable temporarily for data migration)
|
|
59
|
+
migrations.AddField(
|
|
60
|
+
model_name='notificationtemplate',
|
|
61
|
+
name='created_by_user',
|
|
62
|
+
field=models.ForeignKey(
|
|
63
|
+
blank=True,
|
|
64
|
+
help_text='User creator (company-level)',
|
|
65
|
+
null=True,
|
|
66
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
67
|
+
related_name='created_templates',
|
|
68
|
+
to='constec_db.user'
|
|
69
|
+
),
|
|
70
|
+
),
|
|
71
|
+
migrations.AddField(
|
|
72
|
+
model_name='notificationtemplate',
|
|
73
|
+
name='created_by_org_user',
|
|
74
|
+
field=models.ForeignKey(
|
|
75
|
+
blank=True,
|
|
76
|
+
help_text='OrganizationUser creator (org-level)',
|
|
77
|
+
null=True,
|
|
78
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
79
|
+
related_name='created_templates',
|
|
80
|
+
to='constec_db.organizationuser'
|
|
81
|
+
),
|
|
82
|
+
),
|
|
83
|
+
|
|
84
|
+
# 3. Add triggered_by_org_user to ExecutionLog
|
|
85
|
+
migrations.AddField(
|
|
86
|
+
model_name='executionlog',
|
|
87
|
+
name='triggered_by_org_user',
|
|
88
|
+
field=models.ForeignKey(
|
|
89
|
+
blank=True,
|
|
90
|
+
help_text='OrganizationUser who triggered execution (org-level)',
|
|
91
|
+
null=True,
|
|
92
|
+
on_delete=django.db.models.deletion.SET_NULL,
|
|
93
|
+
related_name='triggered_executions',
|
|
94
|
+
to='constec_db.organizationuser'
|
|
95
|
+
),
|
|
96
|
+
),
|
|
97
|
+
|
|
98
|
+
# 4. Update existing triggered_by_user field help text
|
|
99
|
+
migrations.AlterField(
|
|
100
|
+
model_name='executionlog',
|
|
101
|
+
name='triggered_by_user',
|
|
102
|
+
field=models.ForeignKey(
|
|
103
|
+
blank=True,
|
|
104
|
+
help_text='User who triggered execution (company-level)',
|
|
105
|
+
null=True,
|
|
106
|
+
on_delete=django.db.models.deletion.SET_NULL,
|
|
107
|
+
related_name='triggered_executions',
|
|
108
|
+
to='constec_db.user'
|
|
109
|
+
),
|
|
110
|
+
),
|
|
111
|
+
|
|
112
|
+
# 5. Migrate data from old created_by to new created_by_user
|
|
113
|
+
migrations.RunPython(migrate_creator_data, reverse_code=migrations.RunPython.noop),
|
|
114
|
+
|
|
115
|
+
# 6. Remove old created_by fields
|
|
116
|
+
migrations.RemoveField(
|
|
117
|
+
model_name='automation',
|
|
118
|
+
name='created_by',
|
|
119
|
+
),
|
|
120
|
+
migrations.RemoveField(
|
|
121
|
+
model_name='notificationtemplate',
|
|
122
|
+
name='created_by',
|
|
123
|
+
),
|
|
124
|
+
|
|
125
|
+
# 7. Add constraints for Automation
|
|
126
|
+
migrations.AddConstraint(
|
|
127
|
+
model_name='automation',
|
|
128
|
+
constraint=models.CheckConstraint(
|
|
129
|
+
check=models.Q(
|
|
130
|
+
('created_by_user__isnull', False),
|
|
131
|
+
('created_by_org_user__isnull', True)
|
|
132
|
+
) | models.Q(
|
|
133
|
+
('created_by_user__isnull', True),
|
|
134
|
+
('created_by_org_user__isnull', False)
|
|
135
|
+
),
|
|
136
|
+
name='automation_single_creator'
|
|
137
|
+
),
|
|
138
|
+
),
|
|
139
|
+
migrations.AddConstraint(
|
|
140
|
+
model_name='automation',
|
|
141
|
+
constraint=models.CheckConstraint(
|
|
142
|
+
check=models.Q(('created_by_user__isnull', False)) | models.Q(('created_by_org_user__isnull', False)),
|
|
143
|
+
name='automation_requires_creator'
|
|
144
|
+
),
|
|
145
|
+
),
|
|
146
|
+
|
|
147
|
+
# 8. Add constraints for NotificationTemplate
|
|
148
|
+
migrations.AddConstraint(
|
|
149
|
+
model_name='notificationtemplate',
|
|
150
|
+
constraint=models.CheckConstraint(
|
|
151
|
+
check=models.Q(
|
|
152
|
+
('created_by_user__isnull', False),
|
|
153
|
+
('created_by_org_user__isnull', True)
|
|
154
|
+
) | models.Q(
|
|
155
|
+
('created_by_user__isnull', True),
|
|
156
|
+
('created_by_org_user__isnull', False)
|
|
157
|
+
),
|
|
158
|
+
name='template_single_creator'
|
|
159
|
+
),
|
|
160
|
+
),
|
|
161
|
+
migrations.AddConstraint(
|
|
162
|
+
model_name='notificationtemplate',
|
|
163
|
+
constraint=models.CheckConstraint(
|
|
164
|
+
check=models.Q(('created_by_user__isnull', False)) | models.Q(('created_by_org_user__isnull', False)),
|
|
165
|
+
name='template_requires_creator'
|
|
166
|
+
),
|
|
167
|
+
),
|
|
168
|
+
|
|
169
|
+
# 9. Delete deprecated Event model
|
|
170
|
+
migrations.DeleteModel(
|
|
171
|
+
name='Event',
|
|
172
|
+
),
|
|
173
|
+
]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Generated manually - Rename User to CompanyUser for clarity and consistency
|
|
2
|
+
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('constec_db', '0008_refactor_creator_fields'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
# Rename tables
|
|
14
|
+
migrations.RenameModel(
|
|
15
|
+
old_name='User',
|
|
16
|
+
new_name='CompanyUser',
|
|
17
|
+
),
|
|
18
|
+
migrations.RenameModel(
|
|
19
|
+
old_name='UserRole',
|
|
20
|
+
new_name='CompanyUserRole',
|
|
21
|
+
),
|
|
22
|
+
migrations.RenameModel(
|
|
23
|
+
old_name='UserCompanyAccess',
|
|
24
|
+
new_name='CompanyUserAccess',
|
|
25
|
+
),
|
|
26
|
+
|
|
27
|
+
# Update table names
|
|
28
|
+
migrations.AlterModelTable(
|
|
29
|
+
name='companyuser',
|
|
30
|
+
table='core"."company_users',
|
|
31
|
+
),
|
|
32
|
+
migrations.AlterModelTable(
|
|
33
|
+
name='companyuserrole',
|
|
34
|
+
table='core"."company_user_roles',
|
|
35
|
+
),
|
|
36
|
+
migrations.AlterModelTable(
|
|
37
|
+
name='companyuseraccess',
|
|
38
|
+
table='core"."company_user_access',
|
|
39
|
+
),
|
|
40
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""
|
|
2
|
+
constec.db.models - All Django models for the Constec platform.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
from constec.db.models import Company, User, Session, Message
|
|
6
|
+
|
|
7
|
+
# ERP models (from erp schema, no prefix needed):
|
|
8
|
+
from constec.db.models import System, Connection, Entity
|
|
9
|
+
|
|
10
|
+
# Or import from specific modules:
|
|
11
|
+
from constec.db.models.organization import Organization
|
|
12
|
+
from constec.db.models.erp import System, Connection
|
|
13
|
+
from constec.db.models.erp_entity import Role, Entity, EntityAuth
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
# Base
|
|
17
|
+
from .base import UUIDModel
|
|
18
|
+
|
|
19
|
+
# Core models (core schema)
|
|
20
|
+
from .organization import Organization, OrganizationRole, OrganizationUser
|
|
21
|
+
from .company import Company
|
|
22
|
+
from .user import CompanyUser, CompanyUserRole, CompanyUserAccess
|
|
23
|
+
from .person import Person
|
|
24
|
+
from .group import UserGroup
|
|
25
|
+
|
|
26
|
+
# Backward compatibility aliases
|
|
27
|
+
User = CompanyUser
|
|
28
|
+
UserRole = CompanyUserRole
|
|
29
|
+
UserCompanyAccess = CompanyUserAccess
|
|
30
|
+
from .contact import ContactType, Contact, PersonContact
|
|
31
|
+
from .tag import TagCategory, PersonTag, PersonTagged
|
|
32
|
+
from .module import Module, CompanyModule, OrganizationModule
|
|
33
|
+
|
|
34
|
+
# ERP models (erp schema)
|
|
35
|
+
from .erp import System, CompanySystem, Connection
|
|
36
|
+
from .erp_entity import Role, Entity, EntityAuth
|
|
37
|
+
|
|
38
|
+
# Aliases for backward compatibility
|
|
39
|
+
ErpSystem = System
|
|
40
|
+
CompanyErpSystem = CompanySystem
|
|
41
|
+
ErpConnection = Connection
|
|
42
|
+
ErpRole = Role
|
|
43
|
+
ErpEntity = Entity
|
|
44
|
+
|
|
45
|
+
# Constancia models (constancia schema)
|
|
46
|
+
from .flow import FlowTemplate, Flow
|
|
47
|
+
from .session import Session, Message
|
|
48
|
+
|
|
49
|
+
# Automations models (automations schema)
|
|
50
|
+
from .automation import Automation, Trigger, Action, ExecutionLog, NotificationTemplate
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
__all__ = [
|
|
54
|
+
# Base
|
|
55
|
+
'UUIDModel',
|
|
56
|
+
# Organization
|
|
57
|
+
'Organization',
|
|
58
|
+
'OrganizationRole',
|
|
59
|
+
'OrganizationUser',
|
|
60
|
+
# Company
|
|
61
|
+
'Company',
|
|
62
|
+
# CompanyUser
|
|
63
|
+
'CompanyUser',
|
|
64
|
+
'CompanyUserRole',
|
|
65
|
+
'CompanyUserAccess',
|
|
66
|
+
# Backward compatibility aliases
|
|
67
|
+
'User',
|
|
68
|
+
'UserRole',
|
|
69
|
+
'UserCompanyAccess',
|
|
70
|
+
# Person
|
|
71
|
+
'Person',
|
|
72
|
+
# Group
|
|
73
|
+
'UserGroup',
|
|
74
|
+
# Contact
|
|
75
|
+
'ContactType',
|
|
76
|
+
'Contact',
|
|
77
|
+
'PersonContact',
|
|
78
|
+
# Tag
|
|
79
|
+
'TagCategory',
|
|
80
|
+
'PersonTag',
|
|
81
|
+
'PersonTagged',
|
|
82
|
+
# Module
|
|
83
|
+
'Module',
|
|
84
|
+
'CompanyModule',
|
|
85
|
+
'OrganizationModule',
|
|
86
|
+
# ERP (erp schema)
|
|
87
|
+
'System',
|
|
88
|
+
'CompanySystem',
|
|
89
|
+
'Connection',
|
|
90
|
+
'Role',
|
|
91
|
+
'Entity',
|
|
92
|
+
'EntityAuth',
|
|
93
|
+
# ERP aliases (backward compatibility)
|
|
94
|
+
'ErpSystem',
|
|
95
|
+
'CompanyErpSystem',
|
|
96
|
+
'ErpConnection',
|
|
97
|
+
'ErpRole',
|
|
98
|
+
'ErpEntity',
|
|
99
|
+
# Constancia (constancia schema)
|
|
100
|
+
'FlowTemplate',
|
|
101
|
+
'Flow',
|
|
102
|
+
'Session',
|
|
103
|
+
'Message',
|
|
104
|
+
# Automations (automations schema)
|
|
105
|
+
'Automation',
|
|
106
|
+
'Trigger',
|
|
107
|
+
'Action',
|
|
108
|
+
'ExecutionLog',
|
|
109
|
+
'NotificationTemplate',
|
|
110
|
+
]
|