class CodeBoxRun(forms.Form): name = forms.CharField() text = forms.CharField(widget=AceWidget(wordwrap=False, width="650px", height="500px", showprintmargin=True, theme='twilight')) inp = forms.CharField(widget=forms.Textarea(attrs={'id': 'input'}), required=False) langs = forms.ChoiceField(l, initial='C')
class Meta: model = Template widgets = { 'name': forms.TextInput(attrs={'class': 'input-xxlarge'}), 'slug': forms.TextInput(attrs={'class': 'input-xxlarge'}), 'body': AceWidget(mode='django', width='640px', showprintmargin=False), } exclude = ()
def formfield_for_dbfield(self, db_field, **kwargs): if getattr(settings, "USE_ACE_WIDGET", True) and db_field.name == "content": kwargs["widget"] = AceWidget( mode=getattr(settings, "ACE_MODE", "twig"), theme=getattr(settings, "ACE_THEME", "chrome"), width=getattr(settings, "ACE_WIDTH", "100%"), height=getattr(settings, "ACE_HEIGHT", "300px")) return super(AceWidgetMixin, self).formfield_for_dbfield(db_field, **kwargs)
class Meta: model = Feedback exclude = [] widgets = { 'feedback_data': AceWidget(mode='json', theme='monokai', width='600px', height='300px'), }
class EditorForm(forms.Form): text = forms.CharField(widget=AceWidget(mode='python', theme='monokai'),label="") def clean_text(self): value = self.cleaned_data["text"] forbidden = ['exec(', 'eval(', 'exit(', 'quit('] for banned in forbidden: if banned in value: raise forms.ValidationError("Yritit käyttää estettyä python käskyä") return value
class Meta: model = UserProfile fields = ['code'] widgets = { "code": AceWidget(mode='python', theme='twilight', width="850px", height="500px"), }
class Meta: model = Data exclude = [] widgets = { 'value': AceWidget(mode='json', theme='monokai', width='600px', height='300px'), }
def __init__(self, *args, **kwargs): """Set code widget mode.""" super(MigrationStepForm, self).__init__(*args, **kwargs) type_ = self.initial.get('type') if type_: self.fields['code'].widget = AceWidget(mode=type_, **ACE_WIDGET_PARAMS) widget = self.fields['code'].widget widget.__dict__['media'] = widget.media self.fields['type'].widget.attrs = {'class': 'migration_step_type'}
class Meta: model = PersonalProject fields = ['title', 'description', 'code'] widgets = { 'code': AceWidget(mode='python', theme='xcode', width="100%", height="425px", fontsize="14px") }
class CommonAdminFeatures(admin.ModelAdmin): formfield_overrides = { models.TextField: {'widget': AdminMartorWidget}, models.CharField: {'widget': AceWidget(mode='python')} } readonly_fields = ['type', 'judge_function_name'] list_display = ['id', '__str__', 'max_score', 'type'] list_display_links = ['__str__', 'id'] list_editable = ['max_score'] sortable_by = ['id', 'max_score'] search_fields = ['max_score']
class Meta: model = Chapter fields = '__all__' widgets = { 'content': AceWidget(mode='html', theme='twilight', wordwrap=True, width='100%', height='300px') }
class DoubleEditorForm(forms.Form): parameters = forms.CharField(widget=AceWidget(mode='python', theme='merbivore', width="575px", height="50px"), label="Laita tähän kenttään muuttujat omia testiajojasi varten", required=False ) text = forms.CharField(widget=AceWidget(mode='python', theme='merbivore'),label="") def clean_text(self): value = self.cleaned_data["text"] forbidden = ['exec(', 'eval(', 'exit(', 'quit('] for banned in forbidden: if banned in value: raise forms.ValidationError("Yritit käyttää estettyä python käskyä") if "parameters" in self.cleaned_data: value2 = self.cleaned_data["parameters"] for banned in forbidden: if banned in value2: raise forms.ValidationError("Yritit käyttää estettyä python käskyä") return value
def __init__(self, *args, **kwargs): if "instance" in kwargs \ and kwargs["instance"] is not None \ and kwargs["instance"].type_file not in ['bin', 'archive']: type_file = kwargs["instance"].type_file self.base_fields['text_content'].widget = AceWidget(mode=type_file, width="100%", toolbar=True) super(FileControlAdminForm, self).__init__(*args, **kwargs)
class Meta: model = models.Homepage fields = '__all__' widgets = { 'text': AceWidget(mode='django', theme='tomorrow_night', width="900px", height="400px"), } help_texts = { 'text': """To keep the content compatible with the current slide structure of the home page, the content is expected to be separated into sections with class "section".""" }
class Meta: model = Exercise widgets = { "test_imports": AceWidget(theme='twilight', mode='python', wordwrap=True, width='100%'), "test": AceWidget(theme='twilight', mode='python', wordwrap=True, width='100%'), "text": AceWidget(theme='twilight', mode='python', wordwrap=True, width='100%'), } fields = "__all__"
class Meta: model = StructuredProjectCode fields = ['code'] widgets = { 'code': AceWidget(mode='python', theme='xcode', width="100%", height="525px", fontsize="14px") }
class CodeForm(forms.Form): text = forms.CharField(widget=AceWidget(showprintmargin=True)) inp = forms.CharField(widget=forms.Textarea(attrs={'id': 'input'}), required=False) l = [('C', 'C'), ('CPP', 'C++'), ('CPP11', 'C++11'), ('CLOJURE', 'Clojure'), ('CSS', 'CSS'), ('CSHARP', 'C#'), ('HTML', 'HTML'), ('GO', 'Go'), ('JAVA', 'Java'), ('JAVASCRIPT', 'Javascript(Rhino)'), ('JAVASCRIPT_NODE', 'Javascript(Node.js)'), ('HASKELL', 'Haskell'), ('PERL', 'Perl'), ('PHP', 'PHP'), ('PYTHON', 'Python'), ('RUBY', 'Ruby'), ('RUST', 'Rust')] langs = forms.ChoiceField(l, initial='C')
class Meta: model = Crash exclude = [] widgets = { 'stacktrace_json': AceWidget(mode='json', theme='monokai', width='600px', height='300px'), 'stacktrace': AceWidget(theme='monokai', width='600px', height='300px'), 'meta': AceWidget(mode='json', theme='monokai', width='600px', height='300px'), 'archive_size': widgets.TextInput(attrs=dict(disabled='disabled')), 'minidump_size': widgets.TextInput(attrs=dict(disabled='disabled')), }
class Meta: model = CodeBlock widgets = { 'block_1_code': AceWidget(width='800px', height='500px'), 'expected_output': forms.Textarea(attrs={ 'placeholder': 'Optional', 'cols': 80 }) } fields = ['language', 'block_1_code', 'expected_output']
class Meta: #Snippet model is used for creating this form model = Snippet #Different attributes for ace widget widgets = { "text": AceWidget(mode='c_cpp', theme='twilight', width="100%", height="500px", fontsize="14px"), } exclude = ()
class EditorForm(forms.Form): text = forms.CharField( widget=AceWidget( mode='python', theme='xcode', fontsize='18px', width="100%", height="50vh", toolbar=False, ), label='Code Here!', required=False, )
class TaskModelForm(forms.ModelForm): instructions = forms.CharField(widget=AceWidget(mode='markdown', theme='textmate', width='800px', height='600px', wordwrap=True)) class Meta: model = Task class Media: css = { 'all': ('css/admin_ace.css',) } instructions.help_text = ('Instructions are written in <a href="http://markdowntutorial.com/" target="_blank">Markdown</a>.')
class Meta: model = Lesson fields = '__all__' #model.lesson_code = 'static/code_templates/Python_Example_2.txt' widgets = { 'lesson_code':AceWidget(mode='python',theme='twilight'), } form = { 'template':'TemplateForm', }
class ProblemSubmitForm(ModelForm): source = CharField(max_length=65536, widget=AceWidget(theme='twilight', no_ace_media=True)) def __init__(self, *args, **kwargs): super(ProblemSubmitForm, self).__init__(*args, **kwargs) self.fields['problem'].empty_label = None self.fields['problem'].widget = forms.HiddenInput() self.fields['language'].empty_label = None self.fields['language'].label_from_instance = attrgetter('display_name') self.fields['language'].queryset = Language.objects.filter(judges__online=True).distinct() class Meta: model = Submission fields = ['problem', 'language']
class Meta: model = Snippet widgets = { "text": AceWidget(mode='c_cpp', theme='twilight', wordwrap=False, width='100%', height='400px', fontsize="20px", toolbar=True, showprintmargin=True), } exclude = ()
def get_form(self, request, obj=None, **kwargs): form = super(ContestAdmin, self).get_form(request, obj, **kwargs) if 'problem_label_script' in form.base_fields: # form.base_fields['problem_label_script'] does not exist when the user has only view permission # on the model. form.base_fields['problem_label_script'].widget = AceWidget( 'lua', request.profile.ace_theme) perms = ('edit_own_contest', 'edit_all_contest') form.base_fields['curators'].queryset = Profile.objects.filter( Q(user__is_superuser=True) | Q(user__groups__permissions__codename__in=perms) | Q(user__user_permissions__codename__in=perms), ).distinct() return form
class Meta: model = Snippet widgets = { "text": AceWidget( mode='html', theme='twilight', wordwrap=True, showinvisibles=True, usesofttabs=False, tabsize=2, fontsize='12pt', ), } exclude = ()
class ViewOnlyEditorForm(forms.Form): text = forms.CharField( widget=AceWidget( mode='python', theme='katzenmilch', fontsize='18px', width="100%", height="50vh", toolbar=False, readonly=True, showgutter=False, ), label='Note: Read-Only!', required=False, )
class Meta: model = Profile fields = [ 'name', 'about', 'organizations', 'timezone', 'language', 'ace_theme', 'user_script', 'math_engine' ] widgets = { 'name': TextInput(attrs={'style': 'width:100%;box-sizing:border-box'}), 'user_script': AceWidget(theme='github'), 'timezone': Select2Widget(attrs={'style': 'width:200px'}), 'language': Select2Widget(attrs={'style': 'width:200px'}), 'ace_theme': Select2Widget(attrs={'style': 'width:200px'}), 'math_engine': Select2Widget(attrs={'style': 'width:200px'}), 'about': MartorWidget, }
class Meta: model = CodeBlock widgets = { 'block_1_code': AceWidget(width='600px'), 'block_2_code': AceWidget(width='600px'), 'block_3_code': AceWidget(width='600px'), 'block_4_code': AceWidget(width='600px'), 'block_5_code': AceWidget(width='600px'), 'run_result': AceWidget(mode='json', width='600px', readonly=True), } fields = '__all__'