Skip to content

Commit

Permalink
Improve docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklinke committed Aug 16, 2024
1 parent ead1b75 commit 9ecc80a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/django_tenant_options/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


class TenantFormBaseMixin:
"""Mixin that checks for a valid tenant value passed from the view and hides the tenant field."""
"""Base mixin that checks for a valid tenant value passed from the view and hides the tenant field."""

def __init__(self, *args, **kwargs):
self.tenant = self._pop_tenant(kwargs)
Expand Down Expand Up @@ -101,7 +101,7 @@ def clean(self):


class OptionUpdateFormMixin(OptionCreateFormMixin): # pylint disable=R0903
"""Used in forms that allow a tenant to update an existing option.
"""Used in forms that allow a tenant to update an existing custom option.
Has the same operation and requirements as OptionCreateFormMixin, but also allows the option to be deleted.
Expand Down Expand Up @@ -139,7 +139,10 @@ def clean(self):


class SelectionsForm(TenantFormBaseMixin, forms.Form):
"""Creates a form with a `selections` field, defaulting to OptionsModelMultipleChoiceField.
"""Creates a form with a `selections` field, defaulting to use OptionsModelMultipleChoiceField.
An alternative field class can be provided via the `DEFAULT_MULTIPLE_CHOICE_FIELD` setting, or by setting
the `multiple_choice_field_class` attribute in the form.
Usage:
Expand Down Expand Up @@ -222,14 +225,15 @@ def _save_new_selections(self):


class UserFacingFormMixin:
"""Mixin for forms allowing a tenant to create a new custom option.
"""Mixin to handle all user-facing forms with Options.
This mixin requires a `tenant` argument to be passed from the view. The `tenant` should be an instance of the
model class specified in the `tenant_model` parameter of the concrete `OptionModel`.
The form will:
- Set the `option_type` field to `OptionType.CUSTOM`.
- Set the `tenant` field to the tenant instance using a `HiddenInput` widget.
- Handle options that are no longer selected by the tenant.
Example usage:
Expand Down

0 comments on commit 9ecc80a

Please sign in to comment.