accrete 0.0.128__py3-none-any.whl → 0.0.129__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.
accrete/admin.py CHANGED
@@ -10,11 +10,13 @@ class MemberInLine(admin.TabularInline):
10
10
  class TenantAccessGroupInLine(admin.TabularInline):
11
11
 
12
12
  model = models.TenantAccessGroupRel
13
+ extra = 0
13
14
 
14
15
 
15
16
  class AccessGroupMemberInLine(admin.TabularInline):
16
17
 
17
18
  model = models.MemberAccessGroupRel
19
+ extra = 0
18
20
 
19
21
 
20
22
  class TenantAdmin(admin.ModelAdmin):
@@ -23,7 +25,7 @@ class TenantAdmin(admin.ModelAdmin):
23
25
  list_display = ('name', 'is_active', 'pk')
24
26
  search_fields = ('pk', 'name')
25
27
  list_filter = ['is_active']
26
- inlines = [MemberInLine, TenantAccessGroupInLine]
28
+ inlines = [TenantAccessGroupInLine, MemberInLine]
27
29
 
28
30
 
29
31
  class MemberAdmin(admin.ModelAdmin):
@@ -32,15 +34,16 @@ class MemberAdmin(admin.ModelAdmin):
32
34
  list_display = ('user', 'tenant', 'is_active')
33
35
  search_fields = ('user__email', 'tenant__name')
34
36
  list_filter = ['is_active']
37
+ fields = ['user', 'tenant', 'is_active']
35
38
  inlines = [AccessGroupMemberInLine]
36
39
 
37
40
 
38
41
  class AccessGroupAdmin(admin.ModelAdmin):
39
42
 
40
43
  model = models.AccessGroup
41
- list_display = ('name', 'code')
44
+ list_display = ('name', 'code', 'apply_on')
42
45
  search_fields = ('name', 'code')
43
- inlines = [AccessGroupMemberInLine]
46
+ list_filter = ['apply_on']
44
47
 
45
48
 
46
49
  admin.site.register(models.Tenant, TenantAdmin)
@@ -144,8 +144,8 @@
144
144
  <div class="is-flex is-justify-content-space-between is-flex-wrap-wrap">
145
145
  <div class="is-flex is-flex-wrap-wrap is-flex-grow-5 is-align-self-center py-2">
146
146
  {% block header_left %}
147
- <div>
148
- <p class="subtitle is-5 px-2 py-1 my-1">{{ title }}</p>
147
+ <div class="mr-2">
148
+ <p class="title is-5 px-2 py-1 my-1">{{ title }}</p>
149
149
  </div>
150
150
  {% endblock %}
151
151
  </div>
@@ -0,0 +1,28 @@
1
+ # Generated by Django 5.1.4 on 2025-03-06 09:53
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ('accrete', '0004_rename_accessgroupmember_memberaccessgrouprel_and_more'),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AddField(
14
+ model_name='accessgroup',
15
+ name='apply_on',
16
+ field=models.CharField(choices=[('tenant', 'Tenant'), ('member', 'Member')], default='tenant', help_text='', max_length=10, verbose_name='Apply On'),
17
+ ),
18
+ migrations.AlterField(
19
+ model_name='member',
20
+ name='access_groups',
21
+ field=models.ManyToManyField(blank=True, through='accrete.MemberAccessGroupRel', to='accrete.accessgroup'),
22
+ ),
23
+ migrations.AlterField(
24
+ model_name='tenant',
25
+ name='access_groups',
26
+ field=models.ManyToManyField(blank=True, through='accrete.TenantAccessGroupRel', to='accrete.accessgroup'),
27
+ ),
28
+ ]
accrete/models.py CHANGED
@@ -1,3 +1,4 @@
1
+ from django.core.exceptions import ValidationError
1
2
  from django.db import models
2
3
  from django.conf import settings
3
4
  from django.utils.translation import gettext_lazy as _
@@ -70,7 +71,8 @@ class Tenant(models.Model):
70
71
  access_groups = models.ManyToManyField(
71
72
  to='accrete.AccessGroup',
72
73
  through='accrete.TenantAccessGroupRel',
73
- through_fields=('tenant', 'access_group')
74
+ through_fields=('tenant', 'access_group'),
75
+ blank=True
74
76
  )
75
77
 
76
78
  def __str__(self):
