Enforce uid with uppercase for Studentcard and test more edge cases

This commit is contained in:
2019-05-14 15:51:14 +02:00
parent 5ae7d10e84
commit 19e353970d
2 changed files with 50 additions and 1 deletions

View File

@ -749,7 +749,8 @@ class StudentCard(models.Model):
@staticmethod
def is_valid(uid):
return (
len(uid) == StudentCard.UID_SIZE
uid.isupper()
and len(uid) == StudentCard.UID_SIZE
and not StudentCard.objects.filter(uid=uid).exists()
)