Skip to content

Commit

Permalink
doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivo van der Wijk committed Apr 7, 2014
1 parent c070ca8 commit 948b199
Show file tree
Hide file tree
Showing 11 changed files with 1,438 additions and 32 deletions.
15 changes: 5 additions & 10 deletions wheelcms_axle/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from taggit.utils import parse_tags
from django.utils.safestring import mark_safe
from django.forms.util import flatatt

class ParentField(forms.Field):
def __init__(self, parenttype=None, *args, **kw):
Expand Down Expand Up @@ -54,11 +55,14 @@ class TagWidget(forms.TextInput):
to "quote" tags containing a space, something that our tagsManager
plugin can't handle wel.
"""
input_type = 'tag'
def render(self, name, value, attrs=None):
if value is not None and not isinstance(value, basestring):
value = ",".join(o.tag.name for o in value.select_related("tag"))

return super(TagWidget, self).render(name, value, attrs)
final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
# return mark_safe(u'<tags model="foo"></tags>')
return mark_safe(u'<tags model="[\'ivo\', \'bar\']" %s></tags>' % flatatt(final_attrs))

class SubcontentField(forms.MultipleChoiceField):
"""
Expand Down Expand Up @@ -161,15 +165,6 @@ def __init__(self, parent, node=None, attach=False, enlarge=True,
if 'description' in self.fields:
self.fields['description'].widget.attrs['rows'] = 4

if 'tags' in self.fields:
self.fields['tags'].widget.attrs['class'] = "tagManager"
self.fields['tags'].widget.attrs['data-role'] = "tagsinput"
self.fields['tags'].widget.attrs['data-provide'] = "typeahead"
## The placeholder is used to size the tag input, which will
## default to 1 if unspecified.
self.fields['tags'].widget.attrs['placeholder'] = " " * 30
self.fields['tags'].required = False

## workaround for https://code.djangoproject.com/ticket/21173
for patch_dt in ("publication", "expire", "created"):
if patch_dt in self.fields:
Expand Down
Loading

0 comments on commit 948b199

Please sign in to comment.