constec 0.2.1__py3-none-any.whl → 0.3.0__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.
@@ -236,6 +236,11 @@ class Migration(migrations.Migration):
236
236
  'db_table': 'core"."persons',
237
237
  },
238
238
  ),
239
+ migrations.AddField(
240
+ model_name='entity',
241
+ name='company',
242
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='erp_entities', to='constec_db.company'),
243
+ ),
239
244
  migrations.AddField(
240
245
  model_name='entity',
241
246
  name='person',
@@ -498,11 +503,11 @@ class Migration(migrations.Migration):
498
503
  ),
499
504
  migrations.AddIndex(
500
505
  model_name='entity',
501
- index=models.Index(fields=['system', 'cuit'], name='entities_system__347218_idx'),
506
+ index=models.Index(fields=['company', 'cuit'], name='entities_company_cuit_idx'),
502
507
  ),
503
508
  migrations.AlterUniqueTogether(
504
509
  name='entity',
505
- unique_together={('system', 'role', 'external_id')},
510
+ unique_together={('company', 'role', 'external_id')},
506
511
  ),
507
512
  migrations.AlterUniqueTogether(
508
513
  name='connection',
@@ -27,6 +27,7 @@ class Company(UUIDModel):
27
27
  class Meta:
28
28
  app_label = 'constec_db'
29
29
  db_table = 'core"."companies'
30
+ verbose_name_plural = 'Companies'
30
31
 
31
32
  def __str__(self):
32
33
  return self.name
@@ -1,5 +1,7 @@
1
+ from django.core.exceptions import ValidationError
1
2
  from django.db import models
2
3
  from .base import UUIDModel
4
+ from .company import Company
3
5
  from .erp import System
4
6
  from .person import Person
5
7
 
@@ -30,6 +32,11 @@ class Entity(UUIDModel):
30
32
  but no Core account yet). When they authenticate via CUIT, we can
31
33
  optionally link them to a Person later.
