Пример #1
0
 class Meta:
     widgets = {
         'options': JSONEditor(),
         'geolocations': JSONEditor(),
         'username': forms.TextInput(attrs={'autocomplete': 'off'}),
         'password': PasswordWidget(attrs={'autocomplete': 'off'}),
     }
Пример #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"
            }
            """)
Пример #3
0
class CustomModelAdmin(admin.ModelAdmin):
    formfield_overrides = {
        DummyJsonField: {
            'widget': JSONEditor()
        },
        DummyHtmlField: {
            'widget':
            CodeMirrorEditor(options={
                'mode': 'xml',
                'lineNumbers': True,
                'lineWrapping': True
            })
        }
    }
Пример #4
0
 class Meta:
     widgets = {
         'extra_configuration': JSONEditor(),
         'user_password': PasswordWidget(),
     }
Пример #5
0
 class Meta:
     widgets = {
         'config': JSONEditor(),
     }
Пример #6
0
 class Meta:
     widgets = {
         'report': JSONEditor(),
     }
Пример #7
0
 class Meta:
     widgets = {
         'attributes': JSONEditor(),
         'geolocations': JSONEditor(),
         'options': JSONEditor(),
     }
Пример #8
0
 class Meta:
     widgets = {
         'context': JSONEditor(),
     }
Пример #9
0
 class Meta:
     widgets = {
         'extra': JSONEditor(),
     }
Пример #10
0
 class Meta:
     widgets = {
         'options': JSONEditor(),
         'geolocations': JSONEditor(),
         'password': PasswordWidget(),
     }
Пример #11
0
 class Meta:
     widgets = {
         'interface_parameters': JSONEditor(),
     }
Пример #12
0
 class Meta:
     widgets = {
         'arguments': JSONEditor(),
     }