forms.py 1.75 KB
Newer Older
Ben Waters's avatar
Ben Waters committed
1
import floppyforms as forms
Daniel W Bond's avatar
Daniel W Bond committed
2 3 4 5 6
from django.db import models
from django.core.exceptions import ValidationError
from mainapp.models import Student, Major, Minor, GenEd

# form on new page
Ben Waters's avatar
what?  
Ben Waters committed
7
class StartTrajectoryForm(forms.Form):
Ben Waters's avatar
Ben Waters committed
8
    majors = forms.ChoiceField(widget=forms.SelectMultiple,choices=[(obj.id, obj.name) for obj in
9
    Major.objects.all()])
Ben Waters's avatar
Ben Waters committed
10
    minors = forms.ChoiceField(widget=forms.SelectMultiple,choices=[(obj.id, obj.name) for obj in
11
    Minor.objects.all()])
Ben Waters's avatar
Ben Waters committed
12

Ben Waters's avatar
Ben Waters committed
13 14 15
class StudentForm(forms.ModelForm):
    class Meta:
        model = Student
Ben Waters's avatar
Ben Waters committed
16
'''
Ben Waters's avatar
Ben Waters committed
17
class SelectMajorForm(forms.ModelForm):
Daniel W Bond's avatar
Daniel W Bond committed
18 19
    class Meta:
        model = Major
Ben Waters's avatar
Ben Waters committed
20 21
        fields = ['name', ]
        exclude = ['slug', 'description', 'courses', 'gened', 'concentration',]
Daniel W Bond's avatar
Daniel W Bond committed
22
        labels = {
Ben Waters's avatar
Ben Waters committed
23
            'major' : 'Major',
Daniel W Bond's avatar
Daniel W Bond committed
24 25
        }
        widgets = {
Ben Waters's avatar
Ben Waters committed
26
            'major':forms.CharField(),
27 28
        }

Ben Waters's avatar
Ben Waters committed
29 30 31
class SelectMinorForm(forms.ModelForm):
    class Meta:
        model = Minor
32 33 34
        fields = ['name', ]
        exclude = ['slug', 'description', 'courses', ]
        labels = {
Ben Waters's avatar
Ben Waters committed
35
            'minor' : 'Minor',
36 37
        }
        widgets = {
Ben Waters's avatar
Ben Waters committed
38
            'minor':forms.CharField()
Daniel W Bond's avatar
Daniel W Bond committed
39 40 41 42 43 44
        }

# form on build page
class BuildSemesterForm( ModelForm ):
    class Meta:
        model = Semester
45 46
        fields = ['courses', ]
        exclude = ['number', 'user', ]
Daniel W Bond's avatar
Daniel W Bond committed
47
        labels = {
48
            'courses' : 'Possible Courses',
Daniel W Bond's avatar
Daniel W Bond committed
49 50
        }
        widgets = {
51 52 53 54
            'courses':forms.CheckboxSelectMultiple(attrs={
                'class':'form-control',
                'placeholder':'',
            }),
Daniel W Bond's avatar
Daniel W Bond committed
55 56 57 58 59 60
        }

# form on user page
class StudentUpdateForm( ModelForm ):
    class Meta:
        model = Student
61
        fields = [ ]
Daniel W Bond's avatar
Daniel W Bond committed
62 63 64 65 66 67
        exclude = (
        )
        labels = {
        }
        widgets = {
        }
Ben Waters's avatar
Ben Waters committed
68
'''