コード例 #1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        SUBJECTTYPE = Functions.subjectType()
        self.fields["subjecttype"] = forms.ChoiceField(
            label='Subject Type',
            choices=SUBJECTTYPE,
            required=True,
            widget=forms.Select(attrs={'class': 'form-control p-input'}))

        SEMESTER = Functions.getSemestersList()
        self.fields["semester"] = forms.ChoiceField(
            label='Semester',
            choices=SEMESTER,
            required=Functions.getSemesterReq(),
            widget=forms.Select(attrs={'class': 'form-control p-input'}))

        DEPARTMENTS = Functions.getDepartmentList()
        self.fields["departments"] = forms.MultipleChoiceField(
            label='Department(s)',
            choices=DEPARTMENTS,
            required=True,
            widget=forms.SelectMultiple(
                attrs={
                    'class': 'form-control p-input populate-drop',
                    'singular': '0',
                    'data-source': 'department',
                    'data-link': 'lecturers',
                    'data-live-search': 'true',
                }))

        LECTURERS = Functions.getLecturerList(
        )  #Functions.getLectConfirm(Functions.getLecturerList(), Course)
        self.fields["lecturers"] = forms.MultipleChoiceField(
            label='Lecturer(s)',
            choices=LECTURERS,
            required=False,
            widget=forms.SelectMultiple(attrs={
                'class': 'form-control p-input',
                'data-live-search': 'true'
            }))
コード例 #2
0
ファイル: models.py プロジェクト: oluwatobimaxwell/timetabler
from django.db import models
from multiselectfield import MultiSelectField
from admin.models import Functions

DEPARTMENTS = Functions.getDepartmentList()
LECTURERS = Functions.getLecturerList()


class Course(models.Model):

    code = models.CharField(max_length=15, unique=True)
    name = models.CharField(max_length=255)
    coursehourperweek = models.IntegerField(default=2)
    semester = models.IntegerField(default=0)
    subjecttype = models.IntegerField(default=0)
    departments = MultiSelectField(choices=DEPARTMENTS, max_length=2048)
    lecturers = MultiSelectField(choices=LECTURERS, max_length=2048)

    def __str__(self):
        return self.name

    def lecturer(self):
        return self.lecturers

    def contacthour(self):
        return self.coursehourperweek