forms.py 2.53 KB
Newer Older
Daniel W Bond's avatar
Daniel W Bond committed
1
2
3
4
5
6
from django import forms
from django.db import models
from django.core.exceptions import ValidationError
from django.forms import ModelForm, Select
from trajectories.models import Trajectory

Daniel W Bond's avatar
Daniel W Bond committed
7
8
9
10
11
12
13
14
15
16
17
18
19
from haystack.forms import SearchForm

class StyledSeachForm( SearchForm ):
    q = forms.CharField(
        required = False,
	label = 'Search',
	widget = forms.TextInput(attrs={
	    'class' : 'form-control',
	    'placeholder' : 'Search',
	    'autofocus' : 'autofocus',
        }),
    )

Daniel W Bond's avatar
Daniel W Bond committed
20
21
22
23
24
25
26
27
28
29
30
31
# class SelectYourCourses( ModelForm ):

    # class Meta:
        # models = Course

	# widgets = {
	    # department abbreviation

	    # course number

	    # name

Daniel W Bond's avatar
Daniel W Bond committed
32
33
34
35
class NewTrajectoryForm( ModelForm ):
    # def __init__(self, *args, **kwargs):

    class Meta:
36
        model = Program
37
        fields = ('name',
Daniel W Bond's avatar
Daniel W Bond committed
38
        )
Daniel W Bond's avatar
Daniel W Bond committed
39
        exclude = ('courseReqs', 'created', 'last_modified', 'catalogYear',
40
	    'isCompleted', 'programType', 'degreeType',
Daniel W Bond's avatar
Daniel W Bond committed
41
        )
42
43
44
45
        labels = {
            'name' : 'Select your Majors'
            #'name' : 'Select your Minor'
        }
Daniel W Bond's avatar
Daniel W Bond committed
46
        widgets = {
47
            # I know you can't actually have it assigned twice...
Daniel W Bond's avatar
Daniel W Bond committed
48
49
50
51
52
53
	    # name of major(s)
            'name' : TextInput(attrs={
	        'class' : 'form-control',
		'placeholder' : 'Government and International Politics',
	    }),
            # name of minor(s)
54
55
56
57
            'name' : TextInput(attrs={
                'class' : 'form-control',
                'placeholder' = 'Software Engineering',
            }),
Daniel W Bond's avatar
Daniel W Bond committed
58
        }
59
60
61

# class CreateTrajectoryForm ( ModelForm ):

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class StudentInfoForm( ModelForm ):
    # def __init__(self, *args, **kwargs):

    class Meta:
        model = Student
        fields = ('completedCourses', 'isHonors', 'semester',
        )
        exclude = ('user', 'trajectories',
        )
        labels = {
            'completedCourses' : 'Completed Courses',
            'isHonors' : 'Are you in the Honors College?',
            'semester' : 'Semester',
        }
        widgets = {
            # this should be done above, but I don't know how that works with the models ^^^
            'completedCourses' : TextInput(attrs={
                'class' : 'form-control',
                'placeholder' = 'Type in courses you\'ve taken',
            }),
            # is the student honors?
            'isHonors' : CheckboxInput(attrs={
                'class' = 'form-control',
            }),

            # semester
            'semester' : TextInput(attrs={
                'class' : 'form-control',
                'placeholder' : 'What year are you?'
            }),
        }