forms.py 3.6 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
# class SelectYourCourses( ModelForm ):

22
23
    # needs to connect with a Student's completedCourses field

Daniel W Bond's avatar
Daniel W Bond committed
24
25
26
27
28
29
30
31
32
    # class Meta:
        # models = Course

	# widgets = {
	    # department abbreviation

	    # course number

	    # name
33
        # }
Daniel W Bond's avatar
Daniel W Bond committed
34

Daniel W Bond's avatar
Daniel W Bond committed
35
36
37
38
class NewTrajectoryForm( ModelForm ):
    # def __init__(self, *args, **kwargs):

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

# class CreateTrajectoryForm ( ModelForm ):
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
    # def __init__(self, *args, **kwargs):

# the user selects the courses they are allowed to take but
# this needs to be presented in a dramatically different way than
# just some silly dropdown
    class Meta:
        model = Trajectory
        fields = ('name', 'courses',
        )
        exclude = ('trajectorySlug', 'previousCourses', 'whichPrograms',
        'isPublic', 'semester'
        )
        labels = (
        # the courses need to be sorted by their associated program, so idk labels
        )
        widgets = {
            # name of the trajectory
            'name' : TextInput(attrs={
                'class' : 'form-control',
                # this shouldn't change often
                'placeholder' = 'Name Your Trajectory',
            }),
            # course names... this isn't probably right
            # users select and save tiles...
            'name' : TextInput(attrs={
                'class' : 'form-control',
                'placeholder' = 'Name Your Trajectory',
            }),
        }
93

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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',
112
                'placeholder' : 'Type in courses you\'ve taken',
113
114
115
            }),
            # is the student honors?
            'isHonors' : CheckboxInput(attrs={
116
                'class' : 'form-control',
117
118
119
120
121
122
123
124
            }),

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