Commit 799f12e5 authored by Luuk Scholten's avatar Luuk Scholten
Browse files

Set today as exam date by default in upload exam form

parent f768a077
......@@ -6,7 +6,10 @@ from .models import Course, Exam, Summary
class AddExamForm(ModelForm):
exam_date = DateField(widget=SelectDateWidget())
exam_date = DateField(
widget=SelectDateWidget(),
initial=datetime.date.today
)
course = ModelChoiceField(
queryset=Course.objects.order_by('name_' + settings.LANGUAGE_CODE),
empty_label=None)
......
import itertools
import os
from datetime import datetime
from datetime import datetime, date
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, render
......@@ -81,13 +81,12 @@ def submit_exam(request, id=None):
obj.save()
form = AddExamForm()
form.exam_date = datetime.now()
else:
obj = Exam()
obj.exam_date = date.today()
if id is not None:
obj.course = Course.objects.get(id=id)
form = AddExamForm(instance=obj)
form.exam_date = datetime.now()
return render(request, 'education/add_exam.html',
{'form': form, 'saved': saved})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment