2
.gitignore
vendored
2
.gitignore
vendored
@ -1,7 +1,7 @@
|
|||||||
venv/**
|
venv/**
|
||||||
*/static/**
|
*/static/**
|
||||||
__pycache__
|
__pycache__
|
||||||
**.sqlite3
|
**.sqlite*
|
||||||
**.sqlite
|
**.sqlite
|
||||||
**.coverage
|
**.coverage
|
||||||
.coverage*
|
.coverage*
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
With this new setting, the previous setting `LOGGING` will no longer function.
|
With this new setting, the previous setting `LOGGING` will no longer function.
|
||||||
|
|
||||||
|
- Renamed `Organization` model to `Tenant` so as to reflect what is actually is.
|
||||||
|
|
||||||
|
- `robots.txt` file now being served from the API container at path `/robots.txt` with `User-agent: *` and `Disallow: /`
|
||||||
|
|
||||||
|
|
||||||
## Version 1.16.0
|
## Version 1.16.0
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from django.contrib.auth.models import Group
|
|||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin
|
||||||
|
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from django.db.models import Q
|
|||||||
|
|
||||||
from app import settings
|
from app import settings
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
|
|
||||||
from core.forms.common import CommonModelForm
|
from core.forms.common import CommonModelForm
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from django.contrib.auth.models import Group
|
|||||||
from django.utils.deprecation import MiddlewareMixin
|
from django.utils.deprecation import MiddlewareMixin
|
||||||
|
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
|
|
||||||
|
|
||||||
|
26
app/access/migrations/0007_rename_organization_tenant.py
Normal file
26
app/access/migrations/0007_rename_organization_tenant.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Generated by Django 5.1.9 on 2025-05-14 11:06
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('access', '0005_entity_person_entityhistory_entitynotes_role_and_more'),
|
||||||
|
('accounting', '0003_assetbasenotes'),
|
||||||
|
('assistance', '0005_knowledgebasecategoryhistory_knowledgebasehistory'),
|
||||||
|
('config_management', '0007_configgroupshistory_configgrouphostshistory_and_more'),
|
||||||
|
('core', '0025_ticketcommentaction'),
|
||||||
|
('devops', '0011_alter_gitgroup_unique_together_and_more'),
|
||||||
|
('itam', '0011_itamassetbase'),
|
||||||
|
('itim', '0009_slmticket_requestticket'),
|
||||||
|
('project_management', '0005_projecthistory_projectmilestonehistory_and_more'),
|
||||||
|
('settings', '0011_appsettingshistory_externallinkhistory'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameModel(
|
||||||
|
old_name = 'Organization',
|
||||||
|
new_name = 'Tenant'
|
||||||
|
),
|
||||||
|
]
|
@ -0,0 +1,47 @@
|
|||||||
|
# Generated by Django 5.1.9 on 2025-05-14 13:48
|
||||||
|
|
||||||
|
import access.models.team
|
||||||
|
import access.models.tenancy
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('access', '0007_rename_organization_tenant'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='tenant',
|
||||||
|
options={'ordering': ['name'], 'verbose_name': 'Tenant', 'verbose_name_plural': 'Tenants'},
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='entity',
|
||||||
|
name='organization',
|
||||||
|
field=models.ForeignKey(help_text='Tenancy this belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='access.tenant', validators=[access.models.tenancy.TenancyObject.validatate_organization_exists], verbose_name='Tenant'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='role',
|
||||||
|
name='organization',
|
||||||
|
field=models.ForeignKey(help_text='Tenancy this belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='access.tenant', validators=[access.models.tenancy.TenancyObject.validatate_organization_exists], verbose_name='Tenant'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='team',
|
||||||
|
name='organization',
|
||||||
|
field=models.ForeignKey(help_text='Tenant this belongs to', on_delete=django.db.models.deletion.CASCADE, to='access.tenant', validators=[access.models.team.Team.validatate_organization_exists], verbose_name='Tenant'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='tenant',
|
||||||
|
name='manager',
|
||||||
|
field=models.ForeignKey(help_text='Manager for this Tenancy', null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='Manager'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='tenant',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(help_text='Name of this Tenancy', max_length=50, unique=True, verbose_name='Name'),
|
||||||
|
),
|
||||||
|
]
|
@ -4,7 +4,7 @@ from django.contrib.auth.models import Group
|
|||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
|
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ class OrganizationMixin():
|
|||||||
self.permission_required = permissions_required
|
self.permission_required = permissions_required
|
||||||
|
|
||||||
organization_manager_models = [
|
organization_manager_models = [
|
||||||
'access.organization',
|
'access.tenant',
|
||||||
'access.team',
|
'access.team',
|
||||||
'access.teamusers',
|
'access.teamusers',
|
||||||
]
|
]
|
||||||
@ -326,7 +326,7 @@ class OrganizationMixin():
|
|||||||
|
|
||||||
if required_permission.replace(
|
if required_permission.replace(
|
||||||
'view_', ''
|
'view_', ''
|
||||||
) == 'access.organization' and len(self.kwargs) == 0:
|
) == 'access.tenant' and len(self.kwargs) == 0:
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import django
|
|||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
|
|
||||||
User = django.contrib.auth.get_user_model()
|
User = django.contrib.auth.get_user_model()
|
||||||
@ -93,7 +93,7 @@ class OrganizationMixin:
|
|||||||
|
|
||||||
self._obj_organization = obj.organization
|
self._obj_organization = obj.organization
|
||||||
|
|
||||||
elif str(self.model._meta.verbose_name).lower() == 'organization':
|
elif str(self.model._meta.verbose_name).lower() == 'tenant':
|
||||||
|
|
||||||
self._obj_organization = obj
|
self._obj_organization = obj
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from django.core.exceptions import ObjectDoesNotExist
|
|||||||
from rest_framework import exceptions
|
from rest_framework import exceptions
|
||||||
from rest_framework.permissions import DjangoObjectPermissions
|
from rest_framework.permissions import DjangoObjectPermissions
|
||||||
|
|
||||||
from access.models.tenancy import Organization, TenancyObject
|
from access.models.tenancy import Tenant, TenancyObject
|
||||||
|
|
||||||
from core import exceptions as centurion_exceptions
|
from core import exceptions as centurion_exceptions
|
||||||
|
|
||||||
@ -14,10 +14,10 @@ from core import exceptions as centurion_exceptions
|
|||||||
class OrganizationPermissionMixin(
|
class OrganizationPermissionMixin(
|
||||||
DjangoObjectPermissions,
|
DjangoObjectPermissions,
|
||||||
):
|
):
|
||||||
"""Organization Permission Mixin
|
"""Tenant Permission Mixin
|
||||||
|
|
||||||
This class is to be used as the permission class for API `Views`/`ViewSets`.
|
This class is to be used as the permission class for API `Views`/`ViewSets`.
|
||||||
In combination with the `OrganizationPermissionsMixin`, permission checking
|
In combination with the `TenantPermissionsMixin`, permission checking
|
||||||
will be done to ensure the user has the correct permissions to perform the
|
will be done to ensure the user has the correct permissions to perform the
|
||||||
CRUD operation.
|
CRUD operation.
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ class OrganizationPermissionMixin(
|
|||||||
raise centurion_exceptions.PermissionDenied()
|
raise centurion_exceptions.PermissionDenied()
|
||||||
|
|
||||||
|
|
||||||
obj_organization: Organization = view.get_obj_organization(
|
obj_organization: Tenant = view.get_obj_organization(
|
||||||
request = request
|
request = request
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,159 +1 @@
|
|||||||
import django
|
from .tenant import Tenant as Organization
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
from rest_framework.reverse import reverse
|
|
||||||
|
|
||||||
from access.fields import (
|
|
||||||
AutoCreatedField,
|
|
||||||
AutoLastModifiedField,
|
|
||||||
AutoSlugField
|
|
||||||
)
|
|
||||||
|
|
||||||
from core.mixin.history_save import SaveHistory
|
|
||||||
|
|
||||||
User = django.contrib.auth.get_user_model()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Organization(SaveHistory):
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = "Organization"
|
|
||||||
verbose_name_plural = "Organizations"
|
|
||||||
ordering = ['name']
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
|
||||||
|
|
||||||
if self.slug == '_':
|
|
||||||
self.slug = self.name.lower().replace(' ', '_')
|
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
|
||||||
|
|
||||||
id = models.AutoField(
|
|
||||||
blank=False,
|
|
||||||
help_text = 'ID of this item',
|
|
||||||
primary_key=True,
|
|
||||||
unique=True,
|
|
||||||
verbose_name = 'ID'
|
|
||||||
)
|
|
||||||
|
|
||||||
name = models.CharField(
|
|
||||||
blank = False,
|
|
||||||
help_text = 'Name of this Organization',
|
|
||||||
max_length = 50,
|
|
||||||
unique = True,
|
|
||||||
verbose_name = 'Name'
|
|
||||||
)
|
|
||||||
|
|
||||||
manager = models.ForeignKey(
|
|
||||||
settings.AUTH_USER_MODEL,
|
|
||||||
blank = False,
|
|
||||||
help_text = 'Manager for this organization',
|
|
||||||
null = True,
|
|
||||||
on_delete=models.SET_NULL,
|
|
||||||
verbose_name = 'Manager'
|
|
||||||
)
|
|
||||||
|
|
||||||
model_notes = models.TextField(
|
|
||||||
blank = True,
|
|
||||||
default = None,
|
|
||||||
help_text = 'Tid bits of information',
|
|
||||||
null= True,
|
|
||||||
verbose_name = 'Notes',
|
|
||||||
)
|
|
||||||
|
|
||||||
slug = AutoSlugField()
|
|
||||||
|
|
||||||
created = AutoCreatedField()
|
|
||||||
|
|
||||||
modified = AutoLastModifiedField()
|
|
||||||
|
|
||||||
|
|
||||||
def get_organization(self):
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __int__(self):
|
|
||||||
|
|
||||||
return self.id
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
table_fields: list = [
|
|
||||||
'nbsp',
|
|
||||||
'name',
|
|
||||||
'created',
|
|
||||||
'modified',
|
|
||||||
'nbsp'
|
|
||||||
]
|
|
||||||
|
|
||||||
page_layout: list = [
|
|
||||||
{
|
|
||||||
"name": "Details",
|
|
||||||
"slug": "details",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"layout": "double",
|
|
||||||
"left": [
|
|
||||||
'name',
|
|
||||||
'manager',
|
|
||||||
'created',
|
|
||||||
'modified',
|
|
||||||
],
|
|
||||||
"right": [
|
|
||||||
'model_notes',
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Teams",
|
|
||||||
"slug": "teams",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"layout": "table",
|
|
||||||
"field": "teams"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Knowledge Base",
|
|
||||||
"slug": "kb_articles",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"layout": "table",
|
|
||||||
"field": "knowledge_base",
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Notes",
|
|
||||||
"slug": "notes",
|
|
||||||
"sections": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def get_url( self, request = None ) -> str:
|
|
||||||
|
|
||||||
if request:
|
|
||||||
|
|
||||||
return reverse("v2:_api_v2_organization-detail", request=request, kwargs={'pk': self.id})
|
|
||||||
|
|
||||||
return reverse("v2:_api_v2_organization-detail", kwargs={'pk': self.id})
|
|
||||||
|
|
||||||
|
|
||||||
def save_history(self, before: dict, after: dict) -> bool:
|
|
||||||
|
|
||||||
from access.models.organization_history import OrganizationHistory
|
|
||||||
|
|
||||||
history = super().save_history(
|
|
||||||
before = before,
|
|
||||||
after = after,
|
|
||||||
history_model = OrganizationHistory
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
return history
|
|
||||||
|
@ -2,7 +2,7 @@ from django.db import models
|
|||||||
|
|
||||||
from core.models.model_history import ModelHistory
|
from core.models.model_history import ModelHistory
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ class OrganizationHistory(
|
|||||||
|
|
||||||
|
|
||||||
model = models.ForeignKey(
|
model = models.ForeignKey(
|
||||||
Organization,
|
Tenant,
|
||||||
blank = False,
|
blank = False,
|
||||||
help_text = 'Model this note belongs to',
|
help_text = 'Model this note belongs to',
|
||||||
null = False,
|
null = False,
|
||||||
@ -46,8 +46,8 @@ class OrganizationHistory(
|
|||||||
|
|
||||||
model = None
|
model = None
|
||||||
|
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
|
|
||||||
model = OrganizationBaseSerializer(self.model, context = serializer_context)
|
model = TenantBaseSerializer(self.model, context = serializer_context)
|
||||||
|
|
||||||
return model
|
return model
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant
|
||||||
|
|
||||||
from core.models.model_notes import ModelNotes
|
from core.models.model_notes import ModelNotes
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ class OrganizationNotes(
|
|||||||
|
|
||||||
|
|
||||||
model = models.ForeignKey(
|
model = models.ForeignKey(
|
||||||
Organization,
|
Tenant,
|
||||||
blank = False,
|
blank = False,
|
||||||
help_text = 'Model this note belongs to',
|
help_text = 'Model this note belongs to',
|
||||||
null = False,
|
null = False,
|
||||||
|
@ -8,7 +8,7 @@ from access.fields import (
|
|||||||
AutoLastModifiedField
|
AutoLastModifiedField
|
||||||
)
|
)
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant
|
||||||
from access.models.tenancy import TenancyObject
|
from access.models.tenancy import TenancyObject
|
||||||
|
|
||||||
from core import exceptions as centurion_exceptions
|
from core import exceptions as centurion_exceptions
|
||||||
@ -55,13 +55,13 @@ class Team(Group, TenancyObject):
|
|||||||
)
|
)
|
||||||
|
|
||||||
organization = models.ForeignKey(
|
organization = models.ForeignKey(
|
||||||
Organization,
|
Tenant,
|
||||||
blank = False,
|
blank = False,
|
||||||
help_text = 'Organization this belongs to',
|
help_text = 'Tenant this belongs to',
|
||||||
null = False,
|
null = False,
|
||||||
on_delete = models.CASCADE,
|
on_delete = models.CASCADE,
|
||||||
validators = [validatate_organization_exists],
|
validators = [validatate_organization_exists],
|
||||||
verbose_name = 'Organization'
|
verbose_name = 'Tenant'
|
||||||
)
|
)
|
||||||
|
|
||||||
created = AutoCreatedField()
|
created = AutoCreatedField()
|
||||||
|
@ -11,7 +11,7 @@ from access.fields import (
|
|||||||
AutoLastModifiedField
|
AutoLastModifiedField
|
||||||
)
|
)
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
|
|
||||||
from core.lib.feature_not_used import FeatureNotUsed
|
from core.lib.feature_not_used import FeatureNotUsed
|
||||||
@ -99,7 +99,7 @@ class TeamUsers(SaveHistory):
|
|||||||
user.groups.remove(group)
|
user.groups.remove(group)
|
||||||
|
|
||||||
|
|
||||||
def get_organization(self) -> Organization:
|
def get_organization(self) -> Tenant:
|
||||||
return self.team.organization
|
return self.team.organization
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from django.db import models
|
|||||||
|
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant
|
||||||
|
|
||||||
from core import exceptions as centurion_exceptions
|
from core import exceptions as centurion_exceptions
|
||||||
from core.middleware.get_request import get_request
|
from core.middleware.get_request import get_request
|
||||||
@ -136,14 +136,14 @@ class TenancyObject(SaveHistory):
|
|||||||
)
|
)
|
||||||
|
|
||||||
organization = models.ForeignKey(
|
organization = models.ForeignKey(
|
||||||
Organization,
|
Tenant,
|
||||||
blank = False,
|
blank = False,
|
||||||
help_text = 'Organization this belongs to',
|
help_text = 'Tenancy this belongs to',
|
||||||
null = False,
|
null = False,
|
||||||
on_delete = models.CASCADE,
|
on_delete = models.CASCADE,
|
||||||
related_name = '+',
|
related_name = '+',
|
||||||
validators = [validatate_organization_exists],
|
validators = [validatate_organization_exists],
|
||||||
verbose_name = 'Organization'
|
verbose_name = 'Tenant'
|
||||||
)
|
)
|
||||||
|
|
||||||
is_global = models.BooleanField(
|
is_global = models.BooleanField(
|
||||||
@ -161,7 +161,7 @@ class TenancyObject(SaveHistory):
|
|||||||
verbose_name = 'Notes',
|
verbose_name = 'Notes',
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_organization(self) -> Organization:
|
def get_organization(self) -> Tenant:
|
||||||
return self.organization
|
return self.organization
|
||||||
|
|
||||||
app_namespace: str = None
|
app_namespace: str = None
|
||||||
@ -291,7 +291,7 @@ class TenancyObject(SaveHistory):
|
|||||||
|
|
||||||
raise centurion_exceptions.ValidationError(
|
raise centurion_exceptions.ValidationError(
|
||||||
detail = {
|
detail = {
|
||||||
'organization': 'Organization is required'
|
'organization': 'Tenant is required'
|
||||||
},
|
},
|
||||||
code = 'required'
|
code = 'required'
|
||||||
)
|
)
|
||||||
|
161
app/access/models/tenant.py
Normal file
161
app/access/models/tenant.py
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
import django
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from rest_framework.reverse import reverse
|
||||||
|
|
||||||
|
from access.fields import (
|
||||||
|
AutoCreatedField,
|
||||||
|
AutoLastModifiedField,
|
||||||
|
AutoSlugField
|
||||||
|
)
|
||||||
|
|
||||||
|
from core.mixin.history_save import SaveHistory
|
||||||
|
|
||||||
|
User = django.contrib.auth.get_user_model()
|
||||||
|
|
||||||
|
class Tenant(SaveHistory):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = "Tenant"
|
||||||
|
verbose_name_plural = "Tenants"
|
||||||
|
ordering = ['name']
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
|
||||||
|
if self.slug == '_':
|
||||||
|
self.slug = self.name.lower().replace(' ', '_')
|
||||||
|
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
id = models.AutoField(
|
||||||
|
blank=False,
|
||||||
|
help_text = 'ID of this item',
|
||||||
|
primary_key=True,
|
||||||
|
unique=True,
|
||||||
|
verbose_name = 'ID'
|
||||||
|
)
|
||||||
|
|
||||||
|
name = models.CharField(
|
||||||
|
blank = False,
|
||||||
|
help_text = 'Name of this Tenancy',
|
||||||
|
max_length = 50,
|
||||||
|
unique = True,
|
||||||
|
verbose_name = 'Name'
|
||||||
|
)
|
||||||
|
|
||||||
|
manager = models.ForeignKey(
|
||||||
|
settings.AUTH_USER_MODEL,
|
||||||
|
blank = False,
|
||||||
|
help_text = 'Manager for this Tenancy',
|
||||||
|
null = True,
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
verbose_name = 'Manager'
|
||||||
|
)
|
||||||
|
|
||||||
|
model_notes = models.TextField(
|
||||||
|
blank = True,
|
||||||
|
default = None,
|
||||||
|
help_text = 'Tid bits of information',
|
||||||
|
null= True,
|
||||||
|
verbose_name = 'Notes',
|
||||||
|
)
|
||||||
|
|
||||||
|
slug = AutoSlugField()
|
||||||
|
|
||||||
|
created = AutoCreatedField()
|
||||||
|
|
||||||
|
modified = AutoLastModifiedField()
|
||||||
|
|
||||||
|
|
||||||
|
def get_organization(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __int__(self):
|
||||||
|
|
||||||
|
return self.id
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
table_fields: list = [
|
||||||
|
'nbsp',
|
||||||
|
'name',
|
||||||
|
'created',
|
||||||
|
'modified',
|
||||||
|
'nbsp'
|
||||||
|
]
|
||||||
|
|
||||||
|
page_layout: list = [
|
||||||
|
{
|
||||||
|
"name": "Details",
|
||||||
|
"slug": "details",
|
||||||
|
"sections": [
|
||||||
|
{
|
||||||
|
"layout": "double",
|
||||||
|
"left": [
|
||||||
|
'name',
|
||||||
|
'manager',
|
||||||
|
'created',
|
||||||
|
'modified',
|
||||||
|
],
|
||||||
|
"right": [
|
||||||
|
'model_notes',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Teams",
|
||||||
|
"slug": "teams",
|
||||||
|
"sections": [
|
||||||
|
{
|
||||||
|
"layout": "table",
|
||||||
|
"field": "teams"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Knowledge Base",
|
||||||
|
"slug": "kb_articles",
|
||||||
|
"sections": [
|
||||||
|
{
|
||||||
|
"layout": "table",
|
||||||
|
"field": "knowledge_base",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Notes",
|
||||||
|
"slug": "notes",
|
||||||
|
"sections": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def get_url( self, request = None ) -> str:
|
||||||
|
|
||||||
|
if request:
|
||||||
|
|
||||||
|
return reverse("v2:_api_v2_organization-detail", request=request, kwargs={'pk': self.id})
|
||||||
|
|
||||||
|
return reverse("v2:_api_v2_organization-detail", kwargs={'pk': self.id})
|
||||||
|
|
||||||
|
|
||||||
|
def save_history(self, before: dict, after: dict) -> bool:
|
||||||
|
|
||||||
|
from access.models.organization_history import OrganizationHistory
|
||||||
|
|
||||||
|
history = super().save_history(
|
||||||
|
before = before,
|
||||||
|
after = after,
|
||||||
|
history_model = OrganizationHistory
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
return history
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Organization = Tenant
|
@ -6,7 +6,7 @@ from access.models.entity import Entity
|
|||||||
|
|
||||||
from api.serializers import common
|
from api.serializers import common
|
||||||
|
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -87,4 +87,4 @@ class ModelSerializer(
|
|||||||
class ViewSerializer(ModelSerializer):
|
class ViewSerializer(ModelSerializer):
|
||||||
"""Entity Base View Model"""
|
"""Entity Base View Model"""
|
||||||
|
|
||||||
organization = OrganizationBaseSerializer(many=False, read_only=True)
|
organization = TenantBaseSerializer(many=False, read_only=True)
|
||||||
|
@ -6,7 +6,7 @@ from access.serializers.entity_person import (
|
|||||||
BaseSerializer as BaseBaseSerializer,
|
BaseSerializer as BaseBaseSerializer,
|
||||||
ModelSerializer as BaseModelSerializer,
|
ModelSerializer as BaseModelSerializer,
|
||||||
)
|
)
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -72,4 +72,4 @@ class ViewSerializer(
|
|||||||
This model inherits from the Person model.
|
This model inherits from the Person model.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
organization = OrganizationBaseSerializer(many=False, read_only=True)
|
organization = TenantBaseSerializer(many=False, read_only=True)
|
||||||
|
@ -6,7 +6,7 @@ from access.serializers.entity import (
|
|||||||
BaseSerializer as BaseBaseSerializer,
|
BaseSerializer as BaseBaseSerializer,
|
||||||
ModelSerializer as BaseModelSerializer,
|
ModelSerializer as BaseModelSerializer,
|
||||||
)
|
)
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -70,4 +70,4 @@ class ViewSerializer(
|
|||||||
This model inherits from the Entity base model.
|
This model inherits from the Entity base model.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
organization = OrganizationBaseSerializer(many=False, read_only=True)
|
organization = TenantBaseSerializer(many=False, read_only=True)
|
||||||
|
@ -2,15 +2,16 @@ from rest_framework.reverse import reverse
|
|||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant
|
||||||
|
|
||||||
from app.serializers.user import UserBaseSerializer
|
from app.serializers.user import UserBaseSerializer
|
||||||
|
|
||||||
from core import fields as centurion_field
|
from core import fields as centurion_field
|
||||||
|
|
||||||
|
Organization = Tenant
|
||||||
|
|
||||||
|
|
||||||
class OrganizationBaseSerializer(serializers.ModelSerializer):
|
class TenantBaseSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
display_name = serializers.SerializerMethodField('get_display_name')
|
display_name = serializers.SerializerMethodField('get_display_name')
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ class OrganizationBaseSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
model = Organization
|
model = Tenant
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
'id',
|
'id',
|
||||||
@ -42,8 +43,8 @@ class OrganizationBaseSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class OrganizationModelSerializer(
|
class TenantModelSerializer(
|
||||||
OrganizationBaseSerializer
|
TenantBaseSerializer
|
||||||
):
|
):
|
||||||
|
|
||||||
_urls = serializers.SerializerMethodField('get_url')
|
_urls = serializers.SerializerMethodField('get_url')
|
||||||
@ -74,7 +75,7 @@ class OrganizationModelSerializer(
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
model = Organization
|
model = Tenant
|
||||||
|
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ class OrganizationModelSerializer(
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class OrganizationViewSerializer(OrganizationModelSerializer):
|
class TenantViewSerializer(TenantModelSerializer):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
manager = UserBaseSerializer(many=False, read_only = True)
|
manager = UserBaseSerializer(many=False, read_only = True)
|
||||||
|
@ -5,7 +5,7 @@ from drf_spectacular.utils import extend_schema_serializer
|
|||||||
|
|
||||||
from access.functions.permissions import permission_queryset
|
from access.functions.permissions import permission_queryset
|
||||||
from access.models.role import Role
|
from access.models.role import Role
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
|
|
||||||
from api.serializers import common
|
from api.serializers import common
|
||||||
|
|
||||||
@ -109,6 +109,6 @@ class ModelSerializer(
|
|||||||
class ViewSerializer(ModelSerializer):
|
class ViewSerializer(ModelSerializer):
|
||||||
"""Role Base View Model"""
|
"""Role Base View Model"""
|
||||||
|
|
||||||
organization = OrganizationBaseSerializer( many=False, read_only=True )
|
organization = TenantBaseSerializer( many=False, read_only=True )
|
||||||
|
|
||||||
permissions = PermissionBaseSerializer( many=True, read_only=True )
|
permissions = PermissionBaseSerializer( many=True, read_only=True )
|
||||||
|
@ -7,7 +7,7 @@ from access.models.team import Team
|
|||||||
from api.serializers import common
|
from api.serializers import common
|
||||||
|
|
||||||
from access.functions.permissions import permission_queryset
|
from access.functions.permissions import permission_queryset
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
|
|
||||||
from app.serializers.permission import Permission, PermissionBaseSerializer
|
from app.serializers.permission import Permission, PermissionBaseSerializer
|
||||||
|
|
||||||
@ -127,6 +127,6 @@ class TeamModelSerializer(
|
|||||||
|
|
||||||
class TeamViewSerializer(TeamModelSerializer):
|
class TeamViewSerializer(TeamModelSerializer):
|
||||||
|
|
||||||
organization = OrganizationBaseSerializer(many=False, read_only=True)
|
organization = TenantBaseSerializer(many=False, read_only=True)
|
||||||
|
|
||||||
permissions = PermissionBaseSerializer(many = True)
|
permissions = PermissionBaseSerializer(many = True)
|
||||||
|
@ -2,7 +2,7 @@ import pytest
|
|||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.serializers.entity import (
|
from access.serializers.entity import (
|
||||||
Entity,
|
Entity,
|
||||||
ModelSerializer
|
ModelSerializer
|
||||||
|
@ -5,7 +5,7 @@ from django.contrib.contenttypes.models import ContentType
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from access.models.entity import Entity
|
from access.models.entity import Entity
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from access.models.organization_history import Organization, OrganizationHistory
|
from access.models.organization_history import Tenant as Organization, OrganizationHistory
|
||||||
|
|
||||||
from core.tests.abstract.test_functional_history import HistoryEntriesCommon
|
from core.tests.abstract.test_functional_history import HistoryEntriesCommon
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ from django.test import TestCase
|
|||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from access.serializers.organization import (
|
from access.serializers.organization import (
|
||||||
Organization,
|
Tenant,
|
||||||
OrganizationModelSerializer
|
TenantModelSerializer
|
||||||
)
|
)
|
||||||
|
|
||||||
User = django.contrib.auth.get_user_model()
|
User = django.contrib.auth.get_user_model()
|
||||||
@ -18,7 +18,7 @@ class OrganizationValidationAPI(
|
|||||||
TestCase,
|
TestCase,
|
||||||
):
|
):
|
||||||
|
|
||||||
model = Organization
|
model = Tenant
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(self):
|
def setUpTestData(self):
|
||||||
@ -47,7 +47,7 @@ class OrganizationValidationAPI(
|
|||||||
Ensure that if creating and no name is provided a validation error occurs
|
Ensure that if creating and no name is provided a validation error occurs
|
||||||
"""
|
"""
|
||||||
|
|
||||||
serializer = OrganizationModelSerializer(
|
serializer = TenantModelSerializer(
|
||||||
data = self.valid_data
|
data = self.valid_data
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ class OrganizationValidationAPI(
|
|||||||
|
|
||||||
with pytest.raises(ValidationError) as err:
|
with pytest.raises(ValidationError) as err:
|
||||||
|
|
||||||
serializer = OrganizationModelSerializer(
|
serializer = TenantModelSerializer(
|
||||||
data = data
|
data = data
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ class OrganizationValidationAPI(
|
|||||||
|
|
||||||
del data['manager']
|
del data['manager']
|
||||||
|
|
||||||
serializer = OrganizationModelSerializer(
|
serializer = TenantModelSerializer(
|
||||||
data = data
|
data = data
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ from django.contrib.contenttypes.models import ContentType
|
|||||||
from django.shortcuts import reverse
|
from django.shortcuts import reverse
|
||||||
from django.test import Client, TestCase
|
from django.test import Client, TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
@ -318,4 +318,4 @@ class OrganizationMetadata(
|
|||||||
|
|
||||||
menu_id = 'access'
|
menu_id = 'access'
|
||||||
|
|
||||||
menu_entry_id = 'organization'
|
menu_entry_id = 'tenant'
|
@ -3,7 +3,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from core.tests.abstract.model_notes_api_fields import ModelNotesNotesAPIFields
|
from core.tests.abstract.model_notes_api_fields import ModelNotesNotesAPIFields
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.organization_notes import OrganizationNotes
|
from access.models.organization_notes import OrganizationNotes
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from django.test import TestCase
|
|||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.serializers.role import Role, ModelSerializer
|
from access.serializers.role import Role, ModelSerializer
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from django.test import Client, TestCase
|
|||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
|
||||||
from access.models.role import Role
|
from access.models.role import Role
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ from django.test import Client, TestCase
|
|||||||
|
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from rest_framework.exceptions import ValidationError
|
|||||||
|
|
||||||
from access.middleware.request import Tenancy
|
from access.middleware.request import Tenancy
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
|
|
||||||
from access.serializers.teams import (
|
from access.serializers.teams import (
|
||||||
Team,
|
Team,
|
||||||
|
@ -11,7 +11,7 @@ from django.test import Client, TestCase
|
|||||||
|
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
|
|
||||||
from access.serializers.team_user import (
|
from access.serializers.team_user import (
|
||||||
|
@ -8,7 +8,7 @@ from django.test import Client, TestCase
|
|||||||
# from rest_framework.relations import Hyperlink
|
# from rest_framework.relations import Hyperlink
|
||||||
|
|
||||||
from access.models.entity import Entity
|
from access.models.entity import Entity
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ from api.viewsets.common import ModelViewSet
|
|||||||
|
|
||||||
from access.mixins.organization import OrganizationMixin
|
from access.mixins.organization import OrganizationMixin
|
||||||
from access.mixins.permissions import OrganizationPermissionMixin
|
from access.mixins.permissions import OrganizationPermissionMixin
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ from django.test import Client, TestCase
|
|||||||
|
|
||||||
from rest_framework.relations import Hyperlink
|
from rest_framework.relations import Hyperlink
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ from django.test import Client, TestCase
|
|||||||
|
|
||||||
from rest_framework.relations import Hyperlink
|
from rest_framework.relations import Hyperlink
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import pytest
|
|||||||
import unittest
|
import unittest
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
from access.tests.abstract.model_permissions_organization_manager import OrganizationManagerModelPermissionChange, OrganizationManagerModelPermissionView
|
from access.tests.abstract.model_permissions_organization_manager import OrganizationManagerModelPermissionChange, OrganizationManagerModelPermissionView
|
||||||
@ -20,7 +20,7 @@ from app.tests.abstract.model_permissions import ModelPermissionsView, ModelPerm
|
|||||||
User = django.contrib.auth.get_user_model()
|
User = django.contrib.auth.get_user_model()
|
||||||
|
|
||||||
|
|
||||||
class OrganizationPermissions(
|
class TenantPermissions(
|
||||||
TestCase,
|
TestCase,
|
||||||
ModelPermissionsView,
|
ModelPermissionsView,
|
||||||
ModelPermissionsChange,
|
ModelPermissionsChange,
|
||||||
@ -28,7 +28,7 @@ class OrganizationPermissions(
|
|||||||
OrganizationManagerModelPermissionView,
|
OrganizationManagerModelPermissionView,
|
||||||
):
|
):
|
||||||
|
|
||||||
model = Organization
|
model = Tenant
|
||||||
|
|
||||||
app_namespace = 'Access'
|
app_namespace = 'Access'
|
||||||
|
|
||||||
@ -53,11 +53,11 @@ class OrganizationPermissions(
|
|||||||
4. create a user per team
|
4. create a user per team
|
||||||
"""
|
"""
|
||||||
|
|
||||||
organization = Organization.objects.create(name='test_org')
|
organization = Tenant.objects.create(name='test_org')
|
||||||
|
|
||||||
self.organization = organization
|
self.organization = organization
|
||||||
|
|
||||||
different_organization = Organization.objects.create(
|
different_organization = Tenant.objects.create(
|
||||||
name='test_different_organization'
|
name='test_different_organization'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from django.contrib.contenttypes.models import ContentType
|
|||||||
from django.shortcuts import reverse
|
from django.shortcuts import reverse
|
||||||
from django.test import Client, TestCase
|
from django.test import Client, TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import unittest
|
|||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from core.tests.abstract.test_unit_model_history_api_v2 import PrimaryModelHistoryAPI
|
from core.tests.abstract.test_unit_model_history_api_v2 import PrimaryModelHistoryAPI
|
||||||
|
|
||||||
from access.models.organization_history import Organization, OrganizationHistory
|
from access.models.organization_history import Tenant as Organization, OrganizationHistory
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from django.test import Client, TestCase
|
|||||||
# from rest_framework.relations import Hyperlink
|
# from rest_framework.relations import Hyperlink
|
||||||
|
|
||||||
from access.models.role import Role
|
from access.models.role import Role
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ from django.test import Client, TestCase
|
|||||||
|
|
||||||
from rest_framework.relations import Hyperlink
|
from rest_framework.relations import Hyperlink
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from django.test import Client, TestCase
|
|||||||
|
|
||||||
from rest_framework.relations import Hyperlink
|
from rest_framework.relations import Hyperlink
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import pytest
|
|||||||
import unittest
|
import unittest
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
from access.tests.abstract.model_permissions_organization_manager import OrganizationManagerModelPermissions
|
from access.tests.abstract.model_permissions_organization_manager import OrganizationManagerModelPermissions
|
||||||
|
@ -9,7 +9,7 @@ from django.contrib.auth.models import AnonymousUser, Permission
|
|||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from django.test import Client, TestCase
|
|||||||
|
|
||||||
from rest_framework.relations import Hyperlink
|
from rest_framework.relations import Hyperlink
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import unittest
|
|||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import pytest
|
|||||||
import unittest
|
import unittest
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import django
|
import django
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from django.core.exceptions import ObjectDoesNotExist
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.urls.exceptions import NoReverseMatch
|
from django.urls.exceptions import NoReverseMatch
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.tenancy import TenancyManager
|
from access.models.tenancy import TenancyManager
|
||||||
from access.models.tenancy import (
|
from access.models.tenancy import (
|
||||||
TenancyObject,
|
TenancyObject,
|
||||||
|
@ -4,7 +4,7 @@ from django.utils.decorators import method_decorator
|
|||||||
from django.views import generic
|
from django.views import generic
|
||||||
|
|
||||||
from access.mixin import *
|
from access.mixin import *
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
|
|
||||||
from access.forms.organization import OrganizationForm
|
from access.forms.organization import OrganizationForm
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ class IndexView(IndexView):
|
|||||||
|
|
||||||
model = Organization
|
model = Organization
|
||||||
permission_required = [
|
permission_required = [
|
||||||
'access.view_organization'
|
'access.view_tenant'
|
||||||
]
|
]
|
||||||
template_name = 'access/index.html.j2'
|
template_name = 'access/index.html.j2'
|
||||||
context_object_name = "organization_list"
|
context_object_name = "organization_list"
|
||||||
@ -61,7 +61,7 @@ class View(ChangeView):
|
|||||||
|
|
||||||
return self.handle_no_permission()
|
return self.handle_no_permission()
|
||||||
|
|
||||||
if not self.permission_check(request, [ 'access.view_organization' ]):
|
if not self.permission_check(request, [ 'access.view_tenant' ]):
|
||||||
|
|
||||||
raise PermissionDenied('You are not part of this organization')
|
raise PermissionDenied('You are not part of this organization')
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class View(ChangeView):
|
|||||||
|
|
||||||
return self.handle_no_permission()
|
return self.handle_no_permission()
|
||||||
|
|
||||||
if not self.permission_check(request, [ 'access.change_organization' ]):
|
if not self.permission_check(request, [ 'access.change_tenant' ]):
|
||||||
|
|
||||||
raise PermissionDenied('You are not part of this organization')
|
raise PermissionDenied('You are not part of this organization')
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from django.urls import reverse
|
|||||||
|
|
||||||
from access.forms.team import TeamForm, TeamFormAdd
|
from access.forms.team import TeamForm, TeamFormAdd
|
||||||
from access.mixin import *
|
from access.mixin import *
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ from drf_spectacular.utils import extend_schema, extend_schema_view, OpenApiResp
|
|||||||
# THis import only exists so that the migrations can be created
|
# THis import only exists so that the migrations can be created
|
||||||
from access.models.organization_history import OrganizationHistory # pylint: disable=W0611:unused-import
|
from access.models.organization_history import OrganizationHistory # pylint: disable=W0611:unused-import
|
||||||
from access.serializers.organization import (
|
from access.serializers.organization import (
|
||||||
Organization,
|
Tenant,
|
||||||
OrganizationModelSerializer,
|
TenantModelSerializer,
|
||||||
OrganizationViewSerializer
|
TenantViewSerializer
|
||||||
)
|
)
|
||||||
|
|
||||||
from api.viewsets.common import ModelViewSet
|
from api.viewsets.common import ModelViewSet
|
||||||
@ -19,7 +19,7 @@ from api.viewsets.common import ModelViewSet
|
|||||||
description='',
|
description='',
|
||||||
responses = {
|
responses = {
|
||||||
# 200: OpenApiResponse(description='Allready exists', response=OrganizationViewSerializer),
|
# 200: OpenApiResponse(description='Allready exists', response=OrganizationViewSerializer),
|
||||||
201: OpenApiResponse(description='Created', response=OrganizationViewSerializer),
|
201: OpenApiResponse(description='Created', response=TenantViewSerializer),
|
||||||
# 400: OpenApiResponse(description='Validation failed.'),
|
# 400: OpenApiResponse(description='Validation failed.'),
|
||||||
403: OpenApiResponse(description='User is missing add permissions'),
|
403: OpenApiResponse(description='User is missing add permissions'),
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ from api.viewsets.common import ModelViewSet
|
|||||||
summary = 'Fetch all orgnaizations',
|
summary = 'Fetch all orgnaizations',
|
||||||
description='',
|
description='',
|
||||||
responses = {
|
responses = {
|
||||||
200: OpenApiResponse(description='', response=OrganizationViewSerializer),
|
200: OpenApiResponse(description='', response=TenantViewSerializer),
|
||||||
403: OpenApiResponse(description='User is missing view permissions'),
|
403: OpenApiResponse(description='User is missing view permissions'),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -44,7 +44,7 @@ from api.viewsets.common import ModelViewSet
|
|||||||
summary = 'Fetch a single orgnaization',
|
summary = 'Fetch a single orgnaization',
|
||||||
description='',
|
description='',
|
||||||
responses = {
|
responses = {
|
||||||
200: OpenApiResponse(description='', response=OrganizationViewSerializer),
|
200: OpenApiResponse(description='', response=TenantViewSerializer),
|
||||||
403: OpenApiResponse(description='User is missing view permissions'),
|
403: OpenApiResponse(description='User is missing view permissions'),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -53,7 +53,7 @@ from api.viewsets.common import ModelViewSet
|
|||||||
summary = 'Update an orgnaization',
|
summary = 'Update an orgnaization',
|
||||||
description = '',
|
description = '',
|
||||||
responses = {
|
responses = {
|
||||||
200: OpenApiResponse(description='', response=OrganizationViewSerializer),
|
200: OpenApiResponse(description='', response=TenantViewSerializer),
|
||||||
# 201: OpenApiResponse(description='Created', response=OrganizationViewSerializer),
|
# 201: OpenApiResponse(description='Created', response=OrganizationViewSerializer),
|
||||||
# # 400: OpenApiResponse(description='Validation failed.'),
|
# # 400: OpenApiResponse(description='Validation failed.'),
|
||||||
403: OpenApiResponse(description='User is missing change permissions'),
|
403: OpenApiResponse(description='User is missing change permissions'),
|
||||||
@ -71,9 +71,9 @@ class ViewSet( ModelViewSet ):
|
|||||||
'name',
|
'name',
|
||||||
]
|
]
|
||||||
|
|
||||||
model = Organization
|
model = Tenant
|
||||||
|
|
||||||
view_description = 'Centurion Organizations'
|
view_description = 'Centurion Tenants'
|
||||||
|
|
||||||
def get_serializer_class(self):
|
def get_serializer_class(self):
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from drf_spectacular.utils import extend_schema, extend_schema_view, OpenApiParameter, OpenApiResponse
|
from drf_spectacular.utils import extend_schema, extend_schema_view, OpenApiParameter, OpenApiResponse
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
# THis import only exists so that the migrations can be created
|
# THis import only exists so that the migrations can be created
|
||||||
from access.models.team_history import TeamHistory # pylint: disable=W0611:unused-import
|
from access.models.team_history import TeamHistory # pylint: disable=W0611:unused-import
|
||||||
from access.serializers.teams import (
|
from access.serializers.teams import (
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
# Generated by Django 5.1.9 on 2025-05-14 13:48
|
||||||
|
|
||||||
|
import access.models.tenancy
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('access', '0008_alter_tenant_options_alter_entity_organization_and_more'),
|
||||||
|
('accounting', '0003_assetbasenotes'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='assetbase',
|
||||||
|
name='organization',
|
||||||
|
field=models.ForeignKey(help_text='Tenancy this belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='access.tenant', validators=[access.models.tenancy.TenancyObject.validatate_organization_exists], verbose_name='Tenant'),
|
||||||
|
),
|
||||||
|
]
|
@ -2,7 +2,7 @@ from rest_framework import serializers
|
|||||||
|
|
||||||
from drf_spectacular.utils import extend_schema_serializer
|
from drf_spectacular.utils import extend_schema_serializer
|
||||||
|
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
|
|
||||||
from accounting.models.asset_base import AssetBase
|
from accounting.models.asset_base import AssetBase
|
||||||
|
|
||||||
@ -105,4 +105,4 @@ class ModelSerializer(
|
|||||||
class ViewSerializer(ModelSerializer):
|
class ViewSerializer(ModelSerializer):
|
||||||
"""Ticket Base View Model"""
|
"""Ticket Base View Model"""
|
||||||
|
|
||||||
organization = OrganizationBaseSerializer(many=False, read_only=True)
|
organization = TenantBaseSerializer(many=False, read_only=True)
|
||||||
|
@ -3,7 +3,7 @@ from django.contrib.auth.models import Permission
|
|||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from django.contrib.auth.models import Permission
|
|||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ from rest_framework.utils.field_mapping import ClassLookupDict
|
|||||||
|
|
||||||
from rest_framework_json_api.utils import get_related_resource_type
|
from rest_framework_json_api.utils import get_related_resource_type
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant
|
||||||
|
|
||||||
from app.serializers.user import User, UserBaseSerializer
|
from app.serializers.user import User, UserBaseSerializer
|
||||||
|
|
||||||
@ -392,9 +392,10 @@ class ReactUIMetadata(OverRideJSONAPIMetadata):
|
|||||||
"display_name": "Access",
|
"display_name": "Access",
|
||||||
"name": "access",
|
"name": "access",
|
||||||
"pages": {
|
"pages": {
|
||||||
'view_organization': {
|
'view_tenant': {
|
||||||
"display_name": "Organization",
|
"display_name": "Tenancy",
|
||||||
"name": "organization",
|
"name": "tenant",
|
||||||
|
"icon": "organization",
|
||||||
"link": "/access/organization"
|
"link": "/access/organization"
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -705,7 +706,7 @@ class ReactUIMetadata(OverRideJSONAPIMetadata):
|
|||||||
|
|
||||||
# user = view.request.user
|
# user = view.request.user
|
||||||
|
|
||||||
user_orgainzations = Organization.objects.filter(
|
user_orgainzations = Tenant.objects.filter(
|
||||||
manager = request.user
|
manager = request.user
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from rest_framework import serializers, request
|
from rest_framework import serializers, request
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
|
|
||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission
|
||||||
|
@ -3,7 +3,7 @@ import re
|
|||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
|
|
||||||
from api.models.tokens import AuthToken
|
from api.models.tokens import AuthToken
|
||||||
from api.serializers import common
|
from api.serializers import common
|
||||||
@ -132,4 +132,4 @@ class AuthTokenModelSerializer(
|
|||||||
|
|
||||||
class AuthTokenViewSerializer(AuthTokenModelSerializer):
|
class AuthTokenViewSerializer(AuthTokenModelSerializer):
|
||||||
|
|
||||||
organization = OrganizationBaseSerializer( many = False, read_only = True )
|
organization = TenantBaseSerializer( many = False, read_only = True )
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
|
||||||
from access.serializers.organization import Organization
|
from access.serializers.organization import Tenant
|
||||||
|
|
||||||
from assistance.models.model_knowledge_base_article import all_models
|
from assistance.models.model_knowledge_base_article import all_models
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ class OrganizationField(serializers.PrimaryKeyRelatedField):
|
|||||||
if defined.
|
if defined.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
queryset = Organization.objects.all()
|
queryset = Tenant.objects.all()
|
||||||
|
|
||||||
if self.context.get('request', None):
|
if self.context.get('request', None):
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from rest_framework.exceptions import ValidationError, PermissionDenied
|
from rest_framework.exceptions import ValidationError, PermissionDenied
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
|
|
||||||
from api.serializers.auth_token import AuthToken, AuthTokenModelSerializer
|
from api.serializers.auth_token import AuthToken, AuthTokenModelSerializer
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from django.contrib.contenttypes.models import ContentType
|
|||||||
from django.shortcuts import reverse
|
from django.shortcuts import reverse
|
||||||
from django.test import Client, TestCase
|
from django.test import Client, TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import django
|
|||||||
from django.shortcuts import reverse
|
from django.shortcuts import reverse
|
||||||
from django.test import Client, TestCase
|
from django.test import Client, TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
|
|
||||||
from api.tests.unit.test_unit_common_viewset import IndexViewsetInheritedCases
|
from api.tests.unit.test_unit_common_viewset import IndexViewsetInheritedCases
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from django.contrib.auth.models import Permission
|
|||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.test import Client, TestCase
|
from django.test import Client, TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
@ -36,8 +36,8 @@ class NavigationMenu(
|
|||||||
users_to_create: dict = {
|
users_to_create: dict = {
|
||||||
'access': [
|
'access': [
|
||||||
{
|
{
|
||||||
'content_model': 'organization',
|
'content_model': 'tenant',
|
||||||
'permission_model': 'organization'
|
'permission_model': 'tenant'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'assistance': [
|
'assistance': [
|
||||||
@ -189,18 +189,18 @@ class NavigationMenu(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_navigation_menu_visible_access_organization_exist(self):
|
def test_navigation_menu_visible_access_tenant_exist(self):
|
||||||
"""Navigation Menu Check
|
"""Navigation Menu Check
|
||||||
|
|
||||||
Ensure that if the user has the permission, the navigation menu and
|
Ensure that if the user has the permission, the navigation menu and
|
||||||
page is available for the user
|
page is available for the user
|
||||||
"""
|
"""
|
||||||
|
|
||||||
nav_menu = self.metadata.get_navigation(self.access_organization)
|
nav_menu = self.metadata.get_navigation(self.access_tenant)
|
||||||
|
|
||||||
menu_name = 'access'
|
menu_name = 'access'
|
||||||
|
|
||||||
page_name = 'organization'
|
page_name = 'tenant'
|
||||||
|
|
||||||
menu_page_exists: bool = False
|
menu_page_exists: bool = False
|
||||||
|
|
||||||
@ -221,14 +221,14 @@ class NavigationMenu(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_navigation_menu_visible_access_organization_no_additional_exist(self):
|
def test_navigation_menu_visible_access_tenant_no_additional_exist(self):
|
||||||
"""Navigation Menu Check
|
"""Navigation Menu Check
|
||||||
|
|
||||||
Ensure that only the navigation menu and entry is the only one displayed
|
Ensure that only the navigation menu and entry is the only one displayed
|
||||||
for the user who has the desired permission
|
for the user who has the desired permission
|
||||||
"""
|
"""
|
||||||
|
|
||||||
nav_menu = self.metadata.get_navigation(self.access_organization)
|
nav_menu = self.metadata.get_navigation(self.access_tenant)
|
||||||
|
|
||||||
pages_found: int = 0
|
pages_found: int = 0
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ from rest_framework_json_api.metadata import JSONAPIMetadata
|
|||||||
from access.middleware.request import Tenancy
|
from access.middleware.request import Tenancy
|
||||||
from access.mixins.organization import OrganizationMixin
|
from access.mixins.organization import OrganizationMixin
|
||||||
from access.mixins.permissions import OrganizationPermissionMixin
|
from access.mixins.permissions import OrganizationPermissionMixin
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from datetime import datetime, timedelta
|
|||||||
from django.shortcuts import reverse
|
from django.shortcuts import reverse
|
||||||
from django.test import TestCase, Client
|
from django.test import TestCase, Client
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
|
|
||||||
from api.models.tokens import AuthToken
|
from api.models.tokens import AuthToken
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from django.contrib.contenttypes.models import ContentType
|
|||||||
from django.shortcuts import reverse
|
from django.shortcuts import reverse
|
||||||
from django.test import Client, TestCase
|
from django.test import Client, TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from rest_framework.permissions import DjangoObjectPermissions
|
|||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
|
||||||
from access.mixin import OrganizationMixin
|
from access.mixin import OrganizationMixin
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
|
|
||||||
from api.serializers.access import OrganizationSerializer, OrganizationListSerializer, TeamSerializer, TeamPermissionSerializer
|
from api.serializers.access import OrganizationSerializer, OrganizationListSerializer, TeamSerializer, TeamPermissionSerializer
|
||||||
|
@ -182,7 +182,7 @@ class OrganizationPermissionAPI(DjangoObjectPermissions, OrganizationMixin):
|
|||||||
|
|
||||||
if 'pk' in view.kwargs:
|
if 'pk' in view.kwargs:
|
||||||
|
|
||||||
if object_organization is None and view.queryset.model._meta.model_name == 'organization' and view.kwargs['pk']:
|
if object_organization is None and view.queryset.model._meta.model_name == 'tenant' and view.kwargs['pk']:
|
||||||
|
|
||||||
object_organization = view.kwargs['pk']
|
object_organization = view.kwargs['pk']
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from app.urls import urlpatterns
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.urls import URLPattern, URLResolver
|
from django.urls import URLPattern, URLResolver
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
|
|
||||||
from settings.models.user_settings import UserSettings
|
from settings.models.user_settings import UserSettings
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import django
|
import django
|
||||||
|
|
||||||
from access.middleware.request import Tenancy
|
from access.middleware.request import Tenancy
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
|
|
||||||
from settings.models.app_settings import AppSettings
|
from settings.models.app_settings import AppSettings
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from django.db.models import fields
|
|||||||
|
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.tests.unit.tenancy_object.test_unit_tenancy_object_model import (
|
from access.tests.unit.tenancy_object.test_unit_tenancy_object_model import (
|
||||||
TenancyObjectInheritedCases as AccessTenancyObjectInheritedCases
|
TenancyObjectInheritedCases as AccessTenancyObjectInheritedCases
|
||||||
)
|
)
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
# Generated by Django 5.1.9 on 2025-05-14 13:48
|
||||||
|
|
||||||
|
import access.models.tenancy
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('access', '0008_alter_tenant_options_alter_entity_organization_and_more'),
|
||||||
|
('assistance', '0005_knowledgebasecategoryhistory_knowledgebasehistory'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='knowledgebase',
|
||||||
|
name='organization',
|
||||||
|
field=models.ForeignKey(help_text='Tenancy this belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='access.tenant', validators=[access.models.tenancy.TenancyObject.validatate_organization_exists], verbose_name='Tenant'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='knowledgebasecategory',
|
||||||
|
name='organization',
|
||||||
|
field=models.ForeignKey(help_text='Tenancy this belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='access.tenant', validators=[access.models.tenancy.TenancyObject.validatate_organization_exists], verbose_name='Tenant'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='modelknowledgebasearticle',
|
||||||
|
name='organization',
|
||||||
|
field=models.ForeignKey(help_text='Tenancy this belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='access.tenant', validators=[access.models.tenancy.TenancyObject.validatate_organization_exists], verbose_name='Tenant'),
|
||||||
|
),
|
||||||
|
]
|
@ -3,7 +3,7 @@ from rest_framework.reverse import reverse
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
from access.serializers.teams import TeamBaseSerializer
|
from access.serializers.teams import TeamBaseSerializer
|
||||||
|
|
||||||
from app.serializers.user import UserBaseSerializer
|
from app.serializers.user import UserBaseSerializer
|
||||||
@ -187,7 +187,7 @@ class KnowledgeBaseViewSerializer(KnowledgeBaseModelSerializer):
|
|||||||
|
|
||||||
category = KnowledgeBaseCategoryBaseSerializer( read_only = True )
|
category = KnowledgeBaseCategoryBaseSerializer( read_only = True )
|
||||||
|
|
||||||
organization = OrganizationBaseSerializer( many=False, read_only=True )
|
organization = TenantBaseSerializer( many=False, read_only=True )
|
||||||
|
|
||||||
responsible_teams = TeamBaseSerializer( read_only = True, many = True)
|
responsible_teams = TeamBaseSerializer( read_only = True, many = True)
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from rest_framework import serializers
|
|||||||
from rest_framework.exceptions import ParseError, ValidationError
|
from rest_framework.exceptions import ParseError, ValidationError
|
||||||
|
|
||||||
|
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
from access.serializers.teams import TeamBaseSerializer
|
from access.serializers.teams import TeamBaseSerializer
|
||||||
|
|
||||||
from app.serializers.user import UserBaseSerializer
|
from app.serializers.user import UserBaseSerializer
|
||||||
@ -182,7 +182,7 @@ class KnowledgeBaseCategoryModelSerializer(
|
|||||||
|
|
||||||
class KnowledgeBaseCategoryViewSerializer(KnowledgeBaseCategoryModelSerializer):
|
class KnowledgeBaseCategoryViewSerializer(KnowledgeBaseCategoryModelSerializer):
|
||||||
|
|
||||||
organization = OrganizationBaseSerializer( many=False, read_only=True )\
|
organization = TenantBaseSerializer( many=False, read_only=True )\
|
||||||
|
|
||||||
parent_category = KnowledgeBaseCategoryBaseSerializer( many = False, read_only = True)
|
parent_category = KnowledgeBaseCategoryBaseSerializer( many = False, read_only = True)
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from django.apps import apps
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
|
|
||||||
from api.serializers import common
|
from api.serializers import common
|
||||||
|
|
||||||
@ -142,4 +142,4 @@ class ModelKnowledgeBaseArticleViewSerializer(ModelKnowledgeBaseArticleModelSeri
|
|||||||
|
|
||||||
category = KnowledgeBaseCategoryBaseSerializer(source = 'article.category', read_only = True )
|
category = KnowledgeBaseCategoryBaseSerializer(source = 'article.category', read_only = True )
|
||||||
|
|
||||||
organization = OrganizationBaseSerializer( many=False, read_only=True )
|
organization = TenantBaseSerializer( many=False, read_only=True )
|
||||||
|
@ -6,7 +6,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
|
|
||||||
from app.tests.abstract.mock_view import MockView
|
from app.tests.abstract.mock_view import MockView
|
||||||
|
@ -9,7 +9,7 @@ from django.contrib.auth.models import AnonymousUser, Permission
|
|||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
|
|
||||||
from app.tests.abstract.mock_view import MockView
|
from app.tests.abstract.mock_view import MockView
|
||||||
|
@ -5,7 +5,7 @@ from django.contrib.auth.models import Permission
|
|||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
|
|
||||||
from assistance.models.model_knowledge_base_article import KnowledgeBase, ModelKnowledgeBaseArticle
|
from assistance.models.model_knowledge_base_article import KnowledgeBase, ModelKnowledgeBaseArticle
|
||||||
|
@ -11,7 +11,7 @@ from django.test import Client, TestCase
|
|||||||
|
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from django.test import Client, TestCase
|
|||||||
|
|
||||||
from rest_framework.relations import Hyperlink
|
from rest_framework.relations import Hyperlink
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import pytest
|
|||||||
import unittest
|
import unittest
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from django.test import Client, TestCase
|
|||||||
|
|
||||||
from rest_framework.relations import Hyperlink
|
from rest_framework.relations import Hyperlink
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import pytest
|
|||||||
import unittest
|
import unittest
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from django.test import Client, TestCase
|
|||||||
|
|
||||||
from rest_framework.relations import Hyperlink
|
from rest_framework.relations import Hyperlink
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
|
|
||||||
from app.tests.unit.test_unit_models import (
|
from app.tests.unit.test_unit_models import (
|
||||||
TenancyObjectInheritedCases
|
TenancyObjectInheritedCases
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
# Generated by Django 5.1.9 on 2025-05-14 13:48
|
||||||
|
|
||||||
|
import access.models.tenancy
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('access', '0008_alter_tenant_options_alter_entity_organization_and_more'),
|
||||||
|
('config_management', '0007_configgroupshistory_configgrouphostshistory_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='configgrouphosts',
|
||||||
|
name='organization',
|
||||||
|
field=models.ForeignKey(help_text='Tenancy this belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='access.tenant', validators=[access.models.tenancy.TenancyObject.validatate_organization_exists], verbose_name='Tenant'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='configgroups',
|
||||||
|
name='organization',
|
||||||
|
field=models.ForeignKey(help_text='Tenancy this belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='access.tenant', validators=[access.models.tenancy.TenancyObject.validatate_organization_exists], verbose_name='Tenant'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='configgroupsoftware',
|
||||||
|
name='organization',
|
||||||
|
field=models.ForeignKey(help_text='Tenancy this belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='access.tenant', validators=[access.models.tenancy.TenancyObject.validatate_organization_exists], verbose_name='Tenant'),
|
||||||
|
),
|
||||||
|
]
|
@ -2,7 +2,7 @@ from rest_framework import serializers
|
|||||||
from rest_framework.fields import empty
|
from rest_framework.fields import empty
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
|
|
||||||
from api.serializers import common
|
from api.serializers import common
|
||||||
|
|
||||||
@ -200,4 +200,4 @@ class ConfigGroupViewSerializer(ConfigGroupModelSerializer):
|
|||||||
|
|
||||||
parent = ConfigGroupBaseSerializer( read_only = True )
|
parent = ConfigGroupBaseSerializer( read_only = True )
|
||||||
|
|
||||||
organization = OrganizationBaseSerializer( many=False, read_only=True )
|
organization = TenantBaseSerializer( many=False, read_only=True )
|
||||||
|
@ -2,7 +2,7 @@ from rest_framework import serializers
|
|||||||
from rest_framework.fields import empty
|
from rest_framework.fields import empty
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
|
||||||
from access.serializers.organization import OrganizationBaseSerializer
|
from access.serializers.organization import TenantBaseSerializer
|
||||||
|
|
||||||
from api.serializers import common
|
from api.serializers import common
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ class ConfigGroupSoftwareViewSerializer(ConfigGroupSoftwareModelSerializer):
|
|||||||
|
|
||||||
config_group = ConfigGroupBaseSerializer(read_only = True )
|
config_group = ConfigGroupBaseSerializer(read_only = True )
|
||||||
|
|
||||||
organization = OrganizationBaseSerializer( many=False, read_only=True )
|
organization = TenantBaseSerializer( many=False, read_only=True )
|
||||||
|
|
||||||
software = SoftwareBaseSerializer( read_only = True )
|
software = SoftwareBaseSerializer( read_only = True )
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
|
|
||||||
from app.tests.abstract.mock_view import MockView, User
|
from app.tests.abstract.mock_view import MockView, User
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from django.contrib.auth.models import AnonymousUser, Permission
|
|||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
|
|
||||||
from config_management.serializers.config_group_software import ConfigGroupSoftware, ConfigGroupSoftwareModelSerializer
|
from config_management.serializers.config_group_software import ConfigGroupSoftware, ConfigGroupSoftwareModelSerializer
|
||||||
from config_management.models.groups import ConfigGroups
|
from config_management.models.groups import ConfigGroups
|
||||||
|
@ -9,7 +9,7 @@ from django.contrib.auth.models import AnonymousUser, Permission
|
|||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from access.models.organization import Organization
|
from access.models.tenant import Tenant as Organization
|
||||||
from access.models.team import Team
|
from access.models.team import Team
|
||||||
from access.models.team_user import TeamUsers
|
from access.models.team_user import TeamUsers
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user