Esempio n. 1
0
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
Esempio n. 2
0
 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)
Esempio n. 3
0
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')))
Esempio n. 4
0
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")]]))
Esempio n. 5
0
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")]])
        )
Esempio n. 6
0
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
        )
Esempio n. 7
0
 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)
Esempio n. 8
0
 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)
Esempio n. 9
0
def deferred_architecture_widget(node, kw):
    g = GameDepLib(kw.get('gamedep_type'))
    return RadioChoiceWidget(values=g.list_architectures())
Esempio n. 10
0
def deferred_operating_system_widget(node, kw):
    g = GameDepLib(kw.get('gamedep_type'))
    return RadioChoiceWidget(values=g.list_operatingsystems())
Esempio n. 11
0
def deferred_revision_module_type_widget(node, kw):
    return RadioChoiceWidget(values=module_type)
Esempio n. 12
0
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))