Prechádzať zdrojové kódy

Add TextVar for large text entry

Jeremy Stretch 6 rokov pred
rodič
commit
cb0dbc0769
1 zmenil súbory, kde vykonal 13 pridanie a 1 odobranie
  1. 13 1
      netbox/extras/scripts.py

+ 13 - 1
netbox/extras/scripts.py

@@ -3,7 +3,6 @@ import inspect
 import json
 import os
 import pkgutil
-import sys
 import time
 import traceback
 import yaml
@@ -24,6 +23,7 @@ from .forms import ScriptForm
 __all__ = [
     'Script',
     'StringVar',
+    'TextVar',
     'IntegerVar',
     'BooleanVar',
     'ObjectVar',
@@ -87,6 +87,18 @@ class StringVar(ScriptVariable):
             ]
 
 
+class TextVar(ScriptVariable):
+    """
+    Free-form text data. Renders as a <textarea>.
+    """
+    form_field = forms.CharField
+
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+
+        self.field_attrs['widget'] = forms.Textarea
+
+
 class IntegerVar(ScriptVariable):
     """
     Integer representation. Can enforce minimum/maximum values.