Replace SmallTextArea with SmallMarkdownWidget

This commit is contained in:
aron bergur jóhannsson 2023-03-02 22:57:28 +00:00
parent 3af52aaf13
commit 525f53c13b
7 changed files with 46 additions and 37 deletions

View File

@ -7,8 +7,8 @@ from ipam.models import ASN
from netbox.forms import NetBoxModelBulkEditForm from netbox.forms import NetBoxModelBulkEditForm
from tenancy.models import Tenant from tenancy.models import Tenant
from utilities.forms import ( from utilities.forms import (
add_blank_choice, CommentField, DatePicker, DynamicModelChoiceField, DynamicModelMultipleChoiceField, SmallTextarea, add_blank_choice, CommentField, DatePicker, DynamicModelChoiceField, DynamicModelMultipleChoiceField,
StaticSelect, SmallMarkdownWidget, StaticSelect,
) )
__all__ = ( __all__ = (
@ -35,7 +35,7 @@ class ProviderBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label=_('Comments') label=_('Comments')
) )
@ -63,7 +63,7 @@ class ProviderNetworkBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label=_('Comments') label=_('Comments')
) )
@ -125,7 +125,7 @@ class CircuitBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label=_('Comments') label=_('Comments')
) )

View File

@ -11,7 +11,7 @@ from netbox.forms import NetBoxModelBulkEditForm
from tenancy.models import Tenant from tenancy.models import Tenant
from utilities.forms import ( from utilities.forms import (
add_blank_choice, BulkEditForm, BulkEditNullBooleanSelect, ColorField, CommentField, DynamicModelChoiceField, add_blank_choice, BulkEditForm, BulkEditNullBooleanSelect, ColorField, CommentField, DynamicModelChoiceField,
DynamicModelMultipleChoiceField, form_from_model, SmallTextarea, StaticSelect, SelectSpeedWidget, DynamicModelMultipleChoiceField, form_from_model, StaticSelect, SelectSpeedWidget, SmallMarkdownWidget
) )
__all__ = ( __all__ = (
@ -138,7 +138,7 @@ class SiteBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -309,7 +309,7 @@ class RackBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -345,7 +345,7 @@ class RackReservationBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -406,7 +406,7 @@ class DeviceTypeBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -441,7 +441,7 @@ class ModuleTypeBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -551,7 +551,7 @@ class DeviceBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -594,7 +594,7 @@ class ModuleBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -644,7 +644,7 @@ class CableBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -668,7 +668,7 @@ class VirtualChassisBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -714,7 +714,7 @@ class PowerPanelBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -776,7 +776,7 @@ class PowerFeedBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label=_('Comments') label=_('Comments')
) )

View File

@ -10,7 +10,7 @@ from netbox.forms import NetBoxModelBulkEditForm
from tenancy.models import Tenant from tenancy.models import Tenant
from utilities.forms import ( from utilities.forms import (
add_blank_choice, BulkEditNullBooleanSelect, CommentField, DynamicModelChoiceField, NumericArrayField, add_blank_choice, BulkEditNullBooleanSelect, CommentField, DynamicModelChoiceField, NumericArrayField,
SmallTextarea, StaticSelect, DynamicModelMultipleChoiceField, StaticSelect, DynamicModelMultipleChoiceField, SmallMarkdownWidget
) )
__all__ = ( __all__ = (
@ -48,7 +48,7 @@ class VRFBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -69,7 +69,7 @@ class RouteTargetBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -116,7 +116,7 @@ class ASNBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -145,7 +145,7 @@ class AggregateBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -227,7 +227,7 @@ class PrefixBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -266,7 +266,7 @@ class IPRangeBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -314,7 +314,7 @@ class IPAddressBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -359,7 +359,7 @@ class FHRPGroupBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -442,7 +442,7 @@ class VLANBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -474,7 +474,7 @@ class ServiceTemplateBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -504,7 +504,7 @@ class L2VPNBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )

View File

@ -2,7 +2,7 @@ from django import forms
from netbox.forms import NetBoxModelBulkEditForm from netbox.forms import NetBoxModelBulkEditForm
from tenancy.models import * from tenancy.models import *
from utilities.forms import CommentField, DynamicModelChoiceField, SmallTextarea from utilities.forms import CommentField, DynamicModelChoiceField, SmallMarkdownWidget
__all__ = ( __all__ = (
'ContactBulkEditForm', 'ContactBulkEditForm',
@ -106,7 +106,7 @@ class ContactBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )

View File

@ -16,11 +16,13 @@ __all__ = (
'ColorSelect', 'ColorSelect',
'DatePicker', 'DatePicker',
'DateTimePicker', 'DateTimePicker',
'MarkdownWidget',
'NumericArrayField', 'NumericArrayField',
'SelectDurationWidget', 'SelectDurationWidget',
'SelectSpeedWidget', 'SelectSpeedWidget',
'SelectWithPK', 'SelectWithPK',
'SlugWidget', 'SlugWidget',
'SmallMarkdownWidget',
'SmallTextarea', 'SmallTextarea',
'StaticSelect', 'StaticSelect',
'StaticSelectMultiple', 'StaticSelectMultiple',
@ -120,6 +122,13 @@ class MarkdownWidget(forms.Textarea):
template_name = 'widgets/markdown_input.html' template_name = 'widgets/markdown_input.html'
class SmallMarkdownWidget(MarkdownWidget):
"""
Subclass used for rendering a smaller markdown element.
"""
pass
class NumericArrayField(SimpleArrayField): class NumericArrayField(SimpleArrayField):
def clean(self, value): def clean(self, value):

View File

@ -9,7 +9,7 @@ from netbox.forms import NetBoxModelBulkEditForm
from tenancy.models import Tenant from tenancy.models import Tenant
from utilities.forms import ( from utilities.forms import (
add_blank_choice, BulkEditNullBooleanSelect, BulkRenameForm, CommentField, DynamicModelChoiceField, add_blank_choice, BulkEditNullBooleanSelect, BulkRenameForm, CommentField, DynamicModelChoiceField,
DynamicModelMultipleChoiceField, SmallTextarea, StaticSelect DynamicModelMultipleChoiceField, StaticSelect, SmallMarkdownWidget
) )
from virtualization.choices import * from virtualization.choices import *
from virtualization.models import * from virtualization.models import *
@ -90,7 +90,7 @@ class ClusterBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label=_('Comments') label=_('Comments')
) )
@ -163,7 +163,7 @@ class VirtualMachineBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label=_('Comments') label=_('Comments')
) )

View File

@ -5,7 +5,7 @@ from dcim.choices import LinkStatusChoices
from ipam.models import VLAN from ipam.models import VLAN
from netbox.forms import NetBoxModelBulkEditForm from netbox.forms import NetBoxModelBulkEditForm
from tenancy.models import Tenant from tenancy.models import Tenant
from utilities.forms import add_blank_choice, CommentField, DynamicModelChoiceField, SmallTextarea from utilities.forms import add_blank_choice, CommentField, DynamicModelChoiceField, SmallMarkdownWidget
from wireless.choices import * from wireless.choices import *
from wireless.constants import SSID_MAX_LENGTH from wireless.constants import SSID_MAX_LENGTH
from wireless.models import * from wireless.models import *
@ -74,7 +74,7 @@ class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )
@ -119,7 +119,7 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
required=False required=False
) )
comments = CommentField( comments = CommentField(
widget=SmallTextarea, widget=SmallMarkdownWidget,
label='Comments' label='Comments'
) )