slm.validators

class slm.validators.Flag

Bases: tuple

Flag(message, manual, severity)

static __new__(_cls, message, manual, severity)

Create new instance of Flag(message, manual, severity)

manual

Alias for field number 1

message

Alias for field number 0

severity

Alias for field number 2

slm.validators.get_validators(model, field)[source]

Get the validator list for a given model and field from validation settings.

Parameters:
  • model – The Django model name <app_name>.<ModelClass>

  • field – The field name

Returns:

slm.validators.bypass_block()[source]

Return if we should bypass any validation save blocking. This setting is controlled by the SLM_VALIDATION_BYPASS_BLOCK setting in settings or can be preempted by toggling the BYPASS_BLOCKS flag above.

This is important when working with legacy data. All validators should respect this flag.

Returns:

True if we should bypass any save blocks

class slm.validators.TimeRangeBookendValidator[source]

Bases: SLMValidator

Ensures that sections that should not have overlapping time ranges are properly bookended - i.e. that the time range fields are closed before the next section starts.

__init__(*args, bookend_field='installed', severity=FlagSeverity.NOTIFY, **kwargs)[source]
class slm.validators.PositionsMatchValidator[source]

Bases: SLMValidator

Attach this validator to SiteLocation llh and/or xyz fields to validate that these positions are within the given tolerance of each other.

__init__(*args, severity=FlagSeverity.BLOCK_SAVE, tolerance=1.0, **kwargs)[source]
Parameters:

tolerance (float)

tolerance = 1.0

3D tolerance in meters between the positions before flagging.