fairdm.core.formsets#
Shared formsets for the rows of related records a record carries.
Module Contents#
Functions#
Return a formset class that refuses a backwards start/end date pair. |
API#
- date_ordering_formset(start_type, end_type, message)[source]#
Return a formset class that refuses a backwards start/end date pair.
A formset validates every form before any of them saves, so a per-row
clean()that looks its sibling up in the database (asProjectDate.clean()andDatasetDate.clean()do) sees no unsaved sibling when both dates are new rows in the same submission. The returned formset reads the start and end values off the forms’cleaned_datainstead, so the pair is checked whichever of the two (or both) is unsaved.The message is passed whole rather than assembled from a noun so that each record type states its own date vocabulary and the sentence stays translatable as one unit.
Args: start_type: The address of the date type marking the start of the pair. end_type: The address of the date type marking the end of the pair. message: The error message, using
%(start)sand%(end)splaceholders.Returns: A
BaseInlineFormSetsubclass whoseclean()raises aValidationErrorwhen the end precedes the start.