123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- """ 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"}),
- }
|