Added option to set contest deadline

Logging is also restricted after deadline has passed
This commit is contained in:
Sebastian Lohff 2017-01-26 20:51:22 +01:00
parent 1cf183cca2
commit 94d138ff8c
4 changed files with 39 additions and 2 deletions

2
TODO
View File

@ -2,7 +2,6 @@
- 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?)
- register users still has "reference" labels, make form better
- contest log add deadline
- cbr parser zum hochladen
(Partially) Done
@ -23,6 +22,7 @@
- align log button with log
- contest teilnahme klassen
- "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
- call dupe validation könnte ins model wandern

View File

@ -1,11 +1,12 @@
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.utils import timezone
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit, Layout
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
class CustomUserCreationForm(UserCreationForm):
@ -50,6 +51,12 @@ class UpdateCategoryForm(forms.Form):
self.helper.add_input(Submit('submit', 'Set category'))
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 Meta:
model = QSO
@ -110,6 +117,13 @@ class QSOForm(forms.ModelForm):
def clean_refStr(self):
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 Meta:
model = QSO

View File

@ -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,
),
]

View File

@ -13,6 +13,7 @@ class Contest(models.Model):
name = models.CharField(max_length=20)
shortName = models.CharField(max_length=20, unique=True)
callQrg = models.ForeignKey("Frequency", models.SET_NULL, null=True, blank=True)
deadline = models.DateTimeField()
def __str__(self):
return self.name