Skip to content

Commit

Permalink
uni_form.helpers.formHelper or None object must be passed into uni_fo…
Browse files Browse the repository at this point in the history
…rm tag or a TypeError is thrown.
  • Loading branch information
pydanny committed Apr 7, 2010
1 parent b79c9be commit d758a38
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ For 0.8.0

* Improved internal documentation
* form methods generated by FormHelper are in lowercase (http:https://github.com/pydanny/django-uni-form/issues#issue/20)
* uni_form.helpers.formHelper or None object must be passed into uni_form tag or a TypeError is thrown.

For 0.7.0

Expand Down
4 changes: 0 additions & 4 deletions uni_form/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,6 @@ def set_form_action(self, action):
self._form_action = reverse(action)
except NoReverseMatch:
self._form_action = action
#msg = 'Your form action needs to be a named url defined in a urlconf file\n'
#msg += 'Your broken action is: %s\n' % action
#msg += 'NoReverseMatch: %s' % e
#raise FormHelpersException(msg)

# we set properties the old way because we want to support pre-2.6 python
form_action = property(get_form_action, set_form_action)
Expand Down
24 changes: 14 additions & 10 deletions uni_form/templatetags/uni_form_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from django.template.defaultfilters import slugify

from uni_form.helpers import FormHelper

register = template.Library()


Expand Down Expand Up @@ -32,17 +34,17 @@ def as_uni_field(field):
template = get_template('uni_form/field.html')
c = Context({'field':field})
return template.render(c)

@register.inclusion_tag("uni_form/includes.html", takes_context=True)
def uni_form_setup(context):
"""
Creates the <style> and <script> tags needed to initialize the uni-form.
Create a local uni-form/includes.html template if you want to customize how
these files are loaded.
these files are loaded.
"""
if 'MEDIA_URL' not in context:
context['MEDIA_URL'] = settings.MEDIA_URL
context['MEDIA_URL'] = settings.MEDIA_URL
return (context)

############################################################################
Expand All @@ -61,7 +63,7 @@ def namify(text):
So we just replaces hyphens with underscores.
"""
return slugify(text).replace('-','_')


class BasicNode(template.Node):
""" Basic Node object that we can rely on for Node objects in normal
Expand All @@ -79,6 +81,8 @@ def get_render(self, context):
helper = self.helper.resolve(context)
attrs = None
if helper:
if not isinstance(helper, FormHelper):
raise TypeError('helper object provided to uni_form tag must be a uni_form.helpers.FormHelper object or a None object.')
attrs = helper.get_attr()
form_class = ''
form_id = ''
Expand Down Expand Up @@ -115,7 +119,7 @@ def get_render(self, context):
}
c = Context(response_dict)
return c


##################################################################
#
Expand Down Expand Up @@ -149,10 +153,10 @@ def do_uni_form(parser, token):
helper = token.pop(1)
except IndexError:
helper = None


return UniFormNode(form, helper)

return UniFormNode(form, helper)


class UniFormNode(BasicNode):

Expand All @@ -162,7 +166,7 @@ def render(self, context):

template = get_template('uni_form/whole_uni_form.html')
return template.render(c)


#################################
# uni_form scripts
Expand All @@ -185,7 +189,7 @@ def uni_form_jquery(parser, token):
attrs = token.pop(1)
except IndexError:
attrs = None


return UniFormJqueryNode(form,attrs)

Expand Down

0 comments on commit d758a38

Please sign in to comment.