ferrosoft.apps.ferrobase.models package

Submodules

ferrosoft.apps.ferrobase.models.base module

class ferrosoft.apps.ferrobase.models.base.AccessKeyMixin(*args, **kwargs)[source]

Bases: UUIDModel

Mixin that adds a time-limited, single-use access key to a model.

The key is a SHA-256 hex digest generated from settings.SECRET_KEY plus OS random bytes, stored in access_key. It expires after _DEFAULT_VALIDITY (1 day by default). Used for password-reset and account-activation tokens.

class Meta[source]

Bases: object

abstract = False
access_key

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

access_key_expiry

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod get_if_not_expired(access_key)[source]
get_next_by_access_key_expiry(*, field=<django.db.models.fields.DateTimeField: access_key_expiry>, is_next=True, **kwargs)
get_previous_by_access_key_expiry(*, field=<django.db.models.fields.DateTimeField: access_key_expiry>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod new_access_key_params(expiry=None)[source]

Generate a new access key and expiry date.

Return type:

dict

class ferrosoft.apps.ferrobase.models.base.AddressMixin(*args, **kwargs)[source]

Bases: UUIDModel

Add address fields to a model.

class Meta[source]

Bases: object

abstract = False
additional_lines

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property address
address_lines()[source]
city

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

company

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

country

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

country_id
first_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

house_no

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

postal_code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

salutation

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

salutation_id
street

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ferrosoft.apps.ferrobase.models.base.CommonLimit(*values)[source]

Bases: Enum

Defines common limits for VARCHAR columns.

Its usage is DISCOURAGED, because PostgreSQL does not require an arbitrary limit on VARCHAR columns. There is also no performance benefit.

BIG_CHAR = 2000
NORMAL_CHAR = 1000
TINY_CHAR = 100
class ferrosoft.apps.ferrobase.models.base.CoordinatesMixin(*args, **kwargs)[source]

Bases: UUIDModel

class Meta[source]

Bases: object

abstract = False
property coordinates: Tuple[Decimal, Decimal]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

latitude

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

longitude

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ferrosoft.apps.ferrobase.models.base.ISOCatalogEntry(*args, **kwargs)[source]

Bases: UUIDModel

Abstract base for ISO-coded catalog entities (countries, languages, etc.).

Subclasses store an iso_code (unique), an english_name, and a localized_name. The manager keeps entries sorted by iso_code.

class Meta[source]

Bases: object

abstract = False
english_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod get_by_iso_code(code)[source]
classmethod get_ordered()[source]
Return type:

QuerySet

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod id_mapping()[source]

Create mapping from ISO code to internal ID. Returns: dict

Return type:

dict

iso_code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

localized_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects
class ferrosoft.apps.ferrobase.models.base.ISOCatalogEntryManager(*args, **kwargs)[source]

Bases: Manager

Manager for ISOCatalogEntry models.

Returns querysets ordered by iso_code by default and provides an upsert method for bulk-synchronising catalog data from release fixtures.

get_queryset()[source]

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

upsert(objects)[source]
class ferrosoft.apps.ferrobase.models.base.IntegerChoicesMixin(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntegerChoices

Additional methods for IntegerChoices.

classmethod do_parse(value)[source]

Parse value as an instance of the IntegerChoices class or raise ValueError.

classmethod try_parse(value, default=None)[source]

Parse value as an instance of the IntegerChoices class or return None.

class ferrosoft.apps.ferrobase.models.base.ObjectLookupCache(queryset, key_parts_func)[source]

Bases: object

In-memory lookup cache for a queryset of model instances.

Builds a dictionary indexed by a composite key derived from each object via key_parts_func. Useful for bulk import operations that need fast repeated lookups without hitting the database on every iteration.

get(key, default=None)[source]
static lookup_key(key_parts)[source]
update(objects)[source]
exception ferrosoft.apps.ferrobase.models.base.PrefetchedFieldMissing(field_name)[source]

Bases: RuntimeError

Raised when a method requires a prefetched related field that was not loaded.

class ferrosoft.apps.ferrobase.models.base.ReadOnlyMixin(*args, **kwargs)[source]

Bases: UUIDModel

Models can be marked read-only to prevent updates and deletions.

Generic views try to get this attribute from model instances to determine whether to enable certain functionality.

class Meta[source]

Bases: object

abstract = False
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

read_only

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ferrosoft.apps.ferrobase.models.base.SelectOptionsMixin[source]

Bases: object

Mixin that adds a select_options class method for use in HTML select widgets.

Returns a list of (pk_str, label) tuples ordered by the field named in order_by_field (defaults to "name").

classmethod order_by_field()[source]
classmethod select_options()[source]
class ferrosoft.apps.ferrobase.models.base.UUIDModel(*args, **kwargs)[source]

Bases: Model

Abstract base model with a UUID v4 primary key.

All concrete models in Ferrobase should inherit from this class rather than Django’s default integer-keyed Model so that primary keys are opaque, globally unique, and safe to expose in URLs.

class Meta[source]

Bases: object

abstract = False
classmethod get_by_id(pk)[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

ferrosoft.apps.ferrobase.models.base.prefetched_field(field_name, expected_type)[source]

Decorator that guards a method behind a prefetch-loaded related field.

Raises PrefetchedFieldMissing when the named attribute on the instance is not an instance of expected_type, which typically means the queryset did not call prefetch_related before invoking the method.

Parameters:
  • field_name (str) – Attribute name to inspect on the model instance.

  • expected_type – Type the attribute must be an instance of.

Returns:

Decorated function that validates the prefetched field before

delegating to the original function.

Return type:

Callable

ferrosoft.apps.ferrobase.models.builtin module

class ferrosoft.apps.ferrobase.models.builtin.BuiltinSubscriptionPlan(plan, features)[source]

Bases: object

features: Iterable[FeatureAssignment]
plan: SubscriptionPlan

ferrosoft.apps.ferrobase.models.decimal module

class ferrosoft.apps.ferrobase.models.decimal.DecimalWithUnit(value, unit)[source]

Bases: object

DecimalWithUnit wraps a decimal with a unit of measurement.

classmethod create(value, symbol)[source]
Return type:

DecimalWithUnit

format_mass()[source]
Return type:

DecimalWithUnit

is_unit(symbol)[source]
Return type:

bool

round(decimal_places=0)[source]
Return type:

DecimalWithUnit

symbols_differ(other)[source]
Return type:

bool

try_unit()[source]

Return unit or raise exception.

unit: MeasurementUnit | None
value: Decimal
with_unit(symbol)[source]
Return type:

DecimalWithUnit

classmethod zero(unit=None)[source]
class ferrosoft.apps.ferrobase.models.decimal.DecimalWithUnitField(*args, unit, **kwargs)[source]

Bases: DecimalField

A decimal value with a certain presumed unit.

from_db_value(value, expression, connection, **kwargs)[source]
to_python(value)[source]

Convert the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can’t be converted. Return the converted value. Subclasses should override this.

ferrosoft.apps.ferrobase.models.fields module

class ferrosoft.apps.ferrobase.models.fields.BigDecimalField(*args, **kwargs)[source]

Bases: CustomDecimalField

DecimalField with max_digits and decimal_places useful for big values.

class ferrosoft.apps.ferrobase.models.fields.BigMoneyField(*args, **kwargs)[source]

Bases: CustomDecimalField

DecimalField with max_digits and decimal_places useful for big money values.

ROUND = Decimal('1.000')
class ferrosoft.apps.ferrobase.models.fields.CoordinateDecimalField(*args, **kwargs)[source]

Bases: CustomDecimalField

DecimalField with max_digits and decimal_places useful for geographic coordinate.

ROUND = Decimal('1.000000')
class ferrosoft.apps.ferrobase.models.fields.CustomDecimalField(verbose_name=None, name=None, max_digits=None, decimal_places=None, **kwargs)[source]

Bases: DecimalField

Base decimal field that omits max_digits / decimal_places from migrations.

Subclasses hard-code these parameters so migrations stay clean. The ROUND class attribute controls the quantization precision used by the round class method.

ROUND = Decimal('1.00')
deconstruct()[source]

Return enough information to recreate the field as a 4-tuple:

  • The name of the field on the model, if contribute_to_class() has been run.

  • The import path of the field, including the class, e.g. django.db.models.IntegerField. This should be the most portable version, so less specific may be better.

  • A list of positional arguments.

  • A dict of keyword arguments.

Note that the positional or keyword arguments must contain values of the following types (including inner values of collection types):

  • None, bool, str, int, float, complex, set, frozenset, list, tuple, dict

  • UUID

  • datetime.datetime (naive), datetime.date

  • top-level classes, top-level functions - will be referenced by their full import path

  • Storage instances - these have their own deconstruct() method

This is because the values here must be serialized into a text format (possibly new Python code, possibly JSON) and these are the only types with encoding handlers defined.

There’s no need to return the exact way the field was instantiated this time, just ensure that the resulting field is the same - prefer keyword arguments over positional ones, and omit parameters with their default values.

classmethod round(value)[source]
Return type:

Decimal

class ferrosoft.apps.ferrobase.models.fields.NormalDecimalField(*args, **kwargs)[source]

Bases: CustomDecimalField

DecimalField with max_digits and decimal_places useful for most cases.

class ferrosoft.apps.ferrobase.models.fields.TonDecimalField(*args, **kwargs)[source]

Bases: CustomDecimalField

DecimalField with max_digits and decimal_places useful for tonnages not requiring any decimal places.

ROUND = Decimal('1')

ferrosoft.apps.ferrobase.models.file module

class ferrosoft.apps.ferrobase.models.file.AccessMode(*values)[source]

Bases: IntegerChoices

Access mode (read or write) for a FileAccessGrant.

READ = 1
WRITE = 2
class ferrosoft.apps.ferrobase.models.file.AccessSubject(*values)[source]

Bases: IntegerChoices

Subject who can access a file.

ORGANIZATION = 2

Organization of the owner of the file.

OWNER = 1

Owner is the creator of the file.

PUBLIC = 3

Any logged-in user.

class ferrosoft.apps.ferrobase.models.file.Directory(*args, **kwargs)[source]

Bases: UUIDModel

Hierarchical folder structure for organising StoredFile objects.

Directories can be nested via parent_directory; a null parent indicates a root directory. Names must be unique within the same parent.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

directory_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

classmethod find_by_name(name)[source]
get_absolute_url()[source]
classmethod get_or_create(name)[source]
Return type:

Directory

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
parent_directory

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

parent_directory_id
storedfile_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class ferrosoft.apps.ferrobase.models.file.FileAccessGrant(*args, **kwargs)[source]

Bases: UUIDModel

Records a single access permission for a StoredFile.

Each grant links a file to a subject (owner, organisation, or public) and a mode (read or write). The combination of file, subject, and mode is unique, preventing duplicate grants.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

file

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

file_id
get_mode_display(*, field=<django.db.models.fields.IntegerField: mode>)
get_subject_display(*, field=<django.db.models.fields.IntegerField: subject>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

mode

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
subject

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ferrosoft.apps.ferrobase.models.file.FileInfo(file_name, media_type)[source]

Bases: object

Lightweight value object carrying the display name and media type of a file.

file_name is the original name given by the user; media_type is the MIME type string (e.g. "application/pdf").

file_name: str
media_type: str
class ferrosoft.apps.ferrobase.models.file.StoredFile(*args, **kwargs)[source]

Bases: UUIDModel

StoredFile wraps a Django file and enriches it with some metadata.

  • Name the file name given by the user.

  • Content is the file content.

  • Media type is the media/MIME type guessed by file name extension.

  • Directory is where the file is placed into (it has nothing to do with the location in STORAGES backend).

  • Creation time is when the file was created.

  • Owner is the user who can manage the file.

Beyond the owner attribute, no access control has been defined.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

access_grants

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

content

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
creation_time

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

delete(*args, **kwargs)[source]
directory

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

directory_id
expire_on

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_absolute_url()[source]
classmethod get_authenticated_file(path, user)[source]
Return type:

FileInfo | None

get_next_by_creation_time(*, field=<django.db.models.fields.DateTimeField: creation_time>, is_next=True, **kwargs)
get_previous_by_creation_time(*, field=<django.db.models.fields.DateTimeField: creation_time>, is_next=False, **kwargs)
classmethod guess_media_type(file_name)[source]
Return type:

str

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

media_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <ferrosoft.apps.ferrobase.models.file.StoredFileManager object>
owner

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

owner_id
transport_chains

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class ferrosoft.apps.ferrobase.models.file.StoredFileManager(*args, **kwargs)[source]

Bases: Manager

Manager for StoredFile that pre-fetches owner and directory relations.

Also provides create_with_access_grants for atomically creating a file together with its access control entries.

create_with_access_grants(grants, **kwargs)[source]
Return type:

StoredFile

get_queryset()[source]

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

ferrosoft.apps.ferrobase.models.identity module

class ferrosoft.apps.ferrobase.models.identity.APIToken(*args, **kwargs)[source]

Bases: UUIDModel

REST interface is authenticated with JWT’s. Token claims include a reference to this model, which informs about the user and which tenant to use for the request.

API middleware also inspects status and expiration and grants access only if the status is ACTIVE and the current time does not exceed expiration time.

In order to not rely too much on JWT, these fields are not encoded directly in the JWT, allowing for other authentication methods to be added.

Token name is purely informational for display in the UI.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

class Settings(jwt_secret_key, expiration_days=30, jwt_algorithm='HS256')[source]

Bases: object

expiration_days: int = 30
classmethod from_django_settings()[source]
jwt_algorithm: str = 'HS256'
jwt_secret_key: str
TOKEN_ID_CLAIM = 'token_id'
async classmethod acreate(user, tenant)[source]
async classmethod averify(token)[source]
Return type:

APIToken | None

classmethod create(user, tenant, name='')[source]
expiration

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_expiration(*, field=<django.db.models.fields.DateTimeField: expiration>, is_next=True, **kwargs)
get_previous_by_expiration(*, field=<django.db.models.fields.DateTimeField: expiration>, is_next=False, **kwargs)
get_status_display(*, field=<django.db.models.fields.IntegerField: status>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_valid()[source]
Return type:

bool

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <ferrosoft.apps.ferrobase.models.identity.APITokenPrefetchedManager object>
status

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

tenant

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

tenant_id
user

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

user_id
class ferrosoft.apps.ferrobase.models.identity.APITokenPrefetchedManager(*args, **kwargs)[source]

Bases: Manager

Manager for APIToken that deeply pre-fetches user, organisation, and tenant.

get_queryset()[source]

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

class ferrosoft.apps.ferrobase.models.identity.APITokenStatus(*values)[source]

Bases: IntegerChoices

Lifecycle state of an APIToken.

ACTIVE = 1
BLOCKED = 3
INACTIVE = 2
class ferrosoft.apps.ferrobase.models.identity.AccountActivationRequest(*args, **kwargs)[source]

Bases: AccessKeyMixin, UUIDModel

Time-limited token that activates a freshly provisioned tenant account.

Created when a new tenant is set up and sent to the contact email. The recipient follows the link containing access_key to confirm the account. Expired after AccessKeyMixin._DEFAULT_VALIDITY.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

access_key

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

access_key_expiry

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod create(tenant, expiry=None)[source]
get_absolute_url()[source]
get_next_by_access_key_expiry(*, field=<django.db.models.fields.DateTimeField: access_key_expiry>, is_next=True, **kwargs)
get_previous_by_access_key_expiry(*, field=<django.db.models.fields.DateTimeField: access_key_expiry>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
tenant

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

tenant_id
class ferrosoft.apps.ferrobase.models.identity.Organization(*args, **kwargs)[source]

Bases: UUIDModel

Top-level entity representing a customer organisation.

An organisation owns one SubscriptionPlan and contains one or more Tenant databases and User accounts. On save, the subscription tonnage limit Prometheus metric is updated so dashboards stay in sync.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

contact_email

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

contact_first_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

contact_last_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_absolute_url()[source]
iam_reference

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <ferrosoft.apps.ferrobase.models.identity.OrganizationManager object>
save(*, force_insert=False, force_update=False, using=None, update_fields=None)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

subscription

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

subscription_id
tenants

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

users

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class ferrosoft.apps.ferrobase.models.identity.OrganizationManager(*args, **kwargs)[source]

Bases: Manager

Manager for Organization that eagerly loads subscription and tenant relations.

get_queryset()[source]

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

class ferrosoft.apps.ferrobase.models.identity.PasswordResetRequest(*args, **kwargs)[source]

Bases: AccessKeyMixin, UUIDModel

A password reset request is created upon the users request to reset a password.

It is deleted once the user changes the password.

This model is global to all tenants.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

access_key

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

access_key_expiry

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod create(user)[source]

Create new request with random access key. :type user: User :param user: For which user the request is created.

get_next_by_access_key_expiry(*, field=<django.db.models.fields.DateTimeField: access_key_expiry>, is_next=True, **kwargs)
get_previous_by_access_key_expiry(*, field=<django.db.models.fields.DateTimeField: access_key_expiry>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
user

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

user_id
class ferrosoft.apps.ferrobase.models.identity.Tenant(*args, **kwargs)[source]

Bases: UUIDModel

Tenant segregates entities from each other.

This model is global to all tenants.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

activate_connection(default=None)[source]

Fudge tenant database connection details into runtime configuration.

It is advisable to use activate_tenant_database instead of using this method directly.

active

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

async classmethod afind(tenant_id, active=True)[source]
classmethod all_ordered()[source]
database_hostname

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

database_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

database_password

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

database_port

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

database_username

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property django_connection
expiry_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod find(tenant_id, active=True)[source]

Find tenant with given ID. :type tenant_id: :param tenant_id: :type active: :param active: Find only tenants which are active or not active (active by default).

Return type:

Tenant

get_absolute_url()[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod lookup(tenant)[source]
Return type:

Tenant | None

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <ferrosoft.apps.ferrobase.models.identity.TenantManager object>
organization

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

organization_id
class ferrosoft.apps.ferrobase.models.identity.TenantManager(*args, **kwargs)[source]

Bases: Manager

Manager for Tenant that eagerly loads the related organisation.

get_queryset()[source]

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

class ferrosoft.apps.ferrobase.models.identity.User(*args, **kwargs)[source]

Bases: AbstractUser

Extends Django user model with fields required for Ferrosoft Platform.

This model is global to all tenants.

exception DoesNotExist

Bases: ObjectDoesNotExist

MINIMUM_PASSWORD_LENGTH = 15
exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception PasswordInsufficientSize[source]

Bases: Exception

exception PasswordsDoNotMatch[source]

Bases: Exception

REQUIRED_FIELDS = ['email', 'organization_id']
classmethod all_ordered()[source]
api_tokens

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

assign_roles(*roles)[source]
color_theme

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

date_joined

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

email

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

emaildevice_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

first_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

format_email()[source]
get_absolute_url()[source]
get_assigned_feature(feature_code)[source]
classmethod get_by_username(name)[source]
Return type:

User

get_color_theme_display(*, field=<django.db.models.fields.CharField: color_theme>)
get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)
get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)
groups

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_active

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_staff

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_superuser

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

language

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

language_id
last_login

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

local_user()[source]

Find LocalUser corresponding to this user.

If the LocalUser does not exist, it is created implicitly.

Returns: LocalUser

logentry_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <ferrosoft.apps.ferrobase.models.identity.UserManager object>
organization

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

organization_id
password

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

passwordresetrequest_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

phonedevice_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

set_password_validated(password, password_again)[source]
set_tenants(tenant_ids)[source]
staticdevice_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

tenant_allowed(tenant)[source]
tenant_options()[source]
timezone

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

timezone_id
totpdevice_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

user_permissions

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

username

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ferrosoft.apps.ferrobase.models.identity.UserManager(*args, **kwargs)[source]

Bases: UserManager

Manager for User that eagerly loads organisation, language, and timezone.

get_queryset()[source]

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

ferrosoft.apps.ferrobase.models.registry module

class ferrosoft.apps.ferrobase.models.registry.AppFeatureBackend[source]

Bases: BaseBackend

model

alias of AppFeature

objects = dict_values([<AppFeature: Users>, <AppFeature: API Access>, <AppFeature: ERP integration>, <AppFeature: Multi-tenancy>, <AppFeature: Reporting>, <AppFeature: Report CI>, <AppFeature: Report over whole year>])
save_to_master_db_only = True
class ferrosoft.apps.ferrobase.models.registry.BaseBackend[source]

Bases: ABC

get_manager(db_name, model=None)[source]
model = None
objects = []
save_to_database(db_name=None)[source]
save_to_master_db_only = False
class ferrosoft.apps.ferrobase.models.registry.CountryBackend[source]

Bases: BaseBackend

model

alias of Country

objects = [<Country: AF - Afghanistan>, <Country: AL - Albania>, <Country: DZ - Algeria>, <Country: AS - American Samoa>, <Country: AD - Andorra>, <Country: AO - Angola>, <Country: AI - Anguilla>, <Country: AQ - Antarctica>, <Country: AG - Antigua and Barbuda>, <Country: AR - Argentina>, <Country: AM - Armenia>, <Country: AW - Aruba>, <Country: AU - Australia>, <Country: AT - Austria>, <Country: AZ - Azerbaijan>, <Country: BS - Bahamas (the)>, <Country: BH - Bahrain>, <Country: BD - Bangladesh>, <Country: BB - Barbados>, <Country: BY - Belarus>, <Country: BE - Belgium>, <Country: BZ - Belize>, <Country: BJ - Benin>, <Country: BM - Bermuda>, <Country: BT - Bhutan>, <Country: BO - Bolivia (Plurinational State of)>, <Country: BQ - Bonaire, Sint Eustatius and Saba>, <Country: BA - Bosnia and Herzegovina>, <Country: BW - Botswana>, <Country: BV - Bouvet Island>, <Country: BR - Brazil>, <Country: IO - British Indian Ocean Territory (the)>, <Country: BN - Brunei Darussalam>, <Country: BG - Bulgaria>, <Country: BF - Burkina Faso>, <Country: BI - Burundi>, <Country: CV - Cabo Verde>, <Country: KH - Cambodia>, <Country: CM - Cameroon>, <Country: CA - Canada>, <Country: KY - Cayman Islands (the)>, <Country: CF - Central African Republic (the)>, <Country: TD - Chad>, <Country: CL - Chile>, <Country: CN - China>, <Country: CX - Christmas Island>, <Country: CC - Cocos (Keeling) Islands (the)>, <Country: CO - Colombia>, <Country: KM - Comoros (the)>, <Country: CD - Congo (the Democratic Republic of the)>, <Country: CG - Congo (the)>, <Country: CK - Cook Islands (the)>, <Country: CR - Costa Rica>, <Country: HR - Croatia>, <Country: CU - Cuba>, <Country: CW - Curaçao>, <Country: CY - Cyprus>, <Country: CZ - Czechia>, <Country: CI - Côte d'Ivoire>, <Country: DK - Denmark>, <Country: DJ - Djibouti>, <Country: DM - Dominica>, <Country: DO - Dominican Republic (the)>, <Country: EC - Ecuador>, <Country: EG - Egypt>, <Country: SV - El Salvador>, <Country: GQ - Equatorial Guinea>, <Country: ER - Eritrea>, <Country: EE - Estonia>, <Country: SZ - Eswatini>, <Country: ET - Ethiopia>, <Country: FK - Falkland Islands (the) [Malvinas]>, <Country: FO - Faroe Islands (the)>, <Country: FJ - Fiji>, <Country: FI - Finland>, <Country: FR - France>, <Country: GF - French Guiana>, <Country: PF - French Polynesia>, <Country: TF - French Southern Territories (the)>, <Country: GA - Gabon>, <Country: GM - Gambia (the)>, <Country: GE - Georgia>, <Country: DE - Germany>, <Country: GH - Ghana>, <Country: GI - Gibraltar>, <Country: GR - Greece>, <Country: GL - Greenland>, <Country: GD - Grenada>, <Country: GP - Guadeloupe>, <Country: GU - Guam>, <Country: GT - Guatemala>, <Country: GG - Guernsey>, <Country: GN - Guinea>, <Country: GW - Guinea-Bissau>, <Country: GY - Guyana>, <Country: HT - Haiti>, <Country: HM - Heard Island and McDonald Islands>, <Country: VA - Holy See (the)>, <Country: HN - Honduras>, <Country: HK - Hong Kong>, <Country: HU - Hungary>, <Country: IS - Iceland>, <Country: IN - India>, <Country: ID - Indonesia>, <Country: IR - Iran (Islamic Republic of)>, <Country: IQ - Iraq>, <Country: IE - Ireland>, <Country: IM - Isle of Man>, <Country: IL - Israel>, <Country: IT - Italy>, <Country: JM - Jamaica>, <Country: JP - Japan>, <Country: JE - Jersey>, <Country: JO - Jordan>, <Country: KZ - Kazakhstan>, <Country: KE - Kenya>, <Country: KI - Kiribati>, <Country: KP - Korea (the Democratic People's Republic of)>, <Country: KR - Korea (the Republic of)>, <Country: KW - Kuwait>, <Country: KG - Kyrgyzstan>, <Country: LA - Lao People's Democratic Republic (the)>, <Country: LV - Latvia>, <Country: LB - Lebanon>, <Country: LS - Lesotho>, <Country: LR - Liberia>, <Country: LY - Libya>, <Country: LI - Liechtenstein>, <Country: LT - Lithuania>, <Country: LU - Luxembourg>, <Country: MO - Macao>, <Country: MG - Madagascar>, <Country: MW - Malawi>, <Country: MY - Malaysia>, <Country: MV - Maldives>, <Country: ML - Mali>, <Country: MT - Malta>, <Country: MH - Marshall Islands (the)>, <Country: MQ - Martinique>, <Country: MR - Mauritania>, <Country: MU - Mauritius>, <Country: YT - Mayotte>, <Country: MX - Mexico>, <Country: FM - Micronesia (Federated States of)>, <Country: MD - Moldova (the Republic of)>, <Country: MC - Monaco>, <Country: MN - Mongolia>, <Country: ME - Montenegro>, <Country: MS - Montserrat>, <Country: MA - Morocco>, <Country: MZ - Mozambique>, <Country: MM - Myanmar>, <Country: NA - Namibia>, <Country: NR - Nauru>, <Country: NP - Nepal>, <Country: NL - Netherlands (the)>, <Country: NC - New Caledonia>, <Country: NZ - New Zealand>, <Country: NI - Nicaragua>, <Country: NE - Niger (the)>, <Country: NG - Nigeria>, <Country: NU - Niue>, <Country: NF - Norfolk Island>, <Country: MP - Northern Mariana Islands (the)>, <Country: NO - Norway>, <Country: OM - Oman>, <Country: PK - Pakistan>, <Country: PW - Palau>, <Country: PA - Panama>, <Country: PG - Papua New Guinea>, <Country: PY - Paraguay>, <Country: PE - Peru>, <Country: PH - Philippines (the)>, <Country: PN - Pitcairn>, <Country: PL - Poland>, <Country: PT - Portugal>, <Country: PR - Puerto Rico>, <Country: QA - Qatar>, <Country: MK - Republic of North Macedonia>, <Country: RO - Romania>, <Country: RU - Russian Federation (the)>, <Country: RW - Rwanda>, <Country: RE - Réunion>, <Country: BL - Saint Barthélemy>, <Country: SH - Saint Helena, Ascension and Tristan da Cunha>, <Country: KN - Saint Kitts and Nevis>, <Country: LC - Saint Lucia>, <Country: MF - Saint Martin (French part)>, <Country: PM - Saint Pierre and Miquelon>, <Country: VC - Saint Vincent and the Grenadines>, <Country: WS - Samoa>, <Country: SM - San Marino>, <Country: ST - Sao Tome and Principe>, <Country: SA - Saudi Arabia>, <Country: SN - Senegal>, <Country: RS - Serbia>, <Country: SC - Seychelles>, <Country: SL - Sierra Leone>, <Country: SG - Singapore>, <Country: SX - Sint Maarten (Dutch part)>, <Country: SK - Slovakia>, <Country: SI - Slovenia>, <Country: SB - Solomon Islands>, <Country: SO - Somalia>, <Country: ZA - South Africa>, <Country: GS - South Georgia and the South Sandwich Islands>, <Country: SS - South Sudan>, <Country: ES - Spain>, <Country: LK - Sri Lanka>, <Country: SD - Sudan (the)>, <Country: SR - Suriname>, <Country: SJ - Svalbard and Jan Mayen>, <Country: SE - Sweden>, <Country: CH - Switzerland>, <Country: SY - Syrian Arab Republic>, <Country: TW - Taiwan (Province of China)>, <Country: TJ - Tajikistan>, <Country: TZ - Tanzania, United Republic of>, <Country: TH - Thailand>, <Country: TL - Timor-Leste>, <Country: TG - Togo>, <Country: TK - Tokelau>, <Country: TO - Tonga>, <Country: TT - Trinidad and Tobago>, <Country: TN - Tunisia>, <Country: TR - Turkey>, <Country: TM - Turkmenistan>, <Country: TC - Turks and Caicos Islands (the)>, <Country: TV - Tuvalu>, <Country: UG - Uganda>, <Country: UA - Ukraine>, <Country: AE - United Arab Emirates (the)>, <Country: GB - United Kingdom of Great Britain and Northern Ireland (the)>, <Country: UM - United States Minor Outlying Islands (the)>, <Country: US - United States of America (the)>, <Country: UY - Uruguay>, <Country: UZ - Uzbekistan>, <Country: VU - Vanuatu>, <Country: VE - Venezuela (Bolivarian Republic of)>, <Country: VN - Viet Nam>, <Country: VG - Virgin Islands (British)>, <Country: VI - Virgin Islands (U.S.)>, <Country: WF - Wallis and Futuna>, <Country: EH - Western Sahara>, <Country: YE - Yemen>, <Country: ZM - Zambia>, <Country: ZW - Zimbabwe>, <Country: AX - Åland Islands>]
class ferrosoft.apps.ferrobase.models.registry.LanguageBackend[source]

Bases: BaseBackend

model

alias of Language

objects = [<Language: ab - аҧсуа бызшәа, аҧсшәа>, <Language: aa - Afaraf>, <Language: af - Afrikaans>, <Language: ak - Akan>, <Language: sq - Shqip>, <Language: am - አማርኛ>, <Language: ar - العربية>, <Language: an - aragonés>, <Language: hy - Հայերեն>, <Language: as - অসমীয়া>, <Language: av - авар мацӀ, магӀарул мацӀ>, <Language: ae - avesta>, <Language: ay - aymar aru>, <Language: az - azərbaycan dili>, <Language: bm - bamanankan>, <Language: ba - башҡорт теле>, <Language: eu - euskara, euskera>, <Language: be - беларуская мова>, <Language: bn - বাং>, <Language: bh - भोजपुरी>, <Language: bi - Bislama>, <Language: bs - bosanski jezik>, <Language: br - brezhoneg>, <Language: bg - български език>, <Language: my - ဗမာစာ>, <Language: ca - català, valencià>, <Language: ch - Chamoru>, <Language: ce - нохчийн мотт>, <Language: ny - chiCheŵa, chinyanja>, <Language: zh - 中文 (Zhōngwén), 汉语 / 漢語 (Hànyǔ)>, <Language: cv - чӑваш чӗлхи>, <Language: kw - Kernewek>, <Language: co - corsu, lingua corsa>, <Language: cr - ᓀᐦᐃᔭᐍᐏᐣ>, <Language: hr - hrvatski jezik>, <Language: cs - čeština, český jazyk>, <Language: da - dansk>, <Language: dv - ދިވެހި>, <Language: nl - Nederlands, Vlaams>, <Language: dz - རྫོང་ཁ>, <Language: en - English>, <Language: eo - Esperanto>, <Language: et - eesti, eesti keel>, <Language: ee - Eʋegbe>, <Language: fo - føroyskt>, <Language: fj - vosa Vakaviti>, <Language: fi - suomi, suomen kieli>, <Language: fr - français, langue française>, <Language: ff - Fulfulde, Pulaar, Pular>, <Language: gl - Galego>, <Language: ka - ქართული>, <Language: de - Deutsch>, <Language: el - ελληνικά>, <Language: gn - Avañe'ẽ>, <Language: gu - ગુજરાતી>, <Language: ht - Kreyòl ayisyen>, <Language: ha - هَوُسَ>, <Language: he - עברית>, <Language: hz - Otjiherero>, <Language: hi - हिन्दी, हिंदी>, <Language: ho - Hiri Motu>, <Language: hu - magyar>, <Language: ia - Interlingua>, <Language: id - Bahasa Indonesia>, <Language: ie - (ursprünglich:) Occidental, (nach 1945:) Interlingue>, <Language: ga - Gaeilge>, <Language: ig - Asụsụ Igbo>, <Language: ik - Iñupiaq, Iñupiatun>, <Language: io - Ido>, <Language: is - Íslenska>, <Language: it - Italiano>, <Language: iu - ᐃᓄᒃᑎᑐᑦ>, <Language: ja - 日本語, (にほんご Nihongo)>, <Language: jv - ꦧꦱꦗꦮ, Basa Jawa>, <Language: kl - kalaallisut, kalaallit oqaasii>, <Language: kn - ಕನ್ನಡ>, <Language: kr - Kanuri>, <Language: ks - कश्मीरी, كشميري>, <Language: kk - қазақ тілі>, <Language: km - ខ្មែរ, ខេមរភាសា, ភាសាខ្មែរ>, <Language: ki - Gĩkũyũ>, <Language: rw - Ikinyarwanda>, <Language: ky - Кыргызча, Кыргыз тили>, <Language: kv - коми кыв>, <Language: kg - Kikongo>, <Language: ko - 한국어 (韓國語, Hangugeo)>, <Language: ku - Kurdî, کوردی>, <Language: kj - Kuanyama>, <Language: la - latine, lingua latina>, <Language: lb - Lëtzebuergesch>, <Language: lg - Luganda>, <Language: li - Limburgs>, <Language: ln - Lingála>, <Language: lo - ພາສາລາວ>, <Language: lt - lietuvių kalba>, <Language: lu - Kiluba>, <Language: lv - latviešu valoda>, <Language: gv - Gaelg, Gailck>, <Language: mk - македонски јазик>, <Language: mg - fiteny malagasy>, <Language: ms - Bahasa Melayu, بهاس ملايو>, <Language: ml - മലയാളം>, <Language: mt - Malti>, <Language: mi - te reo Māori>, <Language: mr - मराठी>, <Language: mh - Kajin Ṃajeḷ>, <Language: mn - Монгол хэл>, <Language: na - Dorerin Naoero>, <Language: nv - Diné bizaad>, <Language: nd - isiNdebele>, <Language: ne - नेपाली>, <Language: ng - Owambo>, <Language: nb - Norsk Bokmål>, <Language: nn - Norsk Nynorsk>, <Language: no - Norsk>, <Language: ii - ꆈꌠ꒿, Nuosuhxop>, <Language: nr - isiNdebele>, <Language: oc - occitan, lenga d'òc>, <Language: oj - ᐊᓂᔑᓈᐯᒧᐎᓐ>, <Language: cu - ѩзыкъ словѣньскъ>, <Language: om - Afaan Oromoo>, <Language: or - ଓଡ଼ିଆ>, <Language: os - ирон æвзаг>, <Language: pa - ਪੰਜਾਬੀ>, <Language: pi - पालि, पाळि>, <Language: fa - فارسی>, <Language: pl - język polski, polszczyzna>, <Language: ps - پښتو>, <Language: pt - Português>, <Language: qu - Runa Simi, Kichwa>, <Language: rm - Rumantsch, Romontsch, Rumauntsch>, <Language: rn - Ikirundi>, <Language: ro - Română>, <Language: ru - русский>, <Language: sa - संस्कृतम्>, <Language: sc - sardu>, <Language: sd - सिन्धी, سنڌي، سندھی>, <Language: se - Davvisámegiella>, <Language: (sh) - српскохрватски, srpskohrvatski>, <Language: sm - gagana fa'a Samoa>, <Language: sg - yângâ sängö>, <Language: sr - српски језик, srpski jezik>, <Language: gd - Gàidhlig>, <Language: sn - chiShona>, <Language: si - සිංල>, <Language: sk - slovenčina, slovenský jazyk>, <Language: sl - slovenski jezik, slovenščina>, <Language: so - Soomaaliga, af Soomaali>, <Language: st - Sesotho>, <Language: es - Español>, <Language: su - Basa Sunda>, <Language: sw - Kiswahili>, <Language: ss - SiSwati>, <Language: sv - Svenska>, <Language: ta - தமிழ்>, <Language: te - తెలుగు>, <Language: tg - тоҷикӣ, toçikī, تاجیکی>, <Language: th - ไทย>, <Language: ti - ትግርኛ>, <Language: bo - བོད་ཡིག>, <Language: tk - Türkmen, Түркмен>, <Language: tl - Wikang Tagalog>, <Language: tn - Setswana>, <Language: to - Faka Tonga>, <Language: tr - Türkçe>, <Language: ts - Xitsonga>, <Language: tt - татар теле, tatar tele>, <Language: tw - Twi>, <Language: ty - Reo Tahiti>, <Language: ug - Uyghurche, ئۇيغۇرچە>, <Language: uk - Українська>, <Language: ur - اردو>, <Language: uz - Oʻzbek, Ўзбек, أۇزبېك>, <Language: ve - Tshivenḓa>, <Language: vi - Tiếng Việt>, <Language: vo - Volapük>, <Language: wa - Walon>, <Language: cy - Cymraeg>, <Language: wo - Wollof>, <Language: fy - Frysk>, <Language: xh - isiXhosa>, <Language: yi - ייִדיש>, <Language: yo - Yorùbá>, <Language: za - Saɯ cueŋƅ, Saw cuengh>, <Language: zu - isiZulu>]
save_to_master_db_only = True
class ferrosoft.apps.ferrobase.models.registry.SubscriptionPlanRegistry[source]

Bases: BaseBackend

get(pk)[source]
Return type:

SubscriptionPlan | None

model

alias of SubscriptionPlan

objects = [BuiltinSubscriptionPlan(plan=<SubscriptionPlan: Demo>, features=[<FeatureAssignment: Users (limit: 1)>]), BuiltinSubscriptionPlan(plan=<SubscriptionPlan: Basic>, features=[<FeatureAssignment: Users (limit: 2)>, <FeatureAssignment: Reporting>]), BuiltinSubscriptionPlan(plan=<SubscriptionPlan: Business>, features=[<FeatureAssignment: Users>, <FeatureAssignment: API Access>, <FeatureAssignment: Reporting>, <FeatureAssignment: Report over whole year>]), BuiltinSubscriptionPlan(plan=<SubscriptionPlan: Enterprise>, features=[<FeatureAssignment: Users>, <FeatureAssignment: API Access>, <FeatureAssignment: Reporting>, <FeatureAssignment: Report over whole year>]), BuiltinSubscriptionPlan(plan=<SubscriptionPlan: Unlimited>, features=[])]
save_to_database(db_name=None)[source]
save_to_master_db_only = True
class ferrosoft.apps.ferrobase.models.registry.TimeZoneBackend[source]

Bases: BaseBackend

model

alias of TimeZone

objects = [<TimeZone: Africa/Abidjan>, <TimeZone: Africa/Algiers>, <TimeZone: Africa/Bissau>, <TimeZone: Africa/Cairo>, <TimeZone: Africa/Casablanca>, <TimeZone: Africa/Ceuta>, <TimeZone: Africa/El_Aaiun>, <TimeZone: Africa/Johannesburg>, <TimeZone: Africa/Juba>, <TimeZone: Africa/Khartoum>, <TimeZone: Africa/Lagos>, <TimeZone: Africa/Maputo>, <TimeZone: Africa/Monrovia>, <TimeZone: Africa/Nairobi>, <TimeZone: Africa/Ndjamena>, <TimeZone: Africa/Sao_Tome>, <TimeZone: Africa/Tripoli>, <TimeZone: Africa/Tunis>, <TimeZone: Africa/Windhoek>, <TimeZone: America/Adak>, <TimeZone: America/Anchorage>, <TimeZone: America/Araguaina>, <TimeZone: America/Argentina/Buenos_Aires>, <TimeZone: America/Argentina/Catamarca>, <TimeZone: America/Argentina/Cordoba>, <TimeZone: America/Argentina/Jujuy>, <TimeZone: America/Argentina/La_Rioja>, <TimeZone: America/Argentina/Mendoza>, <TimeZone: America/Argentina/Rio_Gallegos>, <TimeZone: America/Argentina/Salta>, <TimeZone: America/Argentina/San_Juan>, <TimeZone: America/Argentina/San_Luis>, <TimeZone: America/Argentina/Tucuman>, <TimeZone: America/Argentina/Ushuaia>, <TimeZone: America/Asuncion>, <TimeZone: America/Bahia>, <TimeZone: America/Bahia_Banderas>, <TimeZone: America/Barbados>, <TimeZone: America/Belem>, <TimeZone: America/Belize>, <TimeZone: America/Boa_Vista>, <TimeZone: America/Bogota>, <TimeZone: America/Boise>, <TimeZone: America/Cambridge_Bay>, <TimeZone: America/Campo_Grande>, <TimeZone: America/Cancun>, <TimeZone: America/Caracas>, <TimeZone: America/Cayenne>, <TimeZone: America/Chicago>, <TimeZone: America/Chihuahua>, <TimeZone: America/Ciudad_Juarez>, <TimeZone: America/Costa_Rica>, <TimeZone: America/Cuiaba>, <TimeZone: America/Danmarkshavn>, <TimeZone: America/Dawson>, <TimeZone: America/Dawson_Creek>, <TimeZone: America/Denver>, <TimeZone: America/Detroit>, <TimeZone: America/Edmonton>, <TimeZone: America/Eirunepe>, <TimeZone: America/El_Salvador>, <TimeZone: America/Fort_Nelson>, <TimeZone: America/Fortaleza>, <TimeZone: America/Glace_Bay>, <TimeZone: America/Goose_Bay>, <TimeZone: America/Grand_Turk>, <TimeZone: America/Guatemala>, <TimeZone: America/Guayaquil>, <TimeZone: America/Guyana>, <TimeZone: America/Halifax>, <TimeZone: America/Havana>, <TimeZone: America/Hermosillo>, <TimeZone: America/Indiana/Indianapolis>, <TimeZone: America/Indiana/Knox>, <TimeZone: America/Indiana/Marengo>, <TimeZone: America/Indiana/Petersburg>, <TimeZone: America/Indiana/Tell_City>, <TimeZone: America/Indiana/Vevay>, <TimeZone: America/Indiana/Vincennes>, <TimeZone: America/Indiana/Winamac>, <TimeZone: America/Inuvik>, <TimeZone: America/Iqaluit>, <TimeZone: America/Jamaica>, <TimeZone: America/Juneau>, <TimeZone: America/Kentucky/Louisville>, <TimeZone: America/Kentucky/Monticello>, <TimeZone: America/La_Paz>, <TimeZone: America/Lima>, <TimeZone: America/Los_Angeles>, <TimeZone: America/Maceio>, <TimeZone: America/Managua>, <TimeZone: America/Manaus>, <TimeZone: America/Martinique>, <TimeZone: America/Matamoros>, <TimeZone: America/Mazatlan>, <TimeZone: America/Menominee>, <TimeZone: America/Merida>, <TimeZone: America/Metlakatla>, <TimeZone: America/Mexico_City>, <TimeZone: America/Miquelon>, <TimeZone: America/Moncton>, <TimeZone: America/Monterrey>, <TimeZone: America/Montevideo>, <TimeZone: America/New_York>, <TimeZone: America/Nome>, <TimeZone: America/Noronha>, <TimeZone: America/North_Dakota/Beulah>, <TimeZone: America/North_Dakota/Center>, <TimeZone: America/North_Dakota/New_Salem>, <TimeZone: America/Nuuk>, <TimeZone: America/Ojinaga>, <TimeZone: America/Panama>, <TimeZone: America/Paramaribo>, <TimeZone: America/Phoenix>, <TimeZone: America/Port-au-Prince>, <TimeZone: America/Porto_Velho>, <TimeZone: America/Puerto_Rico>, <TimeZone: America/Punta_Arenas>, <TimeZone: America/Rankin_Inlet>, <TimeZone: America/Recife>, <TimeZone: America/Regina>, <TimeZone: America/Resolute>, <TimeZone: America/Rio_Branco>, <TimeZone: America/Santarem>, <TimeZone: America/Santiago>, <TimeZone: America/Santo_Domingo>, <TimeZone: America/Sao_Paulo>, <TimeZone: America/Scoresbysund>, <TimeZone: America/Sitka>, <TimeZone: America/St_Johns>, <TimeZone: America/Swift_Current>, <TimeZone: America/Tegucigalpa>, <TimeZone: America/Thule>, <TimeZone: America/Tijuana>, <TimeZone: America/Toronto>, <TimeZone: America/Vancouver>, <TimeZone: America/Whitehorse>, <TimeZone: America/Winnipeg>, <TimeZone: America/Yakutat>, <TimeZone: Antarctica/Casey>, <TimeZone: Antarctica/Davis>, <TimeZone: Antarctica/Macquarie>, <TimeZone: Antarctica/Mawson>, <TimeZone: Antarctica/Palmer>, <TimeZone: Antarctica/Rothera>, <TimeZone: Antarctica/Troll>, <TimeZone: Asia/Almaty>, <TimeZone: Asia/Amman>, <TimeZone: Asia/Anadyr>, <TimeZone: Asia/Aqtau>, <TimeZone: Asia/Aqtobe>, <TimeZone: Asia/Ashgabat>, <TimeZone: Asia/Atyrau>, <TimeZone: Asia/Baghdad>, <TimeZone: Asia/Baku>, <TimeZone: Asia/Bangkok>, <TimeZone: Asia/Barnaul>, <TimeZone: Asia/Beirut>, <TimeZone: Asia/Bishkek>, <TimeZone: Asia/Chita>, <TimeZone: Asia/Choibalsan>, <TimeZone: Asia/Colombo>, <TimeZone: Asia/Damascus>, <TimeZone: Asia/Dhaka>, <TimeZone: Asia/Dili>, <TimeZone: Asia/Dubai>, <TimeZone: Asia/Dushanbe>, <TimeZone: Asia/Famagusta>, <TimeZone: Asia/Gaza>, <TimeZone: Asia/Hebron>, <TimeZone: Asia/Ho_Chi_Minh>, <TimeZone: Asia/Hong_Kong>, <TimeZone: Asia/Hovd>, <TimeZone: Asia/Irkutsk>, <TimeZone: Asia/Jakarta>, <TimeZone: Asia/Jayapura>, <TimeZone: Asia/Jerusalem>, <TimeZone: Asia/Kabul>, <TimeZone: Asia/Kamchatka>, <TimeZone: Asia/Karachi>, <TimeZone: Asia/Kathmandu>, <TimeZone: Asia/Khandyga>, <TimeZone: Asia/Kolkata>, <TimeZone: Asia/Krasnoyarsk>, <TimeZone: Asia/Kuching>, <TimeZone: Asia/Macau>, <TimeZone: Asia/Magadan>, <TimeZone: Asia/Makassar>, <TimeZone: Asia/Manila>, <TimeZone: Asia/Nicosia>, <TimeZone: Asia/Novokuznetsk>, <TimeZone: Asia/Novosibirsk>, <TimeZone: Asia/Omsk>, <TimeZone: Asia/Oral>, <TimeZone: Asia/Pontianak>, <TimeZone: Asia/Pyongyang>, <TimeZone: Asia/Qatar>, <TimeZone: Asia/Qostanay>, <TimeZone: Asia/Qyzylorda>, <TimeZone: Asia/Riyadh>, <TimeZone: Asia/Sakhalin>, <TimeZone: Asia/Samarkand>, <TimeZone: Asia/Seoul>, <TimeZone: Asia/Shanghai>, <TimeZone: Asia/Singapore>, <TimeZone: Asia/Srednekolymsk>, <TimeZone: Asia/Taipei>, <TimeZone: Asia/Tashkent>, <TimeZone: Asia/Tbilisi>, <TimeZone: Asia/Tehran>, <TimeZone: Asia/Thimphu>, <TimeZone: Asia/Tokyo>, <TimeZone: Asia/Tomsk>, <TimeZone: Asia/Ulaanbaatar>, <TimeZone: Asia/Urumqi>, <TimeZone: Asia/Ust-Nera>, <TimeZone: Asia/Vladivostok>, <TimeZone: Asia/Yakutsk>, <TimeZone: Asia/Yangon>, <TimeZone: Asia/Yekaterinburg>, <TimeZone: Asia/Yerevan>, <TimeZone: Atlantic/Azores>, <TimeZone: Atlantic/Bermuda>, <TimeZone: Atlantic/Canary>, <TimeZone: Atlantic/Cape_Verde>, <TimeZone: Atlantic/Faroe>, <TimeZone: Atlantic/Madeira>, <TimeZone: Atlantic/South_Georgia>, <TimeZone: Atlantic/Stanley>, <TimeZone: Australia/Adelaide>, <TimeZone: Australia/Brisbane>, <TimeZone: Australia/Broken_Hill>, <TimeZone: Australia/Darwin>, <TimeZone: Australia/Eucla>, <TimeZone: Australia/Hobart>, <TimeZone: Australia/Lindeman>, <TimeZone: Australia/Lord_Howe>, <TimeZone: Australia/Melbourne>, <TimeZone: Australia/Perth>, <TimeZone: Australia/Sydney>, <TimeZone: CET>, <TimeZone: CST6CDT>, <TimeZone: EET>, <TimeZone: EST>, <TimeZone: EST5EDT>, <TimeZone: Etc/GMT>, <TimeZone: Etc/GMT+1>, <TimeZone: Etc/GMT+10>, <TimeZone: Etc/GMT+11>, <TimeZone: Etc/GMT+12>, <TimeZone: Etc/GMT+2>, <TimeZone: Etc/GMT+3>, <TimeZone: Etc/GMT+4>, <TimeZone: Etc/GMT+5>, <TimeZone: Etc/GMT+6>, <TimeZone: Etc/GMT+7>, <TimeZone: Etc/GMT+8>, <TimeZone: Etc/GMT+9>, <TimeZone: Etc/GMT-1>, <TimeZone: Etc/GMT-10>, <TimeZone: Etc/GMT-11>, <TimeZone: Etc/GMT-12>, <TimeZone: Etc/GMT-13>, <TimeZone: Etc/GMT-14>, <TimeZone: Etc/GMT-2>, <TimeZone: Etc/GMT-3>, <TimeZone: Etc/GMT-4>, <TimeZone: Etc/GMT-5>, <TimeZone: Etc/GMT-6>, <TimeZone: Etc/GMT-7>, <TimeZone: Etc/GMT-8>, <TimeZone: Etc/GMT-9>, <TimeZone: Etc/UTC>, <TimeZone: Europe/Andorra>, <TimeZone: Europe/Astrakhan>, <TimeZone: Europe/Athens>, <TimeZone: Europe/Belgrade>, <TimeZone: Europe/Berlin>, <TimeZone: Europe/Brussels>, <TimeZone: Europe/Bucharest>, <TimeZone: Europe/Budapest>, <TimeZone: Europe/Chisinau>, <TimeZone: Europe/Dublin>, <TimeZone: Europe/Gibraltar>, <TimeZone: Europe/Helsinki>, <TimeZone: Europe/Istanbul>, <TimeZone: Europe/Kaliningrad>, <TimeZone: Europe/Kirov>, <TimeZone: Europe/Kyiv>, <TimeZone: Europe/Lisbon>, <TimeZone: Europe/London>, <TimeZone: Europe/Madrid>, <TimeZone: Europe/Malta>, <TimeZone: Europe/Minsk>, <TimeZone: Europe/Moscow>, <TimeZone: Europe/Paris>, <TimeZone: Europe/Prague>, <TimeZone: Europe/Riga>, <TimeZone: Europe/Rome>, <TimeZone: Europe/Samara>, <TimeZone: Europe/Saratov>, <TimeZone: Europe/Simferopol>, <TimeZone: Europe/Sofia>, <TimeZone: Europe/Tallinn>, <TimeZone: Europe/Tirane>, <TimeZone: Europe/Ulyanovsk>, <TimeZone: Europe/Vienna>, <TimeZone: Europe/Vilnius>, <TimeZone: Europe/Volgograd>, <TimeZone: Europe/Warsaw>, <TimeZone: Europe/Zurich>, <TimeZone: Factory>, <TimeZone: HST>, <TimeZone: Indian/Chagos>, <TimeZone: Indian/Maldives>, <TimeZone: Indian/Mauritius>, <TimeZone: MET>, <TimeZone: MST>, <TimeZone: MST7MDT>, <TimeZone: Pacific/Apia>, <TimeZone: Pacific/Auckland>, <TimeZone: Pacific/Bougainville>, <TimeZone: Pacific/Chatham>, <TimeZone: Pacific/Easter>, <TimeZone: Pacific/Efate>, <TimeZone: Pacific/Fakaofo>, <TimeZone: Pacific/Fiji>, <TimeZone: Pacific/Galapagos>, <TimeZone: Pacific/Gambier>, <TimeZone: Pacific/Guadalcanal>, <TimeZone: Pacific/Guam>, <TimeZone: Pacific/Honolulu>, <TimeZone: Pacific/Kanton>, <TimeZone: Pacific/Kiritimati>, <TimeZone: Pacific/Kosrae>, <TimeZone: Pacific/Kwajalein>, <TimeZone: Pacific/Marquesas>, <TimeZone: Pacific/Nauru>, <TimeZone: Pacific/Niue>, <TimeZone: Pacific/Norfolk>, <TimeZone: Pacific/Noumea>, <TimeZone: Pacific/Pago_Pago>, <TimeZone: Pacific/Palau>, <TimeZone: Pacific/Pitcairn>, <TimeZone: Pacific/Port_Moresby>, <TimeZone: Pacific/Rarotonga>, <TimeZone: Pacific/Tahiti>, <TimeZone: Pacific/Tarawa>, <TimeZone: Pacific/Tongatapu>, <TimeZone: PST8PDT>, <TimeZone: WET>]
save_to_master_db_only = True
class ferrosoft.apps.ferrobase.models.registry.UnifiedBackend[source]

Bases: BaseBackend

Model registries act as an in-memory storage for model instances.

This is used for models of fixed set size, which are defined once, such as measurement units.

AppFeature = <ferrosoft.apps.ferrobase.models.registry.AppFeatureBackend object>
Country = <ferrosoft.apps.ferrobase.models.registry.CountryBackend object>
Language = <ferrosoft.apps.ferrobase.models.registry.LanguageBackend object>
SubscriptionPlan = <ferrosoft.apps.ferrobase.models.registry.SubscriptionPlanRegistry object>
TimeZone = <ferrosoft.apps.ferrobase.models.registry.TimeZoneBackend object>
Unit = <ferrosoft.apps.ferrobase.models.registry.UnitRegistry object>
backends()[source]
Return type:

Generator[BaseBackend, None, None]

save_to_database(db_name=None)[source]
class ferrosoft.apps.ferrobase.models.registry.UnitRegistry[source]

Bases: BaseBackend

Unit registry provides all supported measurement units.

It is storing units in-memory to avoid hitting database for lookups by ID or unit cursor.

exists(needle)[source]
Return type:

bool

find(cursors)[source]
Return type:

Iterable[MeasurementUnit]

get(needle)[source]
Return type:

MeasurementUnit

model

alias of MeasurementUnit

save_to_database(db_name=None)[source]

ferrosoft.apps.ferrobase.models.shared module

Models shared between apps.

class ferrosoft.apps.ferrobase.models.shared.Account(*args, **kwargs)[source]

Bases: UUIDModel

Account names a physical location.

name

A descriptive name

Type:

str

internal

True, if the account represents a location owned by the user, else False

Type:

bool

address

Physical address

Type:

str

latitude

Physical coordinates (latitude)

Type:

Decimal

longitude

Physical coordinates (longitude)

Type:

Decimal

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

address

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod externals()[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

internal

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod internals()[source]
latitude

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

longitude

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
validate()[source]
class ferrosoft.apps.ferrobase.models.shared.BusinessPartner(id, salutation, first_name, last_name, company, additional_lines, street, house_no, city, postal_code, country, latitude, longitude, name)[source]

Bases: AddressMixin, CoordinatesMixin, UUIDModel

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

additional_lines

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

city

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

company

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

country

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

country_id
first_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

format_for_map()[source]
get_absolute_url()[source]
classmethod get_by_name(name)[source]
Return type:

BusinessPartner

classmethod get_ordered()[source]
house_no

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

latitude

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

longitude

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
postal_code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

salutation

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

salutation_id
save(*args, **kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

street

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ferrosoft.apps.ferrobase.models.shared.ColorTheme(*values)[source]

Bases: TextChoices

User-selectable color theme for the web interface.

AUTO = 'A'
DARK = 'D'
LIGHT = 'L'
class ferrosoft.apps.ferrobase.models.shared.ColorThemeDiscovery[source]

Bases: object

Resolves the effective color theme for a request.

Combines the authenticated user’s saved preference with the browser’s reported theme (stored in the fpagenttheme cookie by the front-end JavaScript) to avoid a flash of the wrong theme on page load.

classmethod agent_theme(request)[source]
Return type:

ColorTheme

classmethod guess(request)[source]

Return the best color theme for the given request.

For users with AUTO preference, falls back to the agent (browser) theme if one is available.

Parameters:

request – The current HTTP request.

Returns:

Resolved theme value.

Return type:

ColorTheme

static user_theme(request)[source]
class ferrosoft.apps.ferrobase.models.shared.CompanySite(*args, **kwargs)[source]

Bases: SelectOptionsMixin, AddressMixin, UUIDModel

Physical site of the tenant’s company (warehouse, production facility, etc.).

Access can be restricted to specific LocalUser instances via allowed_users. A user who is not in allowed_users cannot see or use this site in the UI.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

additional_lines

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

allowed_users

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

city

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

company

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

country

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

country_id
first_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_absolute_url()[source]
house_no

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_user_allowed(user)[source]
last_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
classmethod options_for_user(user, only_enabled=None)[source]
postal_code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

salutation

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

salutation_id
classmethod set_locations_for_user(location_ids, user)[source]

Replace locations set for user with new ones.

street

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ferrosoft.apps.ferrobase.models.shared.Country(*args, **kwargs)[source]

Bases: ISOCatalogEntry

Country defines a country.

Since this is a ISO catalog entry, iso_code should conform to ISO codes, although this is not enforced.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

businesspartner_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

companysite_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

english_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

iso_code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

localized_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

tcegeodestination_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

tcegeoorigin_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class ferrosoft.apps.ferrobase.models.shared.IDSequence(*values)[source]

Bases: IntegerChoices

Enumeration of entity types that have configurable human-readable ID sequences.

COMPANY_SITE = 9
CONSIGNMENT = 2
REPORT = 7
SHIPMENT = 3
SUPPORT_TICKET = 4
TRANSPORT_CHAIN = 1
TRANSPORT_OPERATION = 8
TREATMENT = 5
TREATMENT_OPERATION = 6
class ferrosoft.apps.ferrobase.models.shared.IdSequenceConfig(*args, **kwargs)[source]

Bases: UUIDModel

Configuration for auto-generating human-readable sequential IDs.

Each IDSequence entry can have its own prefix and zero-padding amount so that, for example, transport chains get IDs like TC-0001234.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

get_absolute_url()[source]
get_name_display(*, field=<django.db.models.fields.PositiveIntegerField: name>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
padding_amount

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

prefix

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ferrosoft.apps.ferrobase.models.shared.Language(*args, **kwargs)[source]

Bases: ISOCatalogEntry

Language defines a written language.

Since this is a ISO catalog entry, iso_code should conform to ISO codes, although this is not enforced.

SUPPORTED_LANGUAGES

List of language codes for which translations are kept up to date.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

SUPPORTED_LANGUAGES = ['de', 'en']
english_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod get_supported_language(iso_code)[source]

Get ISO code of supported language.

Parameters:

iso_code (str) – Requested language. If it is a supported language, it is returned.

Return type:

str

Returns: Supported language code. Defaults to settings.LANGUAGE_CODE or if that is undefined to “en”.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

iso_code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

localized_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <ferrosoft.apps.ferrobase.models.shared.LanguageManager object>
user_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class ferrosoft.apps.ferrobase.models.shared.LanguageManager(*args, **kwargs)[source]

Bases: ISOCatalogEntryManager

get_supported()[source]
class ferrosoft.apps.ferrobase.models.shared.LocalUser(*args, **kwargs)[source]

Bases: UUIDModel

LocalUser represents the user in tenant database.

Since User model resides in the global tenant-independent database, tenant-dependent models cannot reference User. Instead, they must reference LocalUser.

The 1-1 relationship from LocalUser to User is loosely enforced through the username field.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

company_sites

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

created_by

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod load(user)[source]

Find LocalUser corresponding to this user. If LocalUser does not exist, it is created implicitly.

Parameters:

user (ferrobase.User) – Tenant-independent User model instance

Return type:

LocalUser

Returns: LocalUser

objects = <django.db.models.manager.Manager object>
storedfile_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

username

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ferrosoft.apps.ferrobase.models.shared.LockableModelMixin(*args, **kwargs)[source]

Bases: Model

Mixing adding fields to create a lockable model.

Locking means prohibiting write operations. Enforcement is done by view code.

Views must acquire locks when selecting a model. On frontend side, a web socket should be used to periodically call to the backend to renew the lock.

LOCK_DURATION = datetime.timedelta(seconds=60)
class Meta[source]

Bases: object

abstract = False
acquire_lock(user)[source]

Lock model for given user.

If the model is already locked with a locked_until time lesser or equal to the current time, and locked_by being unequal to the given user, the exception ModelIsLocked is thrown.

Otherwise, the model is locked via lock_model method.

Parameters:

user (LocalUser) – User acquiring the lock

locked_by

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

locked_by_id
locked_until

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ferrosoft.apps.ferrobase.models.shared.Material(*args, **kwargs)[source]

Bases: SelectOptionsMixin, UUIDModel

Material represents a product.

code

A short identifier (free-form)

Type:

str

name

A descriptive name

Type:

str

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_absolute_url()[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <ferrosoft.apps.ferrobase.models.shared.MaterialManager object>
classmethod order_by_field()[source]
class ferrosoft.apps.ferrobase.models.shared.MaterialManager(*args, **kwargs)[source]

Bases: Manager

Manager for Material with a bulk upsert keyed on code.

upsert(records)[source]
class ferrosoft.apps.ferrobase.models.shared.MenuItem(id, name, route_name, position)[source]

Bases: UUIDModel

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
position

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

route_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception ferrosoft.apps.ferrobase.models.shared.ModelIsLocked(user, until)[source]

Bases: Exception

Raised when a LockableModelMixin instance is locked by another user.

class ferrosoft.apps.ferrobase.models.shared.Salutation(id, name)[source]

Bases: UUIDModel

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

businesspartner_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

companysite_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

classmethod get_ordered()[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
tcegeodestination_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

tcegeoorigin_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class ferrosoft.apps.ferrobase.models.shared.TimeZone(*args, **kwargs)[source]

Bases: UUIDModel

IANA timezone identifier stored per-tenant for user preferences.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

identifier

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <ferrosoft.apps.ferrobase.models.shared.TimeZoneManager object>
user_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class ferrosoft.apps.ferrobase.models.shared.TimeZoneManager(*args, **kwargs)[source]

Bases: Manager

Manager for TimeZone that provides a conflict-safe bulk upsert.

upsert(objects)[source]

ferrosoft.apps.ferrobase.models.subscription module

class ferrosoft.apps.ferrobase.models.subscription.AppFeature(*args, **kwargs)[source]

Bases: UUIDModel

A toggleable platform feature identified by a stable string code.

Features are assigned to SubscriptionPlan instances via FeatureAssignment, optionally with a numeric limit.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <ferrosoft.apps.ferrobase.models.subscription.AppFeatureManager object>
class ferrosoft.apps.ferrobase.models.subscription.AppFeatureManager(*args, **kwargs)[source]

Bases: Manager

Manager for AppFeature with a bulk upsert keyed on code.

upsert(objects)[source]
class ferrosoft.apps.ferrobase.models.subscription.FeatureAssignment(*args, **kwargs)[source]

Bases: Model

Through model linking an AppFeature to a SubscriptionPlan with an optional numeric limit.

The meaning of limit is feature-specific (e.g. maximum number of allowed users). Setting limit to 0 disables any limit check for that feature.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

feature

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

feature_id
get_absolute_url()[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

limit

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <ferrosoft.apps.ferrobase.models.subscription.FeatureAssignmentModel object>
plan

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

plan_id
with_plan(plan)[source]
Return type:

FeatureAssignment

class ferrosoft.apps.ferrobase.models.subscription.FeatureAssignmentModel(*args, **kwargs)[source]

Bases: Manager

Manager for FeatureAssignment that pre-fetches the related feature and supports bulk upsert.

get_queryset()[source]

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

upsert(objects)[source]
class ferrosoft.apps.ferrobase.models.subscription.SubscriptionPlan(*args, **kwargs)[source]

Bases: UUIDModel

Defines a subscription tier that controls which features and tonnage cap an organisation gets.

When enable_all_features is True, feature-gate checks are bypassed regardless of the FeatureAssignment entries.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

assigned_features

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

enable_all_features

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

features

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

get_absolute_url()[source]
get_assigned_feature(feature_code)[source]
Return type:

FeatureAssignment | None

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

max_tonnage

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <ferrosoft.apps.ferrobase.models.subscription.SubscriptionPlanManager object>
class ferrosoft.apps.ferrobase.models.subscription.SubscriptionPlanManager(*args, **kwargs)[source]

Bases: Manager

Manager for SubscriptionPlan with a bulk upsert keyed on id.

upsert(objects)[source]

ferrosoft.apps.ferrobase.models.units module

class ferrosoft.apps.ferrobase.models.units.MeasurementUnit(*args, **kwargs)[source]

Bases: UUIDModel

A physical unit of measurement identified by a symbol and a UnitSystem.

The combination of symbol and system is unique so that, for example, the imperial "ft" and the US customary "ft" are separate entries. Equality comparison supports UnitCursor and plain symbol strings (implicitly metric) for convenience.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

property cursor: UnitCursor
property fraction: Tuple[str, str]

Get tuple of denominator and divider of the symbol, if it is a fraction.

Raise exception if it is not a fraction.

classmethod get_ordered()[source]
Return type:

QuerySet

get_system_display(*, field=<django.db.models.fields.IntegerField: system>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <ferrosoft.apps.ferrobase.models.units.MeasurementUnitManager object>
symbol

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

system

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ferrosoft.apps.ferrobase.models.units.MeasurementUnitManager(*args, **kwargs)[source]

Bases: Manager

Manager for MeasurementUnit with bulk-lookup and upsert helpers.

get_lookup(*symbols)[source]
Return type:

dict[str, MeasurementUnit]

upsert(objects)[source]
exception ferrosoft.apps.ferrobase.models.units.UndefinedUnit[source]

Bases: Exception

Raised when a unit symbol or cursor cannot be resolved to a known MeasurementUnit.

class ferrosoft.apps.ferrobase.models.units.UnitCategory(*values)[source]

Bases: IntEnum

Physical quantity category used to group UnitCollection entries.

DISTANCE = 1
EMISSION_FACTOR = 3
EMISSION_VALUE = 2
ENERGY = 4
MASS = 5
NATIVE_CONSUMPTION = 6
class ferrosoft.apps.ferrobase.models.units.UnitCollection[source]

Bases: object

Pre-defined sets of UnitCursor objects organised by physical quantity.

Each class attribute is a list of UnitCursor instances covering the supported units for that quantity across all UnitSystem values. Used to populate UnitChoiceField and to seed the MeasurementUnit table during ferrobase_update.

DISTANCE = [UnitCursor(symbol='km', system=UnitSystem.METRIC), UnitCursor(symbol='m', system=UnitSystem.METRIC), UnitCursor(symbol='ft', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='yd', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='mi', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='le', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='ftm', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='cb', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='nmi', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='ft', system=UnitSystem.IMPERIAL), UnitCursor(symbol='yd', system=UnitSystem.IMPERIAL), UnitCursor(symbol='ch', system=UnitSystem.IMPERIAL), UnitCursor(symbol='fur', system=UnitSystem.IMPERIAL), UnitCursor(symbol='mile', system=UnitSystem.IMPERIAL), UnitCursor(symbol='lea', system=UnitSystem.IMPERIAL), UnitCursor(symbol='ftm', system=UnitSystem.IMPERIAL), UnitCursor(symbol='cb', system=UnitSystem.IMPERIAL), UnitCursor(symbol='nmi', system=UnitSystem.IMPERIAL)]
EMISSION = [UnitCursor(symbol='gCO2e', system=UnitSystem.METRIC), UnitCursor(symbol='kgCO2e', system=UnitSystem.METRIC), UnitCursor(symbol='tCO2e', system=UnitSystem.METRIC)]
EMISSION_FACTOR = [UnitCursor(symbol='kgCO2e/kg', system=UnitSystem.METRIC), UnitCursor(symbol='gCO2e/MJ', system=UnitSystem.METRIC)]
ENERGY = [UnitCursor(symbol='MJ/L', system=UnitSystem.METRIC), UnitCursor(symbol='MJ/kg', system=UnitSystem.METRIC), UnitCursor(symbol='MJ/kWh', system=UnitSystem.METRIC)]
MASS = [UnitCursor(symbol='kg', system=UnitSystem.METRIC), UnitCursor(symbol='t', system=UnitSystem.METRIC), UnitCursor(symbol='oz', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='lb', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='cwt', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='long cwt', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='st', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='ton', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='dw t', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='oz t', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='lb t', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='oz', system=UnitSystem.IMPERIAL), UnitCursor(symbol='lb', system=UnitSystem.IMPERIAL), UnitCursor(symbol='st', system=UnitSystem.IMPERIAL), UnitCursor(symbol='qr', system=UnitSystem.IMPERIAL), UnitCursor(symbol='cwt', system=UnitSystem.IMPERIAL), UnitCursor(symbol='ton', system=UnitSystem.IMPERIAL)]
NATIVE_CONSUMPTION = [UnitCursor(symbol='kg', system=UnitSystem.METRIC), UnitCursor(symbol='L', system=UnitSystem.METRIC), UnitCursor(symbol='kWh', system=UnitSystem.METRIC), UnitCursor(symbol='cu in', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='cu ft', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='cu yd', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='acre ft', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='US fl oz', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='US cup', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='US pt', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='US qt', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='pot', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='US gal', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='bbl', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='oil bbl', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='hhd', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='pt', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='qt', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='gal', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='pk', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='bu', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='dry bbl', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='fl oz', system=UnitSystem.IMPERIAL), UnitCursor(symbol='gi', system=UnitSystem.IMPERIAL), UnitCursor(symbol='pt', system=UnitSystem.IMPERIAL), UnitCursor(symbol='qt', system=UnitSystem.IMPERIAL), UnitCursor(symbol='gal', system=UnitSystem.IMPERIAL)]
VOLUMETRIC = [UnitCursor(symbol='L', system=UnitSystem.METRIC), UnitCursor(symbol='cu in', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='cu ft', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='cu yd', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='acre ft', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='US fl oz', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='US cup', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='US pt', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='US qt', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='pot', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='US gal', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='bbl', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='oil bbl', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='hhd', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='pt', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='qt', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='gal', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='pk', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='bu', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='dry bbl', system=UnitSystem.US_CUSTOMARY), UnitCursor(symbol='fl oz', system=UnitSystem.IMPERIAL), UnitCursor(symbol='gi', system=UnitSystem.IMPERIAL), UnitCursor(symbol='pt', system=UnitSystem.IMPERIAL), UnitCursor(symbol='qt', system=UnitSystem.IMPERIAL), UnitCursor(symbol='gal', system=UnitSystem.IMPERIAL)]
class ferrosoft.apps.ferrobase.models.units.UnitCursor(symbol, system=UnitSystem.METRIC)[source]

Bases: object

Used for lookup of units in UnitRegistry

symbol: str
system: UnitSystem = 0
ferrosoft.apps.ferrobase.models.units.UnitRef = str | uuid.UUID | ferrosoft.apps.ferrobase.models.units.MeasurementUnit | ferrosoft.apps.ferrobase.models.units.UnitCursor

Measurement units can be retrieved by values of these types. A string is treated as the unit symbol (and implicit metric unit system).

class ferrosoft.apps.ferrobase.models.units.UnitSystem(*values)[source]

Bases: IntegerChoices

System of measurement that groups related units together.

IMPERIAL = 2
METRIC = 0
US_CUSTOMARY = 1