# HG changeset patch # User Sverre Rabbelier # Date 1234709705 0 # Node ID 4b8546a3b20ccf3278fa8c3b896e27807366edee # Parent 77931c5841996ed488e7c208139f34d4d96ac27a Add an AdminForm that renders all fields as PTW's Patch by: Sverre Rabbelier diff -r 77931c584199 -r 4b8546a3b20c app/soc/views/helper/params.py --- a/app/soc/views/helper/params.py Sun Feb 15 14:54:42 2009 +0000 +++ b/app/soc/views/helper/params.py Sun Feb 15 14:55:05 2009 +0000 @@ -32,6 +32,7 @@ from soc.views.helper import access from soc.views.helper import dynaform from soc.views.helper import redirects +from soc.views.helper import widgets DEF_LIST_DESCRIPTION_FMT = ugettext( @@ -241,6 +242,9 @@ if not 'edit_form' in params: params['edit_form'] = getEditForm(params, params['create_form']) + if not 'admin_form' in params: + params['admin_form'] = getAdminForm(params['edit_form']) + if not 'key_fields_pattern' in params: params['key_fields_pattern'] = getKeyFieldsPattern(params) @@ -300,6 +304,24 @@ return edit_form +def getAdminForm(base_form): + """Constructs a new AdminForm from base_form. + """ + + # extend to do a proper copy + admin_form = dynaform.extendDynaForm( + dynaform = base_form, + ) + + # replace all widgets with PTW's + for key, value in admin_form.base_fields.iteritems(): + if not isinstance(value, forms.fields.Field): + continue + value.widget = widgets.PlainTextWidget() + + return admin_form + + def getKeyFieldsPattern(params): """Returns the Django pattern for this View's entity. """