Added option to set contest deadline
Logging is also restricted after deadline has passed
This commit is contained in:
parent
1cf183cca2
commit
94d138ff8c
2
TODO
2
TODO
|
@ -2,7 +2,6 @@
|
||||||
- rearrange login index: contest content rüberziehen; exchange registration nach rechts in der nav
|
- rearrange login index: contest content rüberziehen; exchange registration nach rechts in der nav
|
||||||
- ensure QSOs are logged in UTC (they currently are, but why?)
|
- ensure QSOs are logged in UTC (they currently are, but why?)
|
||||||
- register users still has "reference" labels, make form better
|
- register users still has "reference" labels, make form better
|
||||||
- contest log add deadline
|
|
||||||
- cbr parser zum hochladen
|
- cbr parser zum hochladen
|
||||||
|
|
||||||
(Partially) Done
|
(Partially) Done
|
||||||
|
@ -23,6 +22,7 @@
|
||||||
- align log button with log
|
- align log button with log
|
||||||
- contest teilnahme klassen
|
- contest teilnahme klassen
|
||||||
- "Please register with your (uppercase) Callsign as Usernames. For DN-Calls, /[A-Z] is allowed." gibt es wohl noch wo
|
- "Please register with your (uppercase) Callsign as Usernames. For DN-Calls, /[A-Z] is allowed." gibt es wohl noch wo
|
||||||
|
- contest log add deadline
|
||||||
|
|
||||||
Glaube nich, dass ich das mache
|
Glaube nich, dass ich das mache
|
||||||
- call dupe validation könnte ins model wandern
|
- call dupe validation könnte ins model wandern
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.auth.forms import UserCreationForm
|
from django.contrib.auth.forms import UserCreationForm
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from crispy_forms.helper import FormHelper
|
from crispy_forms.helper import FormHelper
|
||||||
from crispy_forms.layout import Submit, Layout
|
from crispy_forms.layout import Submit, Layout
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from .models import User, Reference, QSO, ShadowCall, EntryCategory
|
from .models import User, Reference, QSO, ShadowCall, EntryCategory, Contest
|
||||||
from .validators import CallUsernameValidator, CallLogValidator
|
from .validators import CallUsernameValidator, CallLogValidator
|
||||||
|
|
||||||
class CustomUserCreationForm(UserCreationForm):
|
class CustomUserCreationForm(UserCreationForm):
|
||||||
|
@ -50,6 +51,12 @@ class UpdateCategoryForm(forms.Form):
|
||||||
self.helper.add_input(Submit('submit', 'Set category'))
|
self.helper.add_input(Submit('submit', 'Set category'))
|
||||||
self.helper.layout = Layout('entry')
|
self.helper.layout = Layout('entry')
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
contest = Contest.objects.get(id=1)
|
||||||
|
|
||||||
|
if contest.deadline < timezone.now():
|
||||||
|
raise forms.ValidationError("The deadline for setting your contest category has passed")
|
||||||
|
|
||||||
class QSOForm(forms.ModelForm):
|
class QSOForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = QSO
|
model = QSO
|
||||||
|
@ -110,6 +117,13 @@ class QSOForm(forms.ModelForm):
|
||||||
def clean_refStr(self):
|
def clean_refStr(self):
|
||||||
return self.cleaned_data["refStr"].upper()
|
return self.cleaned_data["refStr"].upper()
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
cleaned_data = super(QSOForm, self).clean()
|
||||||
|
band = cleaned_data.get("band")
|
||||||
|
|
||||||
|
if band.contest.deadline < timezone.now():
|
||||||
|
raise forms.ValidationError("The deadline for logging and editing QSOs has passed")
|
||||||
|
|
||||||
class QSOFormWithTime(QSOForm):
|
class QSOFormWithTime(QSOForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = QSO
|
model = QSO
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.3 on 2017-01-26 19:40
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.utils.timezone
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('contest', '0013_auto_20170126_1909'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='contest',
|
||||||
|
name='deadline',
|
||||||
|
field=models.DateTimeField(default=django.utils.timezone.now),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
|
@ -13,6 +13,7 @@ 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", models.SET_NULL, null=True, blank=True)
|
||||||
|
deadline = models.DateTimeField()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
Loading…
Reference in New Issue