assignment: Accept current date anywhere on earth.
This commit is contained in:
parent
6e380dba29
commit
7374c9f915
2 changed files with 10 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import datetime
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.core.validators import ValidationError
|
from django.core.validators import ValidationError
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
@ -7,7 +9,9 @@ from .terms import TERMS
|
||||||
|
|
||||||
|
|
||||||
def validate_in_past(value):
|
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')
|
raise ValidationError('Enter a date in the past')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,11 @@
|
||||||
|
|
||||||
<form id="assignment-form" action="." method="post" class="mw7">
|
<form id="assignment-form" action="." method="post" class="mw7">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
|
{% if form.errors %}
|
||||||
|
<p class="dark-red bg-washed-red pa2 ba b--red br1">Please review the errors below.</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
|
|
||||||
<p><em>Please be aware that your employer or a contractor may own the rights in your work by virtue of their employment of you or by explicit transfer of ownership in an agreement. We recommend you review any relevant agreements or consult with a lawyer if you are not sure.</em></p>
|
<p><em>Please be aware that your employer or a contractor may own the rights in your work by virtue of their employment of you or by explicit transfer of ownership in an agreement. We recommend you review any relevant agreements or consult with a lawyer if you are not sure.</em></p>
|
||||||
|
|
Loading…
Reference in a new issue