Compare commits

..

2 Commits

Author SHA1 Message Date
Sebastian Lohff c121e874c6 Set on_delete for all ForeignKey fields
Can't believe this has not been done yet.
2022-01-22 16:54:13 +01:00
Sebastian Lohff 0178fcb3ef Remove some python2 --> python3 leftovers
Remove some __future__ imports and the six compability layer (which was
not mentioned in the requirements.txt anyway).
2022-01-22 16:47:07 +01:00
4 changed files with 12 additions and 18 deletions

View File

@ -1,6 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python
from __future__ import print_function
# prepare environment # prepare environment
import sys import sys
sys.path.append("..") sys.path.append("..")

View File

@ -1,5 +1,3 @@
from __future__ import unicode_literals
from django.apps import AppConfig from django.apps import AppConfig

View File

@ -1,5 +1,3 @@
from __future__ import unicode_literals
import datetime import datetime
from django.contrib.auth.models import AbstractUser from django.contrib.auth.models import AbstractUser
@ -14,7 +12,7 @@ from .validators import CallUsernameValidator
class Contest(models.Model): class Contest(models.Model):
name = models.CharField(max_length=20) name = models.CharField(max_length=20)
shortName = models.CharField(max_length=20, unique=True) shortName = models.CharField(max_length=20, unique=True)
callQrg = models.ForeignKey("Frequency", models.SET_NULL, null=True, blank=True) callQrg = models.ForeignKey("Frequency", on_delete=models.SET_NULL, null=True, blank=True)
deadline = models.DateTimeField() deadline = models.DateTimeField()
qsoStartTime = models.DateTimeField() qsoStartTime = models.DateTimeField()
@ -136,7 +134,7 @@ signals.post_save.connect(checkForShadowCall, sender=User)
class Band(models.Model): class Band(models.Model):
name = models.CharField(max_length=10) name = models.CharField(max_length=10)
contest = models.ForeignKey(Contest) contest = models.ForeignKey(Contest, on_delete=models.CASCADE)
def __str__(self): def __str__(self):
return self.name return self.name
@ -147,7 +145,7 @@ class Frequency(models.Model):
# band # band
channel = models.CharField(max_length=3) channel = models.CharField(max_length=3)
qrg = models.DecimalField(max_digits=7, decimal_places=3) qrg = models.DecimalField(max_digits=7, decimal_places=3)
band = models.ForeignKey(Band) band = models.ForeignKey(Band, on_delete=models.CASCADE)
note = models.CharField(max_length=50, blank=True) note = models.CharField(max_length=50, blank=True)
@ -164,11 +162,11 @@ class QSO(models.Model):
["owner", "call"], ["owner", "call"],
] ]
owner = models.ForeignKey(User, db_index=True) owner = models.ForeignKey(User, on_delete=models.CASCADE, db_index=True)
time = models.DateTimeField(blank=True) time = models.DateTimeField(blank=True)
call = models.CharField(max_length=20, db_index=True) call = models.CharField(max_length=20, db_index=True)
callRef = models.ForeignKey(User, models.SET_NULL, related_name='qsoref', null=True, blank=True, default=None) callRef = models.ForeignKey(User, on_delete=models.SET_NULL, related_name='qsoref', null=True, blank=True, default=None)
band = models.ForeignKey(Band) band = models.ForeignKey(Band, on_delete=models.CASCADE)
reportTX = models.CharField(max_length=7, default=59, verbose_name='RS-S', validators=[reportValidator]) 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]) reportRX = models.CharField(max_length=7, default=59, verbose_name='RS-R', validators=[reportValidator])
@ -178,11 +176,11 @@ class QSO(models.Model):
validators=[MinValueValidator(1), MaxValueValidator(MAX_NO_VALUE)]) validators=[MinValueValidator(1), MaxValueValidator(MAX_NO_VALUE)])
refStr = models.CharField(max_length=20, verbose_name="EXC") refStr = models.CharField(max_length=20, verbose_name="EXC")
ref = models.ForeignKey(Reference, models.SET_NULL, null=True, blank=True) ref = models.ForeignKey(Reference, on_delete=models.SET_NULL, null=True, blank=True)
remarks = models.CharField(max_length=50, blank=True, default=None) remarks = models.CharField(max_length=50, blank=True, default=None)
cfmdQSO = models.ForeignKey("QSO", models.SET_NULL, null=True, blank=True, default=None) cfmdQSO = models.ForeignKey("QSO", on_delete=models.SET_NULL, null=True, blank=True, default=None)
CFMD_SEC = 5 * 60 CFMD_SEC = 5 * 60

View File

@ -1,7 +1,6 @@
from django.core import validators from django.core import validators
from django.utils import six
from django.utils.deconstruct import deconstructible from django.utils.deconstruct import deconstructible
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import gettext_lazy as _
import re import re
@ -13,7 +12,8 @@ class CallUsernameValidator(validators.RegexValidator):
'Enter a valid Callsign as Username, ALL UPPERCASE, if needed with -1 / -2,' 'Enter a valid Callsign as Username, ALL UPPERCASE, if needed with -1 / -2,'
'e.g. DL7BST, DN1BER-1, DL/OE1FOO.' 'e.g. DL7BST, DN1BER-1, DL/OE1FOO.'
) )
flags = re.ASCII if six.PY3 else 0 flags = re.ASCII
@deconstructible @deconstructible
class CallLogValidator(validators.RegexValidator): class CallLogValidator(validators.RegexValidator):
@ -22,4 +22,4 @@ class CallLogValidator(validators.RegexValidator):
'Enter a valid callsign, ALL UPPERCASE, if needed with -1 / -2,' 'Enter a valid callsign, ALL UPPERCASE, if needed with -1 / -2,'
'e.g. DL7BST, DN1BER-1, DL/OE1FOO, DN1FTW-1/p' 'e.g. DL7BST, DN1BER-1, DL/OE1FOO, DN1FTW-1/p'
) )
flags = re.ASCII if six.PY3 else 0 flags = re.ASCII