# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata.forms import ModelForm, fields, validators
from udata.i18n import lazy_gettext as _
from udata.models import Badge

__all__ = ('badge_form', )


def badge_form(model):
    '''A form factory for a given model badges'''
    class BadgeForm(ModelForm):
        model_class = Badge

        kind = fields.RadioField(
            _('Kind'), [validators.required()],
            choices=model.__badges__.items(),
            description=_('Kind of badge (certified, etc)'))

    return BadgeForm

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata.forms import ModelForm, fields, validators
from udata.i18n import lazy_gettext as _
from udata.models import Badge

__all__ = ('badge_form', )


def badge_form(model):
    '''A form factory for a given model badges'''
    class BadgeForm(ModelForm):
        model_class = Badge

        kind = fields.RadioField(
            _('Kind'), [validators.DataRequired()],
            choices=model.__badges__.items(),
            description=_('Kind of badge (certified, etc)'))

    return BadgeForm

Switch from the deprecated validators.required() to validators.DataRequired()
Switch from the deprecated validators.required() to validators.DataRequired()
