# HG changeset patch # User Sverre Rabbelier # Date 1233877599 0 # Node ID b24796279fb92fdd733c349ff36827c8805f6c9d # Parent 38afecddfbed8fa5044bba95a91540c5d1b239f9 Added a ReferenceField widget Also removed the unused ReadOnlyBool widget (as we now have a properlyworking ReadOnly widget). Patch by: Sverre Rabbelier diff -r 38afecddfbed -r b24796279fb9 app/soc/views/helper/widgets.py --- a/app/soc/views/helper/widgets.py Thu Feb 05 23:43:52 2009 +0000 +++ b/app/soc/views/helper/widgets.py Thu Feb 05 23:46:39 2009 +0000 @@ -45,23 +45,6 @@ return super(ReadOnlyInput, self).render(name, value, attrs) -class ReadOnlyBool(forms.widgets.Input): - """Read only checkbox widget. - """ - input_type = 'text' - - def render(self, name, value, attrs=None): - """Render ReadOnlyBool widget as HTML. - - Displays "text" field like ReadOnlyInput, but contents will be one of: - * empty (no text at all, just a greyed-out box) if no answer at all - * "True" (in the same greyed-out box) if True - * "False" (in the same greyed-out box) if False - """ - attrs['readonly'] = 'readonly' - return super(ReadOnlyBool, self).render(name, value, attrs) - - class TinyMCE(forms.widgets.Textarea): """TinyMCE widget. @@ -123,3 +106,18 @@ {'attrs': widgets.flatatt(final_attrs), 'value': html.escape(value), 'settings_json': mce_json}) + + +class ReferenceField(forms.CharField): + """Widget for selecting a reference to an Entity. + """ + + def __init__(self, reference_url, filter=None, + *args, **kwargs): + """Initializes the widget with the specified url and filter. + """ + + self.rf = {} + self.rf['reference_url'] = reference_url + self.rf['filter'] = filter if filter else [] + super(ReferenceField, self).__init__(*args, **kwargs)