X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/febc8df810701062ed45c129c0e30c504db28849..e25a52bd2e384683c99b6e57647b829dba3bf5a2:/forum/settings/forms.py diff --git a/forum/settings/forms.py b/forum/settings/forms.py index b4a93e6..3e3cc5a 100644 --- a/forum/settings/forms.py +++ b/forum/settings/forms.py @@ -4,6 +4,7 @@ from django import forms from forum.settings.base import Setting from django.utils.translation import ugettext as _ from django.core.files.storage import FileSystemStorage +from django.core.urlresolvers import reverse class DummySetting: pass @@ -25,7 +26,9 @@ class SettingsSetForm(forms.Form): for setting in set: widget = setting.field_context.get('widget', None) - if widget is forms.RadioSelect or isinstance(widget, forms.RadioSelect): + if widget is forms.CheckboxSelectMultiple or widget is forms.SelectMultiple or isinstance(widget, forms.SelectMultiple): + field = forms.MultipleChoiceField(**setting.field_context) + elif widget is forms.RadioSelect or isinstance(widget, forms.RadioSelect): field = forms.ChoiceField(**setting.field_context) elif isinstance(setting, (Setting.emulators.get(str, DummySetting), Setting.emulators.get(unicode, DummySetting))): if not setting.field_context.get('widget', None): @@ -108,12 +111,30 @@ class StringListWidget(forms.Widget): return data[name] class CommaStringListWidget(forms.Textarea): + def render(self, name, value, attrs=None): + return super(CommaStringListWidget, self).render(name, ', '.join(value), attrs) + + def value_from_datadict(self, data, files, name): if 'submit' in data: return map(strip, data[name].split(',')) else: return ', '.join(data[name]) +class TestEmailSettingsWidget(forms.TextInput): + def render(self, name, value, attrs=None): + if not value: + value = '' - - + return """ +