Skip to content

Commit

Permalink
[1696][controllers] Bug fix: maintain backwards compatibility with ol…
Browse files Browse the repository at this point in the history
…d way of creating custom forms
  • Loading branch information
John Glover committed Jan 23, 2012
1 parent 7088b1f commit 214792d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ckan/controllers/package.py
Expand Up @@ -454,8 +454,13 @@ def new(self, data=None, errors=None, error_summary=None):
vars = {'data': data, 'errors': errors, 'error_summary': error_summary}

self._setup_template_variables(context, {'id': id})
c.form = render(self._package_form(package_type=package_type), extra_vars=vars)

# TODO: This check is to maintain backwards compatibility the old way of creating
# custom forms. This behaviour is now deprecated.
if hasattr(self, 'package_form'):
c.form = render(self.package_form, extra_vars=vars)
else:
c.form = render(self._package_form(package_type=package_type), extra_vars=vars)
return render('package/new.html')


Expand Down Expand Up @@ -496,7 +501,12 @@ def edit(self, id, data=None, errors=None, error_summary=None):

self._setup_template_variables(context, {'id': id}, package_type=package_type)

c.form = render(self._package_form(package_type=package_type), extra_vars=vars)
# TODO: This check is to maintain backwards compatibility the old way of creating
# custom forms. This behaviour is now deprecated.
if hasattr(self, 'package_form'):
c.form = render(self.package_form, extra_vars=vars)
else:
c.form = render(self._package_form(package_type=package_type), extra_vars=vars)
return render('package/edit.html')

def read_ajax(self, id, revision=None):
Expand Down

0 comments on commit 214792d

Please sign in to comment.