ferrosoft.apps.ferrobase.forms package

Submodules

ferrosoft.apps.ferrobase.forms.copy module

class ferrosoft.apps.ferrobase.forms.copy.ModelCopyingForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: BaseModelForm

Model form that creates a copy of an existing instance.

The hidden source_id field identifies the source instance. On save, fields listed in _copying.fields_to_copy are transferred from source to the new instance; fields exposed in the form are filled in by the user and override the copied values. An optional preparator can implement additional copy logic (e.g. duplicating related objects).

base_fields = {'source_id': <django.forms.fields.UUIDField object>}
property copy_options: ModelCopyingFormOptions
declared_fields = {'source_id': <django.forms.fields.UUIDField object>}
property media

Return all media required to render the widgets on this form.

save(commit=True)[source]

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

ferrosoft.apps.ferrobase.forms.copy.copy_fields(source, target, *, fields, **kwargs)[source]

Copy all named fields from source to target.

Any keyword arguments passed to this function override values in target.

Target is returned for convenience, allowing this function to be used in list comprehension.

ferrosoft.apps.ferrobase.forms.copy.copy_form_factory(model, *, additional_fields=None, fields_to_copy=None, preparator=None, **kwargs)[source]

Create a model form class suitable for CopyView.

Fields named in fields_to_copy are copied without user interaction from source to target instance.

Pass preparator for custom copying logic. It is called with source and target objects after standard copying.

Keyword arguments are passed to modelform_factory, allowing fields to be specified requiring user interaction.

ferrosoft.apps.ferrobase.forms.fields module

class ferrosoft.apps.ferrobase.forms.fields.UnitChoiceField(*args, **kwargs)[source]

Bases: ChoiceField

Choice field that presents measurement units grouped by unit system.

Units are looked up from ModelRegistry.Unit and rendered as an <optgroup> per UnitSystem (Metric, US Customary, Imperial). The field converts a submitted UUID string back to a MeasurementUnit instance via to_python.

Parameters:
  • units – Iterable of UnitCursor objects defining the selectable units.

  • initial – Optional UnitCursor whose matching database unit is pre-selected.

to_python(value)[source]

Convert a UUID string from the form submission to a MeasurementUnit.

Parameters:

value – UUID string identifying the selected unit.

Returns:

The corresponding unit instance from the registry.

Return type:

MeasurementUnit

valid_value(value)[source]

Check that the submitted value identifies a known unit.

Parameters:

value – UUID string to validate.

Returns:

True if the registry contains a unit with this UUID.

Return type:

bool

class ferrosoft.apps.ferrobase.forms.fields.UnitChoiceIterator[source]

Bases: BaseChoiceIterator

Choice iterator for measurement units (reserved for future use).

ferrosoft.apps.ferrobase.forms.model_forms module

class ferrosoft.apps.ferrobase.forms.model_forms.APITokenForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: ModelForm

Form for displaying an API token’s name field.

Token creation is intentionally blocked at the form level; tokens must be generated through APIToken.create so that the JWT is returned to the caller.

class Meta[source]

Bases: object

fields = ['name']
model

alias of APIToken

