Exemplo n.º 1
0
 def safe_eval(cls, value, condition):
     return eval(
         condition, {'__builtins__': {}},
         merge_dicts([
             ConditionalAnswer.SAFE_EVAL_LOCAL_CONTEXT, {
                 '_value_': value
             }
         ]))
Exemplo n.º 2
0
 def __init__(self, choices, use_dropdown_widget, **kwargs):
     kw_args = merge_dicts(
         [SUBMISSION_FIELD_KWARGS, MCQ_KWARGS, MCSAQ_KWARGS, kwargs])
     widget = LockableSelect(
         attrs={
             'class': ChosenNoSearchSelect.CLASS_ATTR + ' chosen-smaller'
         }) if use_dropdown_widget else RadioSelect
     if use_dropdown_widget:
         choices.insert(0, MCSAQFormField.DROPDOWN_EMPTY_CHOICE)
     super(MCSAQFormField, self).__init__(widget=widget,
                                          choices=choices,
                                          **kw_args)
Exemplo n.º 3
0
def eval_no_globals(expression, variables):
    return eval(expression, {}, merge_dicts([EVAL_HELPERS, variables]))
Exemplo n.º 4
0
 def __init__(self, **kwargs):
     kw_args = merge_dicts([SUBMISSION_FIELD_KWARGS, INPUT_KWARGS, kwargs])
     super(TextualFormField, self).__init__(help_text=TEXTUAL_HELP_TEXT,
                                            **kw_args)
     self.validators.append(textual_validator)
Exemplo n.º 5
0
 def __init__(self, **kwargs):
     kw_args = merge_dicts([SUBMISSION_FIELD_KWARGS, INPUT_KWARGS, kwargs])
     super(NumericFormField, self).__init__(help_text=NUMERIC_HELP_TEXT,
                                            **kw_args)
     self.validators.append(numeric_validator)
Exemplo n.º 6
0
 def __init__(self, choices, **kwargs):
     kw_args = merge_dicts(
         [SUBMISSION_FIELD_KWARGS, MCQ_KWARGS, MCMAQ_KWARGS, kwargs])
     super(MCMAQFormField, self).__init__(widget=CheckboxSelectMultiple,
                                          choices=choices,
                                          **kw_args)