import re
import textwrap
from django import forms
from django.utils.safestring import mark_safe
from django.utils.encoding import force_text
class ShowTextWidget(forms.Widget):
def __init__(self, *args, **kwargs):
for kwarg in ['bold', 'warning', 'hidden']:
setattr(self, kwarg, kwargs.pop(kwarg, False))
super(ShowTextWidget, self).__init__(*args, **kwargs)
def render(self, name, value, attrs):
value = force_text(value)
if value is None:
return ''
if hasattr(self, 'initial'):
value = self.initial
if self.bold:
final_value = u'%s' % (value)
else:
final_value = '
'.join(value.split('\n'))
if self.warning:
final_value = (
u'
" + siteoptions[this.options[this.selectedIndex].value] + "
" );""".format(target=target, help_text=str(help_text)) )