Esempio n. 1
0
 class Meta:
     widgets = {
         'options': JSONEditor(),
         'geolocations': JSONEditor(),
         'username': forms.TextInput(attrs={'autocomplete': 'off'}),
         'password': PasswordWidget(attrs={'autocomplete': 'off'}),
     }
Esempio n. 2
0
class ProblemCreateForm(forms.ModelForm):
    class Meta:
        model = MultipleChoiceQuestion
        fields = ('title', 'token_value', 'difficulty', 'text', 'answer',
                  'tutorial', 'category', 'variables', 'choices')

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.fields['category'].widget.attrs.update({'class': 'form-control'})
        self.fields['difficulty'].widget.attrs.update(
            {'class': 'form-control'})

    title = forms.CharField(widget=TextInput(attrs={'class': 'form-control'}))

    token_value = forms.IntegerField(widget=NumberInput(
        attrs={'class': 'form-control'}))

    text = forms.CharField(label='Statement',
                           widget=RichTextWidget(field_settings='advanced'))

    answer = forms.CharField(widget=Textarea(attrs={'class': 'form-control'}))

    tutorial = forms.CharField(widget=RichTextWidget(
        field_settings='advanced'))

    variables = forms.CharField(widget=JSONEditor(),
                                help_text="""
        It should be an array with each element a set of variables to choose.
        A valid example:
        [
            {
                "x" : 1,
                "y" : 2,
            },
            {
                "x" : 5,
                "y" : 8,
            }
        ]
        """)

    choices = forms.CharField(widget=JSONEditor(),
                              help_text="""
            It should be an object of choices.
            A valid example:
            {
                "a" : "{x} is odd and {y} is odd",
                "b" : "{x} is even and {y} is odd",
                "c" : "{x} is odd and {y} is even",
                "d" : "{x} is even and {y} is even"
            }
            """)
Esempio n. 3
0
class CustomModelAdmin(admin.ModelAdmin):
    formfield_overrides = {
        DummyJsonField: {
            'widget': JSONEditor()
        },
        DummyHtmlField: {
            'widget':
            CodeMirrorEditor(options={
                'mode': 'xml',
                'lineNumbers': True,
                'lineWrapping': True
            })
        }
    }
Esempio n. 4
0
 class Meta:
     widgets = {
         'extra_configuration': JSONEditor(),
         'user_password': PasswordWidget(),
     }
Esempio n. 5
0
 class Meta:
     widgets = {
         'config': JSONEditor(),
     }
Esempio n. 6
0
 class Meta:
     widgets = {
         'report': JSONEditor(),
     }
Esempio n. 7
0
 class Meta:
     widgets = {
         'attributes': JSONEditor(),
         'geolocations': JSONEditor(),
         'options': JSONEditor(),
     }
Esempio n. 8
0
 class Meta:
     widgets = {
         'context': JSONEditor(),
     }
Esempio n. 9
0
 class Meta:
     widgets = {
         'extra': JSONEditor(),
     }
Esempio n. 10
0
 class Meta:
     widgets = {
         'options': JSONEditor(),
         'geolocations': JSONEditor(),
         'password': PasswordWidget(),
     }
Esempio n. 11
0
 class Meta:
     widgets = {
         'interface_parameters': JSONEditor(),
     }
Esempio n. 12
0
 class Meta:
     widgets = {
         'arguments': JSONEditor(),
     }