equal
deleted
inserted
replaced
41 """Render ReadOnlyInput widget as HTML. |
41 """Render ReadOnlyInput widget as HTML. |
42 """ |
42 """ |
43 attrs['readonly'] = 'readonly' |
43 attrs['readonly'] = 'readonly' |
44 attrs['class'] = 'plaintext' |
44 attrs['class'] = 'plaintext' |
45 return super(ReadOnlyInput, self).render(name, value, attrs) |
45 return super(ReadOnlyInput, self).render(name, value, attrs) |
46 |
|
47 |
|
48 class ReadOnlyBool(forms.widgets.Input): |
|
49 """Read only checkbox widget. |
|
50 """ |
|
51 input_type = 'text' |
|
52 |
|
53 def render(self, name, value, attrs=None): |
|
54 """Render ReadOnlyBool widget as HTML. |
|
55 |
|
56 Displays "text" field like ReadOnlyInput, but contents will be one of: |
|
57 * empty (no text at all, just a greyed-out box) if no answer at all |
|
58 * "True" (in the same greyed-out box) if True |
|
59 * "False" (in the same greyed-out box) if False |
|
60 """ |
|
61 attrs['readonly'] = 'readonly' |
|
62 return super(ReadOnlyBool, self).render(name, value, attrs) |
|
63 |
46 |
64 |
47 |
65 class TinyMCE(forms.widgets.Textarea): |
48 class TinyMCE(forms.widgets.Textarea): |
66 """TinyMCE widget. |
49 """TinyMCE widget. |
67 |
50 |
121 |
104 |
122 return safestring.mark_safe(self.TINY_MCE_HTML_FMT % |
105 return safestring.mark_safe(self.TINY_MCE_HTML_FMT % |
123 {'attrs': widgets.flatatt(final_attrs), |
106 {'attrs': widgets.flatatt(final_attrs), |
124 'value': html.escape(value), |
107 'value': html.escape(value), |
125 'settings_json': mce_json}) |
108 'settings_json': mce_json}) |
|
109 |
|
110 |
|
111 class ReferenceField(forms.CharField): |
|
112 """Widget for selecting a reference to an Entity. |
|
113 """ |
|
114 |
|
115 def __init__(self, reference_url, filter=None, |
|
116 *args, **kwargs): |
|
117 """Initializes the widget with the specified url and filter. |
|
118 """ |
|
119 |
|
120 self.rf = {} |
|
121 self.rf['reference_url'] = reference_url |
|
122 self.rf['filter'] = filter if filter else [] |
|
123 super(ReferenceField, self).__init__(*args, **kwargs) |