Move QSO no validation into model
This commit is contained in:
parent
e049e45698
commit
c43c5c1e10
|
@ -4,7 +4,7 @@ import datetime
|
|||
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.core.validators import RegexValidator
|
||||
from django.core.validators import RegexValidator, MinValueValidator, MaxValueValidator
|
||||
from django.db.models import Q, signals
|
||||
|
||||
from .validators import CallUsernameValidator
|
||||
|
@ -146,6 +146,7 @@ class Frequency(models.Model):
|
|||
return "Channel %s: %s MHz" % (self.channel, self.qrg)
|
||||
|
||||
class QSO(models.Model):
|
||||
MAX_NO_VALUE = 1000000
|
||||
reportValidator = RegexValidator("[1-5][1-9]")
|
||||
|
||||
class Meta:
|
||||
|
@ -162,8 +163,9 @@ class QSO(models.Model):
|
|||
reportTX = models.CharField(max_length=7, default=59, verbose_name='RS-S', validators=[reportValidator])
|
||||
reportRX = models.CharField(max_length=7, default=59, verbose_name='RS-R', validators=[reportValidator])
|
||||
|
||||
ownNo = models.IntegerField(verbose_name='No')
|
||||
otherNo = models.IntegerField(verbose_name='No-R', null=True, blank=True)
|
||||
ownNo = models.IntegerField(verbose_name='No', validators=[MinValueValidator(1), MaxValueValidator(MAX_NO_VALUE)])
|
||||
otherNo = models.IntegerField(verbose_name='No-R', null=True, blank=True,
|
||||
validators=[MinValueValidator(1), MaxValueValidator(MAX_NO_VALUE)])
|
||||
|
||||
refStr = models.CharField(max_length=20, verbose_name="EXC")
|
||||
ref = models.ForeignKey(Reference, models.SET_NULL, null=True, blank=True)
|
||||
|
|
Loading…
Reference in New Issue