-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforms.py
More file actions
40 lines (31 loc) · 1.33 KB
/
forms.py
File metadata and controls
40 lines (31 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from django import forms
from django.contrib.auth.models import User
from tvshow.models import Episode, Season, Show
class ShowForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ShowForm, self).__init__(*args, **kwargs)
self.fields['plot'].widget.attrs['cols'] = 40
self.fields['plot'].widget.attrs['rows'] = 3
class Meta:
model = Show
exclude = ('slug', 'pub_date')
class SeasonForm(forms.ModelForm):
no = forms.IntegerField(min_value=0, max_value=50)
def __init__(self, slug, *args, **kwargs):
super(SeasonForm, self).__init__(*args,**kwargs)
class Meta:
model = Season
exclude = ('show', 'pub_date')
class EpisodeForm(forms.ModelForm):
no = forms.IntegerField(min_value=1, max_value=50)
def __init__(self, slug, *args, **kwargs):
super(EpisodeForm, self).__init__(*args,**kwargs)
self.fields['season'].queryset = Season.objects.filter(show__slug=slug)
class Meta:
model = Episode
exclude = ('show', 'author', 'pub_date', 'status', 'slug')
class ContactForm(forms.Form):
subject = forms.CharField(max_length=100)
message = forms.CharField(widget=forms.Textarea)
sender = forms.EmailField()
cc_myself = forms.BooleanField(required=False)