@@ -105,7 +107,8 @@ class Member(models.Model):
105
107
  access_groups = models.ManyToManyField(
106
108
  to='accrete.AccessGroup',
107
109
  through='accrete.MemberAccessGroupRel',
108
- through_fields=('member', 'access_group')
110
+ through_fields=('member', 'access_group'),
111
+ blank=True
109
112
  )
110
113
 
111
114
  objects = MemberManager()
@@ -138,6 +141,17 @@ class AccessGroup(models.Model):
138
141
  max_length=100
139
142
  )
140
143
 
144
+ apply_on = models.CharField(
145
+ verbose_name=_('Apply On'),
146
+ max_length=10,
147
+ choices=[
148
+ ('tenant', _('Tenant')),
149
+ ('member', _('Member'))
150
+ ],
151
+ default='tenant',
152
+ help_text=_('')
153
+ )
154
+
141
155
  def __str__(self):
142
156
  return self.name
143
157
 
@@ -169,6 +183,10 @@ class MemberAccessGroupRel(models.Model):
169
183
  def __str__(self):
170
184
  return f'{self.member} - {self.access_group}'
171
185
 
186
+ def clean(self):
187
+ if self.access_group.apply_on != 'member':
188
+ raise ValidationError(_('Access Group must apply on members'))
189
+
172
190
 
173
191
  class TenantAccessGroupRel(models.Model):
174
192
 
@@ -196,3 +214,7 @@ class TenantAccessGroupRel(models.Model):
196
214
 
197
215
  def __str__(self):
198
216
  return f'{self.tenant} - {self.access_group}'
217
+
218
+ def clean(self):
219
+ if self.access_group.apply_on != 'tenant':
220
+ raise ValidationError(_('Access Group must apply on tenants'))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: accrete
3
- Version: 0.0.128
3
+ Version: 0.0.129
4
4
  Summary: Django Shared Schema Multi Tenant
5
5
  Author-email: Benedikt Jilek <benedikt.jilek@pm.me>
6
6
  License: Copyright (c) 2023 Benedikt Jilek
@@ -1,5 +1,5 @@
1
1
  accrete/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- accrete/admin.py,sha256=6NiX8_3pYIhnru5hNzvnW4xfzWsbf7gZj8Z2p38xIOk,1232
2
+ accrete/admin.py,sha256=sK7jzjVTdAPim3TnOluRdorRZYVt2Rv8vx7Bw7dix-I,1308
3
3
  accrete/apps.py,sha256=F7ynMLHJr_6bRujWtZVUzCliY2CGKiDvyUmL4F68L2E,146
4
4
  accrete/config.py,sha256=1Yubvz5PVdCsX0tA7HvazhtnvCvgCoEl33_dR8SHpb8,392
5
5
  accrete/context_processors.py,sha256=DySglwyD2TwPsxhElVkYDvyBBUJabEKGMiKCLe0KN4Q,148
@@ -7,7 +7,7 @@ accrete/fields.py,sha256=9SlltB5AJvDfiAbYGWZemrqpjqDl1XNgNrhyTGoBJ2A,4693
7
7
  accrete/forms.py,sha256=H2hPQemslRLvTVV0Wl1TfUmTc5wU3Z98nQTMiLMliqo,1288
8
8
  accrete/managers.py,sha256=DevRVm7cStvlfz6TriitSINr40POCi4HNaHX48VkrMA,1620
9
9
  accrete/middleware.py,sha256=YN73WloNkN01oel9Dcj3xyhurcWoB6zMV0NT3hY8DGw,2264
10
- accrete/models.py,sha256=01UPWHmkWg3CcgPjImaSvS7OPh1Xx7lQ1nsJxZNN53k,4879
10
+ accrete/models.py,sha256=vGVDso638MGL70VYwhLpNHesTVggbNNkMW0Z0siX_ys,5517
11
11
  accrete/storage.py,sha256=Jp3oE_uPMqgarjS_G49KDFrR2eSe4XuIJK9oAF_QBxk,1288
12
12
  accrete/tenant.py,sha256=GGKEhKLsC6JAkNGrMvp4l8ScsyfrDMocwJL5LBPe2Go,2307
13
13
  accrete/tests.py,sha256=Agltbzwwh5htvq_Qi9vqvxutzmg_GwgPS_N19xJZRlw,7197
@@ -197,7 +197,7 @@ accrete/contrib/ui/templates/django/forms/widgets/text.html,sha256=MSmLlQc7PsPoD
197
197
  accrete/contrib/ui/templates/django/forms/widgets/textarea.html,sha256=c9BTedqb3IkXLyVYd0p9pR8DFnsXCNGoxVBWZTk_Fic,278
