feat(tenancy): Add is_ global field
Allow global item creation where all can access if they have the correct permission !1
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
# Generated by Django 5.0.4 on 2024-05-13 15:30
|
||||
# Generated by Django 5.0.4 on 2024-05-13 16:08
|
||||
|
||||
import access.fields
|
||||
import django.contrib.auth.models
|
||||
@ -36,6 +36,7 @@ class Migration(migrations.Migration):
|
||||
name='Team',
|
||||
fields=[
|
||||
('group_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='auth.group')),
|
||||
('is_global', models.BooleanField(default=False)),
|
||||
('team_name', models.CharField(default='', max_length=50, verbose_name='Name')),
|
||||
('created', access.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False)),
|
||||
('modified', access.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False)),
|
||||
|
@ -24,6 +24,10 @@ class OrganizationMixin():
|
||||
|
||||
id = self.get_object().organization.id
|
||||
|
||||
if self.get_object().is_global:
|
||||
|
||||
id = 0
|
||||
|
||||
return id
|
||||
|
||||
|
||||
@ -107,7 +111,7 @@ class OrganizationMixin():
|
||||
|
||||
has_permission = False
|
||||
|
||||
if self.is_member(self.object_organization()):
|
||||
if self.is_member(self.object_organization()) or self.object_organization() == 0:
|
||||
|
||||
groups = Group.objects.filter(pk__in=self.user_groups)
|
||||
|
||||
@ -120,7 +124,7 @@ class OrganizationMixin():
|
||||
|
||||
assembled_permission = str(permission["content_type__app_label"]) + '.' + str(permission["codename"])
|
||||
|
||||
if assembled_permission in self.get_permission_required()[0] and team['organization_id'] == self.object_organization():
|
||||
if assembled_permission in self.get_permission_required()[0] and (team['organization_id'] == self.object_organization() or self.object_organization() == 0):
|
||||
|
||||
return True
|
||||
|
||||
|
@ -50,6 +50,11 @@ class TenancyObject(models.Model):
|
||||
on_delete=models.CASCADE,
|
||||
)
|
||||
|
||||
is_global = models.BooleanField(
|
||||
default = False,
|
||||
blank = False
|
||||
)
|
||||
|
||||
|
||||
class Team(Group, TenancyObject):
|
||||
class Meta:
|
||||
|
Reference in New Issue
Block a user