Ejemplo n.º 1
0
 def clean_rfid(self):
     rfid = self.cleaned_data['rfid']
     if len(rfid) != 10:
         raise forms.ValidationError("This is not a valid 10 digit RFID!")
     if rfid in get_all_rfids():
         raise forms.ValidationError("This RFID is already in use!")
     return rfid
Ejemplo n.º 2
0
    def clean_rfid(self):
        rfid = self.cleaned_data["rfid"]

        if rfid in get_all_rfids():
            raise forms.ValidationError("This RFID is already in use!")

        # If a member is renewing, the RFID can either be a new rfid, or empty
        if self.referenced_member and not (len(rfid) == 0 or len(rfid) == 10):
            raise forms.ValidationError

        # If a member is not renewing, then rfid must be present
        if not self.referenced_member and len(rfid) != 10:
            raise forms.ValidationError("This is not a valid 10 digit RFID!")

        return rfid
Ejemplo n.º 3
0
def validate_rfid(rfid):
    """Ensure that the given rfid is unique across all tables containing rfids."""
    if rfid in get_all_rfids():
        msg = 'This rfid is already in use!'
        logger.info(msg)
        raise ValidationError(msg)
Ejemplo n.º 4
0
def validate_rfid(rfid):
    """Ensure that the given rfid is unique across all tables containing rfids."""
    if rfid in get_all_rfids():
        raise ValidationError("This rfid is already in use!")