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' }))
from django.db import models from multiselectfield import MultiSelectField from admin.models import Functions # Create your models here. LEVELS = Functions.getStudentLevels() DAYS = Functions.getDaysAvailable() FACULTIES = Functions.getFacultyList() DEPARTMENTS = Functions.getDepartmentList() class Venue(models.Model): code = models.CharField(max_length=10, unique=True) name = models.CharField(max_length=10, unique=True) capacity = models.IntegerField(default=50) type = models.IntegerField(default=0) reservedFaculty = MultiSelectField(choices=FACULTIES, max_length=2048) reservedDepartment = MultiSelectField(choices=DEPARTMENTS, max_length=2048) reservedLevel = MultiSelectField(choices=LEVELS, max_length=2048) reservedDays = MultiSelectField(choices=DAYS, max_length=2048)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) newid = Functions.getNewId(Venue, 'VEN', "{:03}") self.fields["code"].initial = newid CAPACITY = Functions.getVenueTypes() self.fields["type"] = forms.ChoiceField( label='Type', choices=CAPACITY, required=False, widget=forms.Select(attrs={'class': 'form-control p-input'})) LEVELS = Functions.getStudentLevels() AVAILABLEDAYS = Functions.getDaysAvailable() FACULTIES = Functions.getFacultyList() DEPARTMENTS = Functions.getDepartmentList() self.fields["reservedDays"] = forms.MultipleChoiceField( label='Days', choices=AVAILABLEDAYS, widget=forms.SelectMultiple( attrs={ 'class': 'selectpicker w-100', 'multiple': 'multiple', 'style': 'width:100%', })) self.fields["reservedLevel"] = forms.MultipleChoiceField( label='Levels', choices=LEVELS, widget=forms.SelectMultiple( attrs={ 'class': 'selectpicker w-100', 'multiple': 'multiple', 'style': 'width:100%', })) self.fields["reservedFaculty"] = forms.MultipleChoiceField( label='Faculties', choices=FACULTIES, widget=forms.SelectMultiple( attrs={ 'class': 'selectpicker w-100 populate-drop', 'multiple': 'multiple', 'data-live-search': 'true', 'style': 'width:100%', 'data-source': 'faculty', 'data-link': 'reservedDepartment', 'singular': '0', })) self.fields["reservedDepartment"] = forms.MultipleChoiceField( label='Departments', choices=DEPARTMENTS, widget=forms.SelectMultiple( attrs={ 'class': 'selectpicker w-100', 'multiple': 'multiple', 'data-live-search': 'true', 'style': 'width:100%', }))