198
198
  accrete/contrib/ui/templates/ui/content_right.html,sha256=XUF1tYpSKfO9FleYtJ2QmWPmwdLYxLHXdBLRa-BrFUs,221
199
199
  accrete/contrib/ui/templates/ui/form_error.html,sha256=uA8FLdZyeU0vXJHlGK3rcBqcmXb63MLPV32uQyUTak4,348
200
- accrete/contrib/ui/templates/ui/layout.html,sha256=l94vfodM5lGbtF3ZOBeSbesZki9LsEpfitH9bC1GEYk,12668
200
+ accrete/contrib/ui/templates/ui/layout.html,sha256=g4ai6b39bu2NXv106dLIKLqe2oJJe-Vd8lyIis3Z9Wc,12678
201
201
  accrete/contrib/ui/templates/ui/list.html,sha256=NY8DmHGl3n5O1u-_B9a_mlAck19ZmpYthzecADuc3BM,2250
202
202
  accrete/contrib/ui/templates/ui/list_update.html,sha256=mLQTCgkKfVI5jrgei-Upc1u87iXL0Q63uLzXHPwMyeo,110
203
203
  accrete/contrib/ui/templates/ui/message.html,sha256=t3bZ5EE7IgQYJroCdLKFeUkZiNbgKkErVYQm6Y3IKpg,532
@@ -253,6 +253,7 @@ accrete/migrations/0001_initial.py,sha256=azThbc8otEhxJwo8BIgOt5eC30mxXhKJLBAazZ
253
253
  accrete/migrations/0002_initial.py,sha256=dFOM7kdHlx7pVAh8cTDlZMtciN4O9Z547HAzEKnygZE,1628
254
254
  accrete/migrations/0003_remove_member_name.py,sha256=bnZrzOIXcqsoGfbqgohTN5OHm2IldnLlBz1HNJDeqKc,315
255
255
  accrete/migrations/0004_rename_accessgroupmember_memberaccessgrouprel_and_more.py,sha256=NXEKuRyIjLFXqycWB1jIZFQ0ppevMwz1I6rAr9qKrk4,1404
256
+ accrete/migrations/0005_accessgroup_apply_on_alter_member_access_groups_and_more.py,sha256=1ZL_PG2W_5h1x1oGAUALn2Ks0kzbFusHF7XEXE1J9Pg,996
256
257
  accrete/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
257
258
  accrete/utils/__init__.py,sha256=saw9zi2XItJOPbv4fjTXOpl7StNtC803jHhapFcGx08,312
258
259
  accrete/utils/dates.py,sha256=apM6kt6JhGrKgoT0jfav1W-8AUVTxNc9xt3fJQ2n0JI,1492
@@ -260,7 +261,7 @@ accrete/utils/forms.py,sha256=1UQoG0cXel4Tg-a_cG9doJNrl62a0JMDVEYrT5TSX1s,3383
260
261
  accrete/utils/log.py,sha256=BH0MBDweAjx30wGBO4F3sFhbgkSoEs7T1lLLjlYZNnA,407
261
262
  accrete/utils/models.py,sha256=2xTacvcpmDK_Bp4rAK7JdVLf8HU009LYNJ6eSpMgYZI,1014
262
263
  accrete/utils/views.py,sha256=AutijWetWGgjdO1PNc4gxCblT-i1fAfldNDFRbO9Sac,5012
263
- accrete-0.0.128.dist-info/METADATA,sha256=3HnKri4Msg5AjnVNVEP5NRET1BmJb-geQnwOmWStajk,4953
264
- accrete-0.0.128.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
265
- accrete-0.0.128.dist-info/licenses/LICENSE,sha256=_7laeMIHnsd3Y2vJEXDYXq_PEXxIcjgJsGt8UIKTRWc,1057
266
- accrete-0.0.128.dist-info/RECORD,,
264
+ accrete-0.0.129.dist-info/METADATA,sha256=Ak-a0g5oHBQbDWpeg0ekq4Fi-RPP80PmqyeHp8W7uhM,4953
265
+ accrete-0.0.129.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
266
+ accrete-0.0.129.dist-info/licenses/LICENSE,sha256=_7laeMIHnsd3Y2vJEXDYXq_PEXxIcjgJsGt8UIKTRWc,1057
267
+ accrete-0.0.129.dist-info/RECORD,,