Dynastie/dynastie/forms.py
2014-05-27 18:24:14 +02:00

64 lines
2.1 KiB
Python
Executable File

# -*- coding: utf-8 -*-
"""
Copyright 2012-2014 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', 'content_format')
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 DraftForm(PostForm):
class Meta:
model = Draft
exclude = ('title_slug', 'creation_date', 'modification_date', 'author', 'blog', 'tags', 'content_format', 'published')
class CategoryForm(ModelForm):
class Meta:
model = Category
exclude = ('parent', 'name_slug', 'blog')
class UserForm(ModelForm):
class Meta:
model = User
class CommentForm(ModelForm):
class Meta:
model = Comment
exclude = ('post', 'parent', 'date')
class TagForm(ModelForm):
class Meta:
model = Tag
exclude = ('blog', 'name_slug')