recordtransfer.forms - Forms for recordtransfer models

Form Mixins

recordtransfer.forms.mixins.validate_no_html_in_text_fields(form: BaseForm) None

Add an error to any text-based field whose cleaned value contains HTML.

Iterates over all CharField (and subclass) fields on the form and uses nh3.is_html() to detect HTML in the cleaned value. If HTML is found, an error is added to the field so the form is marked invalid.

class recordtransfer.forms.mixins.ContactInfoFormMixin(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, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)

Mixin containing address-related form fields.

clean_address_fields() dict

Ensure that the province_or_state field is filled out if ‘Other’ is selected.

property media

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

class recordtransfer.forms.mixins.HiddenCaptchaMixin

Add to forms that require reCAPTCHA validation.

class recordtransfer.forms.mixins.VisibleCaptchaMixin

Add to forms that require visible reCAPTCHA validation.

Admin Forms

Forms specific to the recordtransfer admin site.

class recordtransfer.forms.admin_forms.UserAdminForm(*args, **kwargs)

Custom form for User admin that includes contact information fields.

class Meta

Meta class for UserAdminForm.

model

alias of User

clean() dict[str, Any]

Override clean to call both parent clean methods and enforce group validation.

property media

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

class recordtransfer.forms.admin_forms.RecordTransferModelForm(*args, **kwargs)

Adds disabled_fields to forms.ModelForm.

property media

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

class recordtransfer.forms.admin_forms.SubmissionModelForm(*args, **kwargs)

Form for editing Submissions.

class Meta

Meta class for SubmissionModelForm.

model

alias of Submission

property media

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

class recordtransfer.forms.admin_forms.SiteSettingModelForm(*args, **kwargs)

Form for editing SiteSettings with validation for different value types.

class Meta

Meta class for SiteSettingModelForm.

model

alias of SiteSetting

clean_value() Any

Validate the value field based on the selected value_type.

clean() dict[str, Any]

Additional form-level validation.

property media

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

Submission Forms

Forms specific to creating new submissions.

class recordtransfer.forms.submission_forms.ReviewFormItem

A dictionary representing a form item for review by the user.

step_title

The human-readable title of the step.

Type:

str

step_name

The name of the step.

Type:

str

fields

The fields of the step.

Type:

list[dict[str, Any]] | dict[str, Any]

note

An optional note, intended to be used as a message to the user if a section is empty,

Type:

str | None

for example.
class recordtransfer.forms.submission_forms.SubmissionForm(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, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)

Base form for all submission forms.

clean() dict

Run shared validation, including rejecting HTML in text inputs.

property media

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

class recordtransfer.forms.submission_forms.AcceptLegal(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, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)

Form for accepting legal terms.

class Meta

Meta information for the form.

clean() dict

Clean form data and validate the session token.

property media

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

class recordtransfer.forms.submission_forms.ContactInfoForm(*args, **kwargs)

The Contact Information portion of the form. Contains fields from Section 2 of CAAIS.

class Meta

Meta information for the form.

clean() dict

Clean form data.

property media

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

class recordtransfer.forms.submission_forms.SourceInfoForm(*args, **kwargs)

The Source Information portion of the form. Contains fields from Section 2 of CAAIS.

This form is nominally “optional,” but a user can fill in the fields if they want to. The source name, source type, and source role are all required in CAAIS, so if a user chooses not to fill in the form, we use defaults from the initial data for those fields.

class Meta

Meta information for the form.

clean() dict

Clean form and set defaults if the user chose not to enter source info manually.

property media

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

class recordtransfer.forms.submission_forms.RecordDescriptionForm(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, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)

The Description Information portion of the form. Contains fields from Section 3 of CAAIS.

class Meta

Meta information for the form.

clean() dict

Form date as approximate if user chose to mark the date as approximate.

property media

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

class recordtransfer.forms.submission_forms.ExtendedRecordDescriptionForm(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, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)

Adds quantity and type of units to record description form. Intended to be used when file uploads are disabled.

