Dynastie/dynastie/forms.py
Gregory Soutade 4b642fa48a Fix some bugs:
* Don't use cached objects if file has been removed
	* Replace subblock node with all of this nodes instead of appending them at the end of parent (respect order)
	* Disable Post cache cause it generates some random errors
	* Don't forget to update cur page number, even if Post creation has failed
2020-03-20 16:55:23 +01:00

66 lines
2.2 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
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()]
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')