@@ -1610,7 +1610,7 @@ class FrontPortTemplateForm(BootstrapMixin, forms.ModelForm):
1610
1610
class Meta :
1611
1611
model = FrontPortTemplate
1612
1612
fields = [
1613
- 'device_type' , 'name' , 'label' , 'type' , 'rear_port' , 'rear_port_position' , 'description' ,
1613
+ 'device_type' , 'name' , 'label' , 'type' , 'color' , ' rear_port' , 'rear_port_position' , 'description' ,
1614
1614
]
1615
1615
widgets = {
1616
1616
'device_type' : forms .HiddenInput (),
@@ -1639,7 +1639,7 @@ class FrontPortTemplateCreateForm(ComponentTemplateCreateForm):
1639
1639
help_text = 'Select one rear port assignment for each front port being created.' ,
1640
1640
)
1641
1641
field_order = (
1642
- 'manufacturer' , 'device_type' , 'name_pattern' , 'label_pattern' , 'type' , 'rear_port_set' , 'description' ,
1642
+ 'manufacturer' , 'device_type' , 'name_pattern' , 'label_pattern' , 'type' , 'color' , ' rear_port_set' , 'description' ,
1643
1643
)
1644
1644
1645
1645
def __init__ (self , * args , ** kwargs ):
@@ -1703,6 +1703,11 @@ class FrontPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
1703
1703
required = False ,
1704
1704
widget = StaticSelect2 ()
1705
1705
)
1706
+ color = forms .CharField (
1707
+ max_length = 6 , # RGB color code
1708
+ required = False ,
1709
+ widget = ColorSelect ()
1710
+ )
1706
1711
description = forms .CharField (
1707
1712
required = False
1708
1713
)
@@ -1716,7 +1721,7 @@ class RearPortTemplateForm(BootstrapMixin, forms.ModelForm):
1716
1721
class Meta :
1717
1722
model = RearPortTemplate
1718
1723
fields = [
1719
- 'device_type' , 'name' , 'label' , 'type' , 'positions' , 'description' ,
1724
+ 'device_type' , 'name' , 'label' , 'type' , 'color' , ' positions' , 'description' ,
1720
1725
]
1721
1726
widgets = {
1722
1727
'device_type' : forms .HiddenInput (),
@@ -1729,13 +1734,20 @@ class RearPortTemplateCreateForm(ComponentTemplateCreateForm):
1729
1734
choices = PortTypeChoices ,
1730
1735
widget = StaticSelect2 (),
1731
1736
)
1737
+ color = forms .CharField (
1738
+ max_length = 6 , # RGB color code
1739
+ required = False ,
1740
+ widget = ColorSelect ()
1741
+ )
1732
1742
positions = forms .IntegerField (
1733
1743
min_value = REARPORT_POSITIONS_MIN ,
1734
1744
max_value = REARPORT_POSITIONS_MAX ,
1735
1745
initial = 1 ,
1736
1746
help_text = 'The number of front ports which may be mapped to each rear port'
1737
1747
)
1738
- field_order = ('manufacturer' , 'device_type' , 'name_pattern' , 'label_pattern' , 'type' , 'positions' , 'description' )
1748
+ field_order = (
1749
+ 'manufacturer' , 'device_type' , 'name_pattern' , 'label_pattern' , 'type' , 'color' , 'positions' , 'description' ,
1750
+ )
1739
1751
1740
1752
1741
1753
class RearPortTemplateBulkEditForm (BootstrapMixin , BulkEditForm ):
@@ -1752,6 +1764,11 @@ class RearPortTemplateBulkEditForm(BootstrapMixin, BulkEditForm):
1752
1764
required = False ,
1753
1765
widget = StaticSelect2 ()
1754
1766
)
1767
+ color = forms .CharField (
1768
+ max_length = 6 , # RGB color code
1769
+ required = False ,
1770
+ widget = ColorSelect ()
1771
+ )
1755
1772
description = forms .CharField (
1756
1773
required = False
1757
1774
)
@@ -3427,7 +3444,7 @@ def clean_enabled(self):
3427
3444
3428
3445
class FrontPortFilterForm (DeviceComponentFilterForm ):
3429
3446
field_groups = [
3430
- ['name' , 'label' , 'type' ],
3447
+ ['name' , 'label' , 'type' , 'color' ],
3431
3448
['region_id' , 'site_group_id' , 'site_id' ],
3432
3449
['tag' ]
3433
3450
]
@@ -3437,6 +3454,11 @@ class FrontPortFilterForm(DeviceComponentFilterForm):
3437
3454
required = False ,
3438
3455
widget = StaticSelect2Multiple ()
3439
3456
)
3457
+ color = forms .CharField (
3458
+ max_length = 6 , # RGB color code
3459
+ required = False ,
3460
+ widget = ColorSelect ()
3461
+ )
3440
3462
tag = TagFilterField (model )
3441
3463
3442
3464
@@ -3449,8 +3471,8 @@ class FrontPortForm(BootstrapMixin, CustomFieldModelForm):
3449
3471
class Meta :
3450
3472
model = FrontPort
3451
3473
fields = [
3452
- 'device' , 'name' , 'label' , 'type' , 'rear_port ' , 'rear_port_position ' , 'mark_connected ' , 'description ' ,
3453
- 'tags' ,
3474
+ 'device' , 'name' , 'label' , 'type' , 'color ' , 'rear_port ' , 'rear_port_position ' , 'mark_connected ' ,
3475
+ 'description' , ' tags' ,
3454
3476
]
3455
3477
widgets = {
3456
3478
'device' : forms .HiddenInput (),
@@ -3475,13 +3497,19 @@ class FrontPortCreateForm(ComponentCreateForm):
3475
3497
choices = PortTypeChoices ,
3476
3498
widget = StaticSelect2 (),
3477
3499
)
3500
+ color = forms .CharField (
3501
+ max_length = 6 , # RGB color code
3502
+ required = False ,
3503
+ widget = ColorSelect ()
3504
+ )
3478
3505
rear_port_set = forms .MultipleChoiceField (
3479
3506
choices = [],
3480
3507
label = 'Rear ports' ,
3481
3508
help_text = 'Select one rear port assignment for each front port being created.' ,
3482
3509
)
3483
3510
field_order = (
3484
- 'device' , 'name_pattern' , 'label_pattern' , 'type' , 'rear_port_set' , 'mark_connected' , 'description' , 'tags' ,
3511
+ 'device' , 'name_pattern' , 'label_pattern' , 'type' , 'color' , 'rear_port_set' , 'mark_connected' , 'description' ,
3512
+ 'tags' ,
3485
3513
)
3486
3514
3487
3515
def __init__ (self , * args , ** kwargs ):
@@ -3540,7 +3568,7 @@ def get_iterative_data(self, iteration):
3540
3568
3541
3569
3542
3570
class FrontPortBulkEditForm (
3543
- form_from_model (FrontPort , ['label' , 'type' , 'mark_connected' , 'description' ]),
3571
+ form_from_model (FrontPort , ['label' , 'type' , 'color' , ' mark_connected' , 'description' ]),
3544
3572
BootstrapMixin ,
3545
3573
AddRemoveTagsForm ,
3546
3574
CustomFieldBulkEditForm
@@ -3572,7 +3600,8 @@ class FrontPortCSVForm(CustomFieldModelCSVForm):
3572
3600
class Meta :
3573
3601
model = FrontPort
3574
3602
fields = (
3575
- 'device' , 'name' , 'label' , 'type' , 'mark_connected' , 'rear_port' , 'rear_port_position' , 'description' ,
3603
+ 'device' , 'name' , 'label' , 'type' , 'color' , 'mark_connected' , 'rear_port' , 'rear_port_position' ,
3604
+ 'description' ,
3576
3605
)
3577
3606
help_texts = {
3578
3607
'rear_port_position' : 'Mapped position on corresponding rear port' ,
@@ -3608,7 +3637,7 @@ def __init__(self, *args, **kwargs):
3608
3637
class RearPortFilterForm (DeviceComponentFilterForm ):
3609
3638
model = RearPort
3610
3639
field_groups = [
3611
- ['name' , 'label' , 'type' ],
3640
+ ['name' , 'label' , 'type' , 'color' ],
3612
3641
['region_id' , 'site_group_id' , 'site_id' ],
3613
3642
['tag' ]
3614
3643
]
@@ -3617,6 +3646,11 @@ class RearPortFilterForm(DeviceComponentFilterForm):
3617
3646
required = False ,
3618
3647
widget = StaticSelect2Multiple ()
3619
3648
)
3649
+ color = forms .CharField (
3650
+ max_length = 6 , # RGB color code
3651
+ required = False ,
3652
+ widget = ColorSelect ()
3653
+ )
3620
3654
tag = TagFilterField (model )
3621
3655
3622
3656
@@ -3629,7 +3663,7 @@ class RearPortForm(BootstrapMixin, CustomFieldModelForm):
3629
3663
class Meta :
3630
3664
model = RearPort
3631
3665
fields = [
3632
- 'device' , 'name' , 'label' , 'type' , 'positions' , 'mark_connected' , 'description' , 'tags' ,
3666
+ 'device' , 'name' , 'label' , 'type' , 'color' , ' positions' , 'mark_connected' , 'description' , 'tags' ,
3633
3667
]
3634
3668
widgets = {
3635
3669
'device' : forms .HiddenInput (),
@@ -3643,27 +3677,33 @@ class RearPortCreateForm(ComponentCreateForm):
3643
3677
choices = PortTypeChoices ,
3644
3678
widget = StaticSelect2 (),
3645
3679
)
3680
+ color = forms .CharField (
3681
+ max_length = 6 , # RGB color code
3682
+ required = False ,
3683
+ widget = ColorSelect ()
3684
+ )
3646
3685
positions = forms .IntegerField (
3647
3686
min_value = REARPORT_POSITIONS_MIN ,
3648
3687
max_value = REARPORT_POSITIONS_MAX ,
3649
3688
initial = 1 ,
3650
3689
help_text = 'The number of front ports which may be mapped to each rear port'
3651
3690
)
3652
3691
field_order = (
3653
- 'device' , 'name_pattern' , 'label_pattern' , 'type' , 'positions' , 'mark_connected' , 'description' , 'tags' ,
3692
+ 'device' , 'name_pattern' , 'label_pattern' , 'type' , 'color' , 'positions' , 'mark_connected' , 'description' ,
3693
+ 'tags' ,
3654
3694
)
3655
3695
3656
3696
3657
3697
class RearPortBulkCreateForm (
3658
- form_from_model (RearPort , ['type' , 'positions' , 'mark_connected' ]),
3698
+ form_from_model (RearPort , ['type' , 'color' , ' positions' , 'mark_connected' ]),
3659
3699
DeviceBulkAddComponentForm
3660
3700
):
3661
3701
model = RearPort
3662
3702
field_order = ('name_pattern' , 'label_pattern' , 'type' , 'positions' , 'mark_connected' , 'description' , 'tags' )
3663
3703
3664
3704
3665
3705
class RearPortBulkEditForm (
3666
- form_from_model (RearPort , ['label' , 'type' , 'mark_connected' , 'description' ]),
3706
+ form_from_model (RearPort , ['label' , 'type' , 'color' , ' mark_connected' , 'description' ]),
3667
3707
BootstrapMixin ,
3668
3708
AddRemoveTagsForm ,
3669
3709
CustomFieldBulkEditForm
@@ -3689,7 +3729,7 @@ class RearPortCSVForm(CustomFieldModelCSVForm):
3689
3729
3690
3730
class Meta :
3691
3731
model = RearPort
3692
- fields = ('device' , 'name' , 'label' , 'type' , 'mark_connected' , 'positions' , 'description' )
3732
+ fields = ('device' , 'name' , 'label' , 'type' , 'color' , ' mark_connected' , 'positions' , 'description' )
3693
3733
help_texts = {
3694
3734
'positions' : 'Number of front ports which may be mapped'
3695
3735
}
0 commit comments