Skip to content

Tenancy Object


This page contains the Tenancy Object API Documentation.

Tenancy Object Model Abstract class

Bases: SaveHistory

Tenancy Model Abstrct class.

This class is for inclusion wihtin every model within Centurion ERP. Provides the required fields, functions and methods for multi tennant objects. Unless otherwise stated, no object within this class may be overridden.

Raises:

Type Description
ValidationError

User failed to supply organization

Attributes

objects = TenancyManager()

Multi-Tenanant Objects

id = models.AutoField(blank=False, help_text='ID of the item', primary_key=True, unique=True, verbose_name='ID')

organization = models.ForeignKey(Organization, blank=False, help_text='Organization this belongs to', null=False, on_delete=models.CASCADE, validators=[validatate_organization_exists], verbose_name='Organization')

is_global = models.BooleanField(blank=False, default=False, help_text='Is this a global object?', verbose_name='Global Object')

model_notes = models.TextField(blank=True, default=None, help_text='Tid bits of information', null=True, verbose_name='Notes')

Classes

Meta

Attributes
abstract = True

Functions

validatate_organization_exists()

Ensure that the user did provide an organization

Raises:

Type Description
ValidationError

User failed to supply organization.

get_organization()

get_url(request=None)

Fetch the models URL

If URL kwargs are required to generate the URL, define a get_url_kwargs that returns them.

Parameters:

Name Type Description Default
request object

The request object that was made by the end user. Defaults to None.

None

Returns:

Name Type Description
str str

Canonical URL of the model if the request object was provided. Otherwise the relative URL.

get_url_kwargs()

Fetch the URL kwargs

Returns:

Name Type Description
dict dict

kwargs required for generating the URL with reverse

save(force_insert=False, force_update=False, using=None, update_fields=None)

Tenancy Object Manager

Bases: Manager

Multi-Tennant Object Manager

This manager specifically caters for the multi-tenancy features of Centurion ERP.

Functions

get_queryset()

Fetch the data

This function filters the data fetched from the database to that which is from the organizations the user is a part of.

Requirement

This method may be overridden however must still be called from the overriding function. i.e. super().get_queryset()

Workflow

This functions workflow is as follows:

  • Fetch the user from the request

  • Check if the user is authenticated

  • Iterate over the users teams

  • Store unique organizations from users teams

  • return results

Returns:

Type Description
queryset

super user: return unfiltered data.

queryset

not super user: return data from the stored unique organizations.

About:

This page forms part of our Project Centurion ERP.

Page Metadata
Version: ToDo: place files short git commit here
Date Created: 2024-07-15
Date Edited: 2024-07-15

Contribution:

Would You like to contribute to our Centurion ERP project? You can assist in the following ways:

 

ToDo: Add the page list of contributors