1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00
Files
netbox-community-netbox/netbox/tenancy/forms/bulk_edit.py
Aron Bergur Jóhannsson fa60f9d2a8 Closes #11294: Markdown Preview (#11894)
* MarkdownWidget

* Change border and color of active markdown tab

* Fix template name typo

* Add render markdown endpoint

* Static assets for markdown widget

* widget style fix and unique ids based on name

* Replace SmallTextArea with SmallMarkdownWidget

* Clear innerHTML before swapping

* render markdown directly in template

* change render markdown view path

* remove small markdown widget

* Simplify rendering logic

* Use a form to clean input Markdown data

---------

Co-authored-by: Jeremy Stretch <jstretch@ns1.com>
2023-03-09 08:21:13 -05:00

117 lines
2.5 KiB
Python

from django import forms
from netbox.forms import NetBoxModelBulkEditForm
from tenancy.models import *
from utilities.forms import CommentField, DynamicModelChoiceField
__all__ = (
'ContactBulkEditForm',
'ContactGroupBulkEditForm',
'ContactRoleBulkEditForm',
'TenantBulkEditForm',
'TenantGroupBulkEditForm',
)
#
# Tenants
#
class TenantGroupBulkEditForm(NetBoxModelBulkEditForm):
parent = DynamicModelChoiceField(
queryset=TenantGroup.objects.all(),
required=False
)
description = forms.CharField(
max_length=200,
required=False
)
model = TenantGroup
nullable_fields = ('parent', 'description')
class TenantBulkEditForm(NetBoxModelBulkEditForm):
group = DynamicModelChoiceField(
queryset=TenantGroup.objects.all(),
required=False
)
model = Tenant
fieldsets = (
(None, ('group',)),
)
nullable_fields = ('group',)
#
# Contacts
#
class ContactGroupBulkEditForm(NetBoxModelBulkEditForm):
parent = DynamicModelChoiceField(
queryset=ContactGroup.objects.all(),
required=False
)
description = forms.CharField(
max_length=200,
required=False
)
model = ContactGroup
fieldsets = (
(None, ('parent', 'description')),
)
nullable_fields = ('parent', 'description')
class ContactRoleBulkEditForm(NetBoxModelBulkEditForm):
description = forms.CharField(
max_length=200,
required=False
)
model = ContactRole
fieldsets = (
(None, ('description',)),
)
nullable_fields = ('description',)
class ContactBulkEditForm(NetBoxModelBulkEditForm):
group = DynamicModelChoiceField(
queryset=ContactGroup.objects.all(),
required=False
)
title = forms.CharField(
max_length=100,
required=False
)
phone = forms.CharField(
max_length=50,
required=False
)
email = forms.EmailField(
required=False
)
address = forms.CharField(
max_length=200,
required=False
)
link = forms.URLField(
required=False
)
description = forms.CharField(
max_length=200,
required=False
)
comments = CommentField(
label='Comments'
)
model = Contact
fieldsets = (
(None, ('group', 'title', 'phone', 'email', 'address', 'link', 'description')),
)
nullable_fields = ('group', 'title', 'phone', 'email', 'address', 'link', 'description', 'comments')