"""Model for the DevID Registration."""fromtypingimportAnyfromdjango.dbimportmodelsfromdjango.utils.translationimportgettext_lazyas_fromutil.fieldimportUniqueNameValidatorfrom.domainimportDomainModelfrom.truststoreimportTruststoreModel__all__=['DevIdRegistration']
[docs]classDevIdRegistration(models.Model):"""Represents a DevID Registration, linking a Truststore, Domain, unique name, and a serial number regex pattern."""
[docs]serial_number_pattern=models.CharField(verbose_name=_('Serial Number Pattern'),max_length=255,help_text=_('A regex pattern to match valid serial numbers for this registration.'),)
[docs]def__str__(self)->str:"""Returns a human-readable string representation of the DevIdRegistration instance."""returnf'DevIdRegistration: {self.unique_name}'
[docs]defsave(self,**kwargs:Any)->None:"""Ensures the model is valid and enforces validations before saving."""self.full_clean()super().save(**kwargs)