Source

article / article / forms.py

Full commit
from django import forms
from django.db.models import get_model
from django.contrib.flatpages.models import FlatPage
from django.contrib.flatpages.admin import FlatPageAdmin, FlatpageForm

from django_cloudi.widgets import CloudImages
#from widgets import WYMEditor
#from tinymce.widgets import TinyMCE

from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit, HTML, Layout
from crispy_forms.bootstrap import PrependedText

class PostAdminModelForm(forms.ModelForm):
    post_content = forms.CharField(widget=forms.Textarea(attrs={'class':'redactor','cols': 80, 'rows': 30}))
    #change_form_template = 'article/templates/admin_post_form.html'

    class Meta:
        model = get_model('article', 'post')

    class Media:
        js = (
            '//media.happyherbivore.com/grappelli/jquery/jquery-1.7.2.min.js',
            #'//happyherb-photos.s3.amazonaws.com/admin/grappelli/jquery/jquery-1.6.2.min.js',
            '//photos.happyherbivore.com/admin/redactor/811/redactor.min.js',
            '//photos.happyherbivore.com/admin/redactor/redactor_init-v2.js',
            )
        css = {
            "all" : ('//photos.happyherbivore.com/admin/redactor/811/redactor.css',
                '//photos.happyherbivore.com/admin/redactor/custom_redactor-v2.css')
            }

class RecipeAdminModelForm(forms.ModelForm):
    recipe_description = forms.CharField(widget=forms.Textarea(attrs={'class':'redactor','cols': 80, 'rows': 30}))
    recipe_instructions = forms.CharField(widget=forms.Textarea(attrs={'class':'redactor','cols': 80, 'rows': 30}))
    
    class Meta:
        model = get_model('article', 'recipe')   

    class Media:
        js = (
            '//happyherb-photos.s3.amazonaws.com/admin/grappelli/jquery/jquery-1.6.2.min.js',
            '//photos.happyherbivore.com/admin/redactor/811/redactor.min.js',
            '//photos.happyherbivore.com/admin/redactor/redactor_init-v2.js',
            )
        css = {
            "all" : ('//photos.happyherbivore.com/admin/redactor/811/redactor.css',
                '//photos.happyherbivore.com/admin/redactor/custom_redactor-v2.css')
            }

class FlatPagesAdminModelForm(FlatpageForm):
    content = forms.CharField(widget=forms.Textarea(attrs={'class':'redactor','cols': 80, 'rows': 30}))

    class Meta:
        model = FlatPage
        
    class Media:
        js = (
            '//happyherb-photos.s3.amazonaws.com/admin/grappelli/jquery/jquery-1.6.2.min.js',
            '//photos.happyherbivore.com/admin/redactor/811/redactor.min.js',
            '//photos.happyherbivore.com/admin/redactor/redactor_init-v2.js',
            )
        css = {
            "all" : ('//photos.happyherbivore.com/admin/redactor/811/redactor.css',
                '//photos.happyherbivore.com/admin/redactor/custom_redactor-v2.css')
            }

class RecipePhotosAdminForm(forms.ModelForm):
    url = forms.CharField(widget=CloudImages(attrs={'style':'width:400px;'}))    

    class Meta:
        model = get_model('article', 'recipephotos')

class RecipePhotosInlineForm(forms.ModelForm):
# Disabled because currently the js can't bind properly to multiple inputs.
#    url = forms.CharField(widget=CloudImages(attrs={'style':'max-width:400px;'}))    

    class Meta:
        model = get_model('article', 'recipephotos')


class ContactForm(forms.Form):
    message = forms.CharField(widget=forms.Textarea(attrs={'class':'span5', 'placeholder':"Type your message here..."}))
    name = forms.CharField()
    email = forms.EmailField()

    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_id = 'send-email'
        self.helper.form_class = 'send-email'
        self.helper.form_method = 'post'
        self.helper.form_action = '/about/contact/'
        
        self.helper.layout = Layout(
            HTML('<hr>'),
            HTML("<div class='contactlindsay'><p>Hiya Herbie!</p><p>Nothing lifts my spirits like your personal stories and I love answering your questions! I do, however, respond to over 3,400 emails every month. Can you do me a favor and search the FAQ or the site search before emailing me? Chances are I've already addressed your question on this site. Thank you!</p><p>- Lindsay (HH)</p></div>"),
            HTML('<hr>'),
            'message',
            PrependedText('name', '<i class="icon-user"></i>'),
            PrependedText('email', '<i class="icon-envelope"></i>'),
        )
        self.helper.add_input(Submit('submit-email', 'Submit'))

        super(ContactForm, self).__init__(*args, **kwargs)