32
34
  """
35
+ company = models.ForeignKey(
36
+ Company,
37
+ on_delete=models.CASCADE,
38
+ related_name="erp_entities",
39
+ )
33
40
  person = models.ForeignKey(
34
41
  Person,
35
42
  on_delete=models.CASCADE,
@@ -63,12 +70,20 @@ class Entity(UUIDModel):
63
70
  class Meta:
64
71
  app_label = 'constec_db'
65
72
  db_table = '"erp"."entities"'
66
- unique_together = [['system', 'role', 'external_id']]
73
+ verbose_name_plural = 'Entities'
74
+ unique_together = [['company', 'role', 'external_id']]
67
75
  indexes = [
68
76
  models.Index(fields=['cuit']),
69
- models.Index(fields=['system', 'cuit']),
77
+ models.Index(fields=['company', 'cuit']),
70
78
  ]
71
79
 
80
+ def clean(self):
81
+ from .erp import CompanySystem
82
+ if not CompanySystem.objects.filter(company=self.company, system=self.system).exists():
83
+ raise ValidationError(
84
+ f"Company {self.company} is not associated with System {self.system}"
85
+ )
86
+
72
87
  def __str__(self):
73
88
  person_info = f"({self.person.full_name})" if self.person else "(no person linked)"
74
89
  return f"[{self.system.name}] {self.role.name} {self.external_id} {person_info}"
constec/db/models/tag.py CHANGED
@@ -17,6 +17,8 @@ class TagCategory(UUIDModel):
17
17
  class Meta:
18
18
  app_label = 'constec_db'
19
19
  db_table = 'core"."tag_categories'
20
+ verbose_name = 'Tag category'
21
+ verbose_name_plural = 'Tag categories'
20
22
 
21
23
  def __str__(self):
22
24
  return f"{self.name}"
constec/db/models/user.py CHANGED
@@ -66,6 +66,8 @@ class UserCompanyAccess(UUIDModel):
66
66
  class Meta:
67
67
  app_label = 'constec_db'
68
68
  db_table = 'core"."user_company_access'
69
+ verbose_name = 'User company access'
70
+ verbose_name_plural = 'User company access'
69
71
  unique_together = [['user', 'company']]
70
72
 
71
73
  def __str__(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: constec
3
- Version: 0.2.1
3
+ Version: 0.3.0
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
@@ -1,22 +1,22 @@
1
1
  constec/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  constec/db/__init__.py,sha256=wou_y3aqCg1xP8Gr13FKRy0kEI2avV-19G3P2g3bzjs,287
3
3
  constec/db/apps.py,sha256=zc-9lGNa049q9bvxV7957EwnZjuBozPLZq594cKAU24,221
4
- constec/db/migrations/0001_initial.py,sha256=msXQuh93fquBr7pV3IE1XTInAFQeUeaYan-29h0RTCo,28290
4
+ constec/db/migrations/0001_initial.py,sha256=eJ2F_Gub0wgHOauKMvkDc_XUjGoaeyzDjyxA1f0nNsU,28527
5
5
  constec/db/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  constec/db/models/__init__.py,sha256=xsER3dtbsj14mSb52v1Mf1bE0RzKbvrvwD6xti2RN5s,2132
7
7
  constec/db/models/base.py,sha256=1t_eYXYyggoL5fKLcitRPKr1qUE1Ql3_sOmSHQMD3QE,359
8
- constec/db/models/company.py,sha256=VZMt6gmsEWBL6VPUYzTPYOngBqL3mPYmZ6ZuCiz5Jeo,1055
8
+ constec/db/models/company.py,sha256=9Mr2Q9iSwu4bhp_4KPZqZy4ciJ62rI_AxFWSs1wGGhE,1097
9
9
  constec/db/models/contact.py,sha256=qzkekZBNBtusFMpZRANxwKjtDN9qCxc4BMz-H7RyWM0,1904
10
10
  constec/db/models/erp.py,sha256=sN0U0XCMNW-pc9CNLZG_kPZeWXznq_XU3ML2zJ3arjA,3518
11
- constec/db/models/erp_entity.py,sha256=lJG0sU7YfehuxoqrxmpvuCSG0_GsardU5DvwBgMKsW8,3412
11
+ constec/db/models/erp_entity.py,sha256=aussrOd7kyNaP2tRJ5SS_WLzpXcZ-SyBa7KnSCkL89g,3954
12
12
  constec/db/models/flow.py,sha256=K_UA7E4zJ2-UPNp5H9e-lfPeGn0wDEiOl0cRal4Dmb8,4414
13
13
  constec/db/models/group.py,sha256=ueCOIfpmzR683ojWf5vLb6IG_jawfVRM7IJcGK05I3Y,897
14
14
  constec/db/models/module.py,sha256=na_7pJw8Q2D2UkF86ZwK5VdJnV87yqUOMBvaBLw4KgI,1218
15
15
  constec/db/models/organization.py,sha256=9dbsh5UBShtDRAeyMqqQEPEaflhzS3aiZpRWUiEluBU,1731
16
16
  constec/db/models/person.py,sha256=B4BNdy2AgqmxrZrkWWvqnFxFHs4uO1n61Y_5sP6MsUo,848
17
17
  constec/db/models/session.py,sha256=HeIk5rK25IaxKBRX-XNuJ75ndjJZ08rAdSGTLvTwlLE,2695
18
- constec/db/models/tag.py,sha256=wgJYoffXCO_-G7zhS1FLiQHFtJVbJKPV-wyRG3mwb74,1730
19
- constec/db/models/user.py,sha256=UzCgb47ZVg1cBN_Y5CIpZJeHSC8JOAYT_0xZE3d294Y,1921
18
+ constec/db/models/tag.py,sha256=VlddQW8MLDtYmtt6wp7kC6MsT6SQ6odiJX8mUK8FP3o,1815
19
+ constec/db/models/user.py,sha256=QHA-BzJ0F1xaeaUfJbuDlmvLDFclSnVrzqN1n4BCumk,2018
20
20
  constec/services/__init__.py,sha256=LXGKIzaRf1gVG2y7oUc18EulUsJXHVs8-oz0nY2h7WA,312
21
21
  constec/services/encryption.py,sha256=rwfAGUC7kDy1bhezHPoZG1hTjajpEB6l3AgcfGtmdvg,2368
22
22
  constec/shared/__init__.py,sha256=Qe99OxBfwg3_4i4zyCQR20vCcyyaIULpLzUa0XfwBPg,435
@@ -24,8 +24,8 @@ constec/shared/exceptions.py,sha256=8Bih40RWoH0gVhto09mH2ppSQV_drHPnGWITcoD-0J0,
24
24
  constec/utils/__init__.py,sha256=brf-G4UvU-3CK_rKNPTaHwsVsxnoJSbml_QTZJSM7d0,458
25
25
  constec/utils/cuit.py,sha256=dQKGlA4pRQ5DyR-N4BiV8ZsvAle2Vgjif7PU72zHx_A,2753
26
26
  constec/utils/password.py,sha256=XNpTJ9xZQSoZNjXEAnexAEZuYkwW1dFgX4AY-B5Q0gA,1462
27
- constec-0.2.1.dist-info/licenses/LICENSE,sha256=a1R51ONDGq0UQfV-n3ybsNL7EGhcC2sQ1sXvRANaFVI,1064
28
- constec-0.2.1.dist-info/METADATA,sha256=HOqHTtkL5qv5h6LZK6AV2K9f6i8tTsCKh936Kf8Ge1s,2954
29
- constec-0.2.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
30
- constec-0.2.1.dist-info/top_level.txt,sha256=bQ9AydOLlthShsr7tA7t7ivbLvlLPdhHOo0BdWgnh_Y,8
31
- constec-0.2.1.dist-info/RECORD,,
27
+ constec-0.3.0.dist-info/licenses/LICENSE,sha256=a1R51ONDGq0UQfV-n3ybsNL7EGhcC2sQ1sXvRANaFVI,1064
28
+ constec-0.3.0.dist-info/METADATA,sha256=HngSlD9Jv1PcYz6x2ycn9vSmCu0gNXe3b93Kfn817Qs,2954
29
+ constec-0.3.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
30
+ constec-0.3.0.dist-info/top_level.txt,sha256=bQ9AydOLlthShsr7tA7t7ivbLvlLPdhHOo0BdWgnh_Y,8
31
+ constec-0.3.0.dist-info/RECORD,,