""" catalog forms """ from django.forms import ModelForm, fields, Textarea, TextInput, SelectMultiple from catalog.models import Book, Map, Movie, Person, Subscription, ZipCode class BookForm(ModelForm): long_description = fields.TextInput(attrs={"class": "test"}) def __init__(self, *args, **kwargs): super(BookForm, self).__init__(*args, **kwargs) self.fields['authors'].queryset = Person.objects.active() class Meta: # need to do it this way to get the order of the fields we want. fields = ('title', 'subtitle', 'long_description', 'synopsis', 'image', 'price', 'shipping_cost', 'shipping_cost_multiple', 'sku', 'featured', 'tax_free', 'authors', 'editors', 'illustrator', 'publisher', 'printer', 'publish_date', 'edition', 'features', 'dimensions', 'pages', 'isbn', 'library_of_congress_number', 'genre') model = Book widgets = { 'title': TextInput(attrs={ 'class': 'input-xxlarge span7'}), 'long_description': Textarea(attrs={ 'class': 'input-xxlarge span7'}), 'synopsis': Textarea(attrs={ 'class': 'input-xxlarge span7', 'rows': 3}), 'subtitle': TextInput(attrs={ 'class': 'input-xxlarge span7'}), 'editors': TextInput(attrs={ 'class': 'input-xxlarge span7'}), 'features': TextInput(attrs={ 'class': 'input-xxlarge span7'}), 'authors': SelectMultiple(attrs={ 'class': 'input-xlarge span5'}), } class MapForm(ModelForm): class Meta: exclude = ('created', 'created_by', 'last_updated', 'last_updated_by', 'subclass_type', 'deleted') model = Map widgets = { 'title': TextInput(attrs={ 'class': 'input-xxlarge span7'}), 'long_description': Textarea(attrs={ 'class': 'input-xxlarge span7'}), 'synopsis': Textarea(attrs={ 'class': 'input-xxlarge span7', 'rows': 3}), } class MovieForm(ModelForm): class Meta: exclude = ('created', 'created_by', 'last_updated', 'last_updated_by', 'subclass_type', 'deleted') model = Movie widgets = { 'title': TextInput(attrs={ 'class': 'input-xxlarge span7'}), 'long_description': Textarea(attrs={ 'class': 'input-xxlarge span7'}), 'synopsis': Textarea(attrs={ 'class': 'input-xxlarge span7', 'rows': 3}), 'music': Textarea(attrs={ 'class': 'input-xxlarge span7', 'rows': 2}), } class SubscriptionForm(ModelForm): class Meta: exclude = ('created', 'created_by', 'last_updated', 'last_updated_by', 'subclass_type', 'deleted') model = Subscription widgets = { 'title': TextInput(attrs={ 'class': 'input-xxlarge span7'}), 'long_description': Textarea(attrs={ 'class': 'input-xxlarge span7'}), 'synopsis': Textarea(attrs={ 'class': 'input-xxlarge span7', 'rows': 3}), } class PostalCodeForm(ModelForm): class Meta: exclude = ('created', 'created_by', 'last_updated', 'last_updated_by', 'subclass_type', 'deleted') model = ZipCode class PersonForm(ModelForm): class Meta: exclude = ('created', 'created_by', 'last_updated', 'last_updated_by', 'subclass_type', 'deleted', 'slug') model = Person widgets = { 'name': TextInput(attrs={ 'class': 'input-xxlarge span7'}), 'description': Textarea(attrs={ 'class': 'input-xxlarge span7'}), 'title': TextInput(attrs={ 'class': 'input-xxlarge span7'}), }