property media

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

class recordtransfer.forms.submission_forms.RightsFormSet(*args, **kwargs)

Formset for rights information (optional).

class Meta

Meta information for the form.

class recordtransfer.forms.submission_forms.RightsForm(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, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)

The Rights portion of the form. Contains fields from Section 4 of CAAIS.

class Meta

Meta information for the form.

clean() dict

Check that the rights type is set if the other rights type is not.

property media

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

class recordtransfer.forms.submission_forms.OtherIdentifiersForm(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, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)

The Other Identifiers portion of the form. Contains fields from Section 1 of CAAIS.

class Meta

Meta information for the form.

clean() dict

Check that the other identifier type and value are set if the note is set.

property media

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

class recordtransfer.forms.submission_forms.OtherIdentifiersFormSet(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, form_kwargs=None, error_messages=None)

Special formset to add metadata to the other identifiers formset.

class Meta

Meta information for the form.

class recordtransfer.forms.submission_forms.GroupSubmissionForm(*args, **kwargs)

Form for assigning a submission to a specific group.

class Meta

Meta information for the form.

clean() dict

Check that chosen group exists and is owned by the user.

property media

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

class recordtransfer.forms.submission_forms.UploadFilesForm(*args, **kwargs)

The form where users upload their files and write any final notes.

The upload session is supplied by the view.

class Meta

Meta information for the form.

clean() dict

Check that the upload session is valid and that at least one file was uploaded.

property media

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

class recordtransfer.forms.submission_forms.FinalStepFormNoUpload(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, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)

The form where users write any final notes. Intended to be used in place of UploadFilesForm when file uploads are disabled.

class Meta

Meta information for the form.

property media

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

class recordtransfer.forms.submission_forms.ReviewForm(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, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)

The final step of the form where the user can review their submission before sending it.

class Meta

Meta information for the form.

static format_form_data(form_dict: OrderedDict[str, BaseForm | BaseFormSet], user: User) list[ReviewFormItem]

Format form data to be used in a form review page.

property media

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

class recordtransfer.forms.submission_forms.ReviewFormReCaptcha(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, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)

The final step of the form, with a hidden reCAPTCHA input.

property media

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

recordtransfer.forms.submission_forms.clear_form_errors(form: BaseForm | BaseFormSet) None

Clear all errors on a form or formset.

Submission Group Forms

class recordtransfer.forms.submission_group_form.SubmissionGroupForm(*args, **kwargs)

Form for creating and updating SubmissionGroup instances.

class Meta

Meta options for SubmissionGroupForm.

model

alias of SubmissionGroup

clean() dict[str, Any]

Clean the form data.

save(commit: bool = True) SubmissionGroup

Save the form data to a SubmissionGroup instance.

property media

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

User Forms

class recordtransfer.forms.user_forms.SignUpForm(*args, **kwargs)

Form for a user to create a new account.

class Meta

Meta class for SignUpForm.

model

alias of User

clean() dict[str, Any]

Clean data, make sure username and email are not already in use.

property media

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

class recordtransfer.forms.user_forms.SignUpFormRecaptcha(*args, **kwargs)

Form for a user to create a new account with reCAPTCHA.

property media

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

class recordtransfer.forms.user_forms.UserAccountInfoForm(*args, **kwargs)

Form for updating a user’s account information.

class Meta

Meta class for UserProfileForm.

model

alias of User

property media

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

class recordtransfer.forms.user_forms.AsyncPasswordResetForm(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, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)

Form for resetting a user’s password.

send_mail(subject_template_name: str, email_template_name: str, context: dict[str, Any], from_email: str | None, to_email: str, html_email_template_name: str | None = None) None

Override parent method to send password reset email asynchronously using django_rq.

property media

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

class recordtransfer.forms.user_forms.UserContactInfoForm(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)

ModelForm version of ContactInfoFormMixin for editing a User’s contact information.

class Meta

Meta class for UserContactInfoForm.

model

alias of User

clean() dict

Clean form data.

property media

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