start adding exam dates
This commit is contained in:
+31
-3
@@ -8,6 +8,9 @@ from django.forms import (
|
||||
HiddenInput,
|
||||
EmailField,
|
||||
IntegerField,
|
||||
DateField,
|
||||
SplitDateTimeField,
|
||||
SplitDateTimeWidget,
|
||||
)
|
||||
from django.forms import inlineformset_factory
|
||||
from atlas.models import CaseCollection
|
||||
@@ -79,6 +82,24 @@ class ExamFormMixin:
|
||||
required=False,
|
||||
queryset=user_user_group_queryset,
|
||||
)
|
||||
self.fields["start_date"] = SplitDateTimeField(
|
||||
widget=SplitDateTimeWidget(
|
||||
date_attrs={"type": "date", "class": "datepicker"},
|
||||
time_attrs={"type": "time", "class": "timepicker"},
|
||||
date_format="%Y-%m-%d",
|
||||
time_format="%H:%M",
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
self.fields["end_date"] = SplitDateTimeField(
|
||||
widget=SplitDateTimeWidget(
|
||||
date_attrs={"type": "date", "class": "datepicker"},
|
||||
time_attrs={"type": "time", "class": "timepicker"},
|
||||
date_format="%Y-%m-%d",
|
||||
time_format="%H:%M",
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
fields = [
|
||||
@@ -88,6 +109,9 @@ class ExamFormMixin:
|
||||
"authors_only",
|
||||
"exam_mode",
|
||||
"include_history",
|
||||
"start_date",
|
||||
"end_date",
|
||||
"restrict_to_dates",
|
||||
"active",
|
||||
"publish_results",
|
||||
"archive",
|
||||
@@ -96,6 +120,11 @@ class ExamFormMixin:
|
||||
# "author",
|
||||
]
|
||||
|
||||
# widgets = {
|
||||
# "start_date": TextInput(attrs={"type": "date"}),
|
||||
# "end_date": TextInput(attrs={"type": "date"}),
|
||||
# }
|
||||
|
||||
def save(self, commit=True):
|
||||
instance = ModelForm.save(self, False)
|
||||
instance.save()
|
||||
@@ -588,9 +617,7 @@ class ExamCollectionForm(ModelForm):
|
||||
self.fields[reverse_prop] = ModelMultipleChoiceField(
|
||||
required=False,
|
||||
queryset=exam_obj.objects.filter(archive=False),
|
||||
widget=FilteredSelectMultiple(
|
||||
verbose_name=name, is_stacked=False
|
||||
),
|
||||
widget=FilteredSelectMultiple(verbose_name=name, is_stacked=False),
|
||||
)
|
||||
|
||||
def save(self, commit=True):
|
||||
@@ -619,6 +646,7 @@ class ExamCollectionForm(ModelForm):
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
class ExamCollectionCloneForm(ModelForm):
|
||||
class Meta:
|
||||
model = ExamCollection
|
||||
|
||||
Reference in New Issue
Block a user