Changeset - 7374c9f91528
[Not reviewed]
0 2 0
Ben Sturmfels (bsturmfels) - 2 years ago 2021-12-16 23:54:47
ben@sturm.com.au
assignment: Accept current date anywhere on earth.
2 files changed with 10 insertions and 1 deletions:
0 comments (0 inline, 0 general)
www/conservancy/apps/assignment/forms.py
Show inline comments
 
import datetime
 

	
 
from django import forms
 
from django.core.validators import ValidationError
...
 
@@ -8,5 +10,7 @@ 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')
 

	
www/conservancy/templates/assignment/assignment_form.html
Show inline comments
...
 
@@ -13,4 +13,9 @@
 
    <form id="assignment-form" action="." method="post" class="mw7">
 
      {% 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 }}
 

	
0 comments (0 inline, 0 general)