forms.py 827 Bytes
Newer Older
Jan's avatar
Jan committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from django.conf import settings
from django.forms import (
    ModelForm,
    DateField,
    SelectDateWidget,
    ModelChoiceField,
    ChoiceField
)

from .models import Exam, Summary, Course


class AddExamForm(ModelForm):
    exam_date = DateField(widget=SelectDateWidget())
    course = ModelChoiceField(
        queryset=Course.objects.order_by('name_' + settings.LANGUAGE_CODE),
        empty_label=None)
    type = ChoiceField(choices=Exam.EXAM_TYPES)

    class Meta:
        model = Exam
        fields = ('file', 'course', 'type', 'exam_date')


class AddSummaryForm(ModelForm):
    course = ModelChoiceField(
        queryset=Course.objects.order_by('name_' + settings.LANGUAGE_CODE),
        empty_label=None)

    class Meta:
        model = Summary
        fields = ('name', 'year', 'file', 'course', 'author')