def ballot_voting_form(ballot_voting, request): yes_no_choices = [(True, _('Yes')), (False, _('No')), (None, _('Abstention'))] max_points = 9 if len(ballot_voting.options) > 3 else 3 point_choices = [(i, str(i)) for i in range(max_points+1)] schema = Schema() for option in ballot_voting.options: option_schema = SchemaNode(Mapping(), name=str(option.uuid), title=option.title) option_schema.add(SchemaNode( Boolean(), validator=OneOf([x[0] for x in yes_no_choices]), widget=RadioChoiceWidget(values=yes_no_choices, inline=True), name='yes_no', title=f'Stimmst du dem Antrag zu?')) option_schema.add(SchemaNode( Int(), validator=OneOf([x[0] for x in point_choices]), widget=RadioChoiceWidget(values=point_choices, inline=True, null_value='0'), name='points', title='Welche Punktzahl gibst du dem Antrag?', missing=0)) schema.add(option_schema) form = Form(schema, request, buttons=[Button(title=_('check'))]) return form
def __init__(self, model, id_field='id', label_field='label', order_by=None, **kw): RelationSelectMixin.__init__(self, model, id_field, label_field, None, order_by) RadioChoiceWidget.__init__(self, **kw)
class SoftwareCollectionSchema(DocumentSchema): choices = ( ('ascending', 'Ascending'), ('descending', 'Descending')) sort_order_choice = colander.SchemaNode(colander.String(), title=_(u'Sort Order'), default='descending', widget=RadioChoiceWidget(values=choices), validator=colander.OneOf(('ascending', 'descending')))
class QuestionSchema(ContentSchema): title = colander.SchemaNode( colander.String(), title=_(u'Question'), ) question_type = colander.SchemaNode( colander.String(), title=_(u'Question Type'), validator=colander.OneOf(["radio", "checkbox", "text"]), widget=RadioChoiceWidget(values=[["radio", _( "Single Choice")], ["checkbox", _("Multiple Choice")], ["text", _("Text")]]))
class AnswerSchema(ContentSchema): title = colander.SchemaNode( colander.String(), title=_(u'Answering Choice:'), ) correct = colander.SchemaNode( colander.Bool(), title=_(u'Answer Type'), widget=RadioChoiceWidget(values=[ [True, _("Correct Answer")], [False, _("Incorrect Answer")]]) )
class QuestionSchema(ContentSchema): title = colander.SchemaNode( colander.String(), title=_(u'Question'), ) question_type = colander.SchemaNode( colander.String(), title=_(u'Question Type'), validator=colander.OneOf(["radio", "checkbox", "text"]), widget=RadioChoiceWidget(values=[ ["radio", _("singlechoice")], ["checkbox", _("multiplechoice")], ["text", _("freetext")]]) ) correct_answer = colander.SchemaNode( colander.String(), title=_(u'Correct Answer'), missing=None, default=colander.null )
def __init__( self, model, id_field='id', label_field='label', order_by=None, **kw): RelationSelectMixin.__init__( self, model, id_field, label_field, None, order_by) RadioChoiceWidget.__init__(self, **kw)
def after_bind(self, node, kw): values = SOURCE_TYPES.items() if not kw['request'].solr_activated: values.remove(('wizard_solr', SOURCE_TYPES['wizard_solr'])) self.widget = RadioChoiceWidget(values=values)
def deferred_architecture_widget(node, kw): g = GameDepLib(kw.get('gamedep_type')) return RadioChoiceWidget(values=g.list_architectures())
def deferred_operating_system_widget(node, kw): g = GameDepLib(kw.get('gamedep_type')) return RadioChoiceWidget(values=g.list_operatingsystems())
def deferred_revision_module_type_widget(node, kw): return RadioChoiceWidget(values=module_type)
def deferred_edit_dependency_two_widget(node, kw): g = GameDepLib(kw.get('gamedep_type')) depid = kw.get('depid') return RadioChoiceWidget(values=g.revision_dropdown(depid))