Dynastie/forms.py
Grégory Soutadé e795fa1af6 New version 0.2
Add coding information in all py files
Add dyn:post_url and dyn:post_full_url for replace directive (doesn't prepend http://)
Escape double quotes in metas tag
Add HTML5 markup for blog.soutade.fr
Add ChangeLog
2013-02-09 08:55:06 +01:00

60 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
"""
Copyright 2012-2013 Grégory Soutadé
This file is part of Dynastie.
Dynastie is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dynastie is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Dynastie. If not, see <http://www.gnu.org/licenses/>.
"""
from django.forms import ModelForm
from django import forms
from dynastie.models import *
class BlogForm(ModelForm):
class Meta:
model = Blog
class PostForm(ModelForm):
description = forms.CharField(widget=forms.Textarea(attrs={'rows':'5', 'cols':'50'}), required=False)
keywords = forms.CharField(widget=forms.Textarea(attrs={'rows':'2', 'cols':'50'}), required=False)
text_tags = forms.CharField(widget=forms.Textarea(attrs={'rows':'2', 'cols':'50'}), required=False)
class Meta:
model = Post
exclude = ('title_slug', 'creation_date', 'modification_date', 'author', 'blog', 'tags')
def __init__(self, *args, **kwargs):
super(PostForm, self).__init__(*args, **kwargs)
self.fields['category'].choices = [(cat.id, cat.name) for cat in Category.objects.all()]
class CategoryForm(ModelForm):
class Meta:
model = Category
exclude = ('parent', 'name_slug', 'blog')
class UserForm(ModelForm):
class Meta:
model = User
exclude = ('is_staff', 'is_active', 'last_login', 'last_joined', 'user_permissions', 'groups', 'date_joined', 'password')
class CommentForm(ModelForm):
class Meta:
model = Comment
exclude = ('post', 'parent', 'date')
class TagForm(ModelForm):
class Meta:
model = Tag
exclude = ('blog', 'name_slug')