# -*- coding: utf-8 -*-
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.safestring import mark_safe
from django.conf import settings
APPROVAL_CHOICES = (
(1, mark_safe(_('' %
{'media_url': settings.MEDIA_URL, },
))),
(2, mark_safe(_('' %
{'media_url': settings.MEDIA_URL, },
))),
(0, mark_safe(_('' %
{'media_url': settings.MEDIA_URL, },
))),
)
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
"""renders horizontal radio buttons.
found here:
https://wikis.utexas.edu/display/~bm6432/Django-Modifying+RadioSelect+Widget+to+have+horizontal+buttons
"""
def render(self):
return mark_safe(u'\n'.join([u'%s\n' % w for w in self]))
class ApprovalForm(forms.Form):
approval = forms.ChoiceField(choices=APPROVAL_CHOICES,
initial=0,
widget=forms.RadioSelect(renderer=HorizontalRadioRenderer),
)