import datetime
from django import forms
from django.core.validators import ValidationError
from django.utils import timezone
from .models import Assignment
from .terms import TERMS
def validate_in_past(value):
if value > timezone.now().date():
# Adding a day to allow the current date anywhere on earth, regardless of
# the server timezone.
if value > timezone.now().date() + datetime.timedelta(days=1):
raise ValidationError('Enter a date in the past')
class AssignmentForm(forms.ModelForm):
period_begins = forms.DateField(
label='Assign the copyright in my above contributions starting on',