Skip to content
This repository has been archived by the owner on Nov 16, 2017. It is now read-only.

Commit

Permalink
TemplatesAdminHook.contribute_to_form now gets template_path (so addi…
Browse files Browse the repository at this point in the history
…tional form_fields can depend on the template_path)
  • Loading branch information
peritus committed Feb 26, 2009
1 parent ce96099 commit e9db82e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion templatesadmin/edithooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def post_save(cls, request, form, template_path):
pass

@classmethod
def contribute_to_form(cls, form):
def contribute_to_form(cls, form, template_path):
return form

2 changes: 1 addition & 1 deletion templatesadmin/edithooks/dotbackupfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def pre_save(cls, request, form, template_path):
return "Backup \'%s.backup\' has been saved." % template_path

@classmethod
def contribute_to_form(cls):
def contribute_to_form(cls, template_path):
return dict(backup=forms.BooleanField(
label = _('Backup file before saving?'),
required = False,
Expand Down
2 changes: 1 addition & 1 deletion templatesadmin/edithooks/gitcommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def post_save(cls, request, form, template_path):
return stdout_value.rstrip()

@classmethod
def contribute_to_form(cls):
def contribute_to_form(cls, template_path):
return dict(commitmessage=forms.CharField(
widget=forms.TextInput(attrs={'size':'100'}),
label = _('Change message'),
Expand Down
2 changes: 1 addition & 1 deletion templatesadmin/edithooks/hgcommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def post_save(cls, request, form, template_path):
return "Template '%s' was committed succesfully into mercurial repository." % commit_file

@classmethod
def contribute_to_form(cls):
def contribute_to_form(cls, template_path):
return dict(commitmessage=forms.CharField(
widget=forms.TextInput(attrs={'size':'100'}),
label = _('Change message'),
Expand Down
4 changes: 2 additions & 2 deletions templatesadmin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def edit(request, path, template_name='templatesadmin/edit.html', base_form=Temp
if request.method == 'POST':
formclass = base_form
for hook in TEMPLATESADMIN_EDITHOOKS:
formclass.base_fields.update(hook.contribute_to_form())
formclass.base_fields.update(hook.contribute_to_form(template_path))

form = formclass(request.POST)
if form.is_valid():
Expand Down Expand Up @@ -200,7 +200,7 @@ def edit(request, path, template_name='templatesadmin/edit.html', base_form=Temp

formclass = TemplateForm
for hook in TEMPLATESADMIN_EDITHOOKS:
formclass.base_fields.update(hook.contribute_to_form())
formclass.base_fields.update(hook.contribute_to_form(template_path))

form = formclass(
initial={'content': template_file}
Expand Down

0 comments on commit e9db82e

Please sign in to comment.