# -*- 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 . """ from django.forms import ModelForm from django import forms from dynastie.models import * class BlogForm(ModelForm): class Meta: model = Blog exclude = () 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', 'post_type') 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()] self.fields['language'].choices = [(lang.id, lang.name) for lang in Language.objects.all()] class DraftForm(PostForm): class Meta: model = Draft exclude = ('title_slug', 'creation_date', 'modification_date', 'author', 'blog', 'tags', 'content_format', 'published', 'post_type') class CategoryForm(ModelForm): class Meta: model = Category exclude = ('parent', 'name_slug', 'blog') class UserForm(ModelForm): class Meta: model = User exclude = ('groups', 'user_permissions', 'date_joined') class CommentForm(ModelForm): class Meta: model = Comment exclude = ('post', 'parent', 'date') class TagForm(ModelForm): class Meta: model = Tag exclude = ('blog', 'name_slug')