article / article / forms.py

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

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

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

    class Media:
        js = (
            '//happyherb-photos.s3.amazonaws.com/admin/grappelli/jquery/jquery-1.6.2.min.js',
            '//photos.happyherbivore.com/admin/redactor/redactor-802v1.js',
            '//photos.happyherbivore.com/admin/redactor/redactor_init-v2.js',
            )
        css = {
            "all" : ('//photos.happyherbivore.com/admin/redactor/802/redactor.css',
                '//photos.happyherbivore.com/admin/redactor/custom_redactor-v0.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/redactor-802v1.js',
            '//photos.happyherbivore.com/admin/redactor/redactor_init-v2.js',
            )
        css = {
            "all" : ('//photos.happyherbivore.com/admin/redactor/802/redactor.css',
                '//photos.happyherbivore.com/admin/redactor/custom_redactor-v0.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/redactor-802v1.js',
            '//photos.happyherbivore.com/admin/redactor/redactor_init-v2.js',
            )
        css = {
            "all" : ('//photos.happyherbivore.com/admin/redactor/802/redactor.css',
                '//photos.happyherbivore.com/admin/redactor/custom_redactor-v0.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):
    question = forms.CharField(widget=forms.TextInput(attrs={'ng-model': 'userq'}))
    message = forms.CharField(widget=forms.Textarea(attrs={'class':'span5'}))
    name = forms.CharField()
    email = forms.EmailField()
    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.