2013-02-09 08:55:06 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2013-02-07 18:50:54 +01:00
|
|
|
"""
|
|
|
|
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/>.
|
|
|
|
"""
|
2012-07-08 16:23:39 +02:00
|
|
|
from django.forms import ModelForm
|
2012-11-08 21:23:30 +01:00
|
|
|
from django import forms
|
2012-07-08 16:23:39 +02:00
|
|
|
from dynastie.models import *
|
|
|
|
|
|
|
|
class BlogForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Blog
|
|
|
|
|
2012-08-28 09:09:14 +02:00
|
|
|
class PostForm(ModelForm):
|
2012-11-08 21:23:30 +01:00
|
|
|
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)
|
|
|
|
|
2012-07-08 16:23:39 +02:00
|
|
|
class Meta:
|
2012-08-28 09:09:14 +02:00
|
|
|
model = Post
|
2012-09-08 12:35:52 +02:00
|
|
|
exclude = ('title_slug', 'creation_date', 'modification_date', 'author', 'blog', 'tags')
|
2012-07-08 16:23:39 +02:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
2012-08-28 09:09:14 +02:00
|
|
|
super(PostForm, self).__init__(*args, **kwargs)
|
2012-07-08 16:23:39 +02:00
|
|
|
self.fields['category'].choices = [(cat.id, cat.name) for cat in Category.objects.all()]
|
|
|
|
|
|
|
|
class CategoryForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Category
|
2012-10-09 20:47:12 +02:00
|
|
|
exclude = ('parent', 'name_slug', 'blog')
|
2012-07-08 16:23:39 +02:00
|
|
|
|
|
|
|
class UserForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = User
|
2012-12-24 16:34:30 +01:00
|
|
|
exclude = ('is_staff', 'is_active', 'last_login', 'last_joined', 'user_permissions', 'groups', 'date_joined', 'password')
|
2012-10-04 21:49:33 +02:00
|
|
|
|
|
|
|
class CommentForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Comment
|
|
|
|
exclude = ('post', 'parent', 'date')
|
2012-11-08 21:23:30 +01:00
|
|
|
|
|
|
|
class TagForm(ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Tag
|
|
|
|
exclude = ('blog', 'name_slug')
|