This commit is contained in:
Les Orchard 2012-04-15 21:31:52 -04:00
Родитель ec3a2d1f4d
Коммит 4826730c90
1 изменённых файлов: 25 добавлений и 1 удалений

Просмотреть файл

@ -5,6 +5,8 @@ from django.conf import settings
from django import forms
from django.db import models
from django.contrib.auth.models import User, AnonymousUser
from django.forms.fields import FileField
from django.forms.widgets import ClearableFileInput
try:
from tower import ugettext_lazy as _
@ -15,16 +17,38 @@ from badger.models import (Award)
from badger.forms import (MyModelForm, MyForm, MultiEmailField)
from badger_multiplayer.models import (Badge, Nomination)
try:
from taggit.managers import TaggableManager
except:
TaggableManager = None
class BadgeEditForm(MyModelForm):
class Meta:
model = Badge
fields = ('title', 'image', 'description', 'unique',)
fields = ('title', 'image', 'description', 'tags', 'unique',)
required_css_class = "required"
error_css_class = "error"
def __init__(self, *args, **kwargs):
super(BadgeEditForm, self).__init__(*args, **kwargs)
# HACK: inject new templates into the image field, monkeypatched
# without creating a subclass
self.fields['image'].widget.template_with_clear = u'''
<p class="clear">%(clear)s
<label for="%(clear_checkbox_id)s">%(clear_checkbox_label)s</label></p>
'''
self.fields['image'].widget.template_with_initial = u'''
<div class="clearablefileinput">
<p>%(initial_text)s: %(initial)s</p>
%(clear_template)s
<p>%(input_text)s: %(input)s</p>
</div>
'''
class BadgeNewForm(BadgeEditForm):