base_fields = {'name': <django.forms.fields.CharField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

save(commit=True)[source]

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

class ferrosoft.apps.ferrobase.forms.model_forms.CompanySiteForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: ModelForm

Form for creating and updating CompanySite records.

Renders additional_lines as a compact two-row textarea.

class Meta[source]

Bases: object

fields = ['code', 'name', 'salutation', 'first_name', 'last_name', 'company', 'additional_lines', 'street', 'house_no', 'city', 'postal_code', 'country']
model

alias of CompanySite

widgets = {'additional_lines': <django.forms.widgets.Textarea object>}
base_fields = {'additional_lines': <django.forms.fields.CharField object>, 'city': <django.forms.fields.CharField object>, 'code': <django.forms.fields.CharField object>, 'company': <django.forms.fields.CharField object>, 'country': <django.forms.models.ModelChoiceField object>, 'first_name': <django.forms.fields.CharField object>, 'house_no': <django.forms.fields.CharField object>, 'last_name': <django.forms.fields.CharField object>, 'name': <django.forms.fields.CharField object>, 'postal_code': <django.forms.fields.CharField object>, 'salutation': <django.forms.models.ModelChoiceField object>, 'street': <django.forms.fields.CharField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class ferrosoft.apps.ferrobase.forms.model_forms.FeatureAssignmentForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: ModelForm

Form for assigning an AppFeature to a SubscriptionPlan with an optional limit.

The plan field is hidden because it is set programmatically from the parent subscription context.

class Meta[source]

Bases: object

fields = ['plan', 'feature', 'limit']
model

alias of FeatureAssignment

widgets = {'plan': <django.forms.widgets.HiddenInput object>}
base_fields = {'feature': <django.forms.models.ModelChoiceField object>, 'limit': <django.forms.fields.IntegerField object>, 'plan': <django.forms.models.ModelChoiceField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class ferrosoft.apps.ferrobase.forms.model_forms.GroupPermissionsForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: ModelForm

Form for assigning Django permissions to a Group via checkboxes.

class Meta[source]

Bases: object

fields = ['permissions']
model

alias of Group

base_fields = {'permissions': <django.forms.models.ModelMultipleChoiceField object>}
declared_fields = {'permissions': <django.forms.models.ModelMultipleChoiceField object>}
property media

Return all media required to render the widgets on this form.

class ferrosoft.apps.ferrobase.forms.model_forms.IDSequenceForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: ModelForm

Form for configuring a named IdSequenceConfig entry (prefix and padding).

class Meta[source]

Bases: object

fields = ['name', 'prefix', 'padding_amount']
model

alias of IdSequenceConfig

base_fields = {'name': <django.forms.fields.TypedChoiceField object>, 'padding_amount': <django.forms.fields.IntegerField object>, 'prefix': <django.forms.fields.CharField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class ferrosoft.apps.ferrobase.forms.model_forms.OrganizationForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: ModelForm

Form for creating and updating Organization master records.

class Meta[source]

Bases: object

fields = ['name', 'contact_email', 'contact_first_name', 'contact_last_name', 'subscription']
model

alias of Organization

base_fields = {'contact_email': <django.forms.fields.EmailField object>, 'contact_first_name': <django.forms.fields.CharField object>, 'contact_last_name': <django.forms.fields.CharField object>, 'name': <django.forms.fields.CharField object>, 'subscription': <django.forms.models.ModelChoiceField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class ferrosoft.apps.ferrobase.forms.model_forms.SubscriptionPlanForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: ModelForm

Form for editing SubscriptionPlan tier settings (name, tonnage cap, feature flag).

class Meta[source]

Bases: object

fields = ['name', 'max_tonnage', 'enable_all_features']
model

alias of SubscriptionPlan

base_fields = {'enable_all_features': <django.forms.fields.BooleanField object>, 'max_tonnage': <django.forms.fields.IntegerField object>, 'name': <django.forms.fields.CharField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class ferrosoft.apps.ferrobase.forms.model_forms.TenantForm(*args, **kwargs)[source]

Bases: ModelForm

Form for creating and updating Tenant records.

When enable_add_tenant=True is passed at instantiation, save delegates to add_tenant (which provisions the tenant database and loads fixtures) instead of the standard ModelForm.save. This flag is only meaningful for new tenants; updates use the standard path regardless.

class Meta[source]

Bases: object

fields = ['organization', 'name', 'active', 'expiry_date']
model

alias of Tenant

widgets = {'expiry_date': <django.forms.widgets.DateTimeInput object>, 'organization': <django.forms.widgets.HiddenInput object>}
base_fields = {'active': <django.forms.fields.BooleanField object>, 'expiry_date': <django.forms.fields.DateTimeField object>, 'language': <django.forms.models.ModelChoiceField object>, 'name': <django.forms.fields.CharField object>, 'organization': <django.forms.models.ModelChoiceField object>}
declared_fields = {'language': <django.forms.models.ModelChoiceField object>}
property media

Return all media required to render the widgets on this form.

save(commit=True)[source]

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

class ferrosoft.apps.ferrobase.forms.model_forms.UserCreationForm(*args, **kwargs)[source]

Bases: UserPasswordForm

Form for creating new User accounts.

The organization field is hidden and fixed to the caller’s organization unless allow_organization_selection=True is passed (for superusers).

class Meta[source]

Bases: object

fields = ['username', 'email', 'organization']
model

alias of User

base_fields = {'email': <django.forms.fields.EmailField object>, 'organization': <django.forms.models.ModelChoiceField object>, 'password': <django.forms.fields.CharField object>, 'username': <django.forms.fields.CharField object>}
declared_fields = {'password': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

save(commit=True)[source]

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

class ferrosoft.apps.ferrobase.forms.model_forms.UserGroupsForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: ModelForm

Form for managing a user’s Django group memberships via checkboxes.

class Meta[source]

Bases: object

fields = ['groups']
model

alias of User

base_fields = {'groups': <django.forms.models.ModelMultipleChoiceField object>}
declared_fields = {'groups': <django.forms.models.ModelMultipleChoiceField object>}
property media

Return all media required to render the widgets on this form.

class ferrosoft.apps.ferrobase.forms.model_forms.UserPasswordForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]

Bases: ModelForm

Base form mixin that adds an optional password field to any User form.

If the password field is left empty, the existing password is not changed.

base_fields = {'password': <django.forms.fields.CharField object>}
declared_fields = {'password': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

save(commit=True)[source]

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

class ferrosoft.apps.ferrobase.forms.model_forms.UserUpdateForm(*args, **kwargs)[source]

Bases: UserPasswordForm

Form for editing an existing User account’s profile and preferences.

class Meta[source]

Bases: object

fields = ['username', 'is_active', 'first_name', 'last_name', 'email', 'language', 'timezone', 'color_theme']
model

alias of User

base_fields = {'color_theme': <django.forms.fields.TypedChoiceField object>, 'email': <django.forms.fields.EmailField object>, 'first_name': <django.forms.fields.CharField object>, 'is_active': <django.forms.fields.BooleanField object>, 'language': <django.forms.models.ModelChoiceField object>, 'last_name': <django.forms.fields.CharField object>, 'password': <django.forms.fields.CharField object>, 'timezone': <django.forms.models.ModelChoiceField object>, 'username': <django.forms.fields.CharField object>}
declared_fields = {'password': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.