mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 12:12:53 -06:00
Closes #5399: Show options for cable endpoint types during bulk import
This commit is contained in:
parent
cc271aefe1
commit
2b0ddd2a98
@ -5,6 +5,7 @@
|
|||||||
### Enhancements
|
### Enhancements
|
||||||
|
|
||||||
* [#5274](https://github.com/netbox-community/netbox/issues/5274) - Add REST API support for custom fields
|
* [#5274](https://github.com/netbox-community/netbox/issues/5274) - Add REST API support for custom fields
|
||||||
|
* [#5399](https://github.com/netbox-community/netbox/issues/5399) - Show options for cable endpoint types during bulk import
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if field.STATIC_CHOICES %}
|
{% if field.STATIC_CHOICES %}
|
||||||
<button type="button" class="btn btn-primary btn-xs pull-right" data-toggle="modal" data-target="#{{ name }}_choices">
|
<button type="button" class="btn btn-link btn-xs pull-right" data-toggle="modal" data-target="#{{ name }}_choices">
|
||||||
<i class="mdi mdi-help-circle"></i>
|
<i class="mdi mdi-help-circle"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="modal fade" id="{{ name }}_choices" tabindex="-1" role="dialog">
|
<div class="modal fade" id="{{ name }}_choices" tabindex="-1" role="dialog">
|
||||||
|
@ -135,13 +135,20 @@ class CSVModelChoiceField(forms.ModelChoiceField):
|
|||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
try:
|
try:
|
||||||
return super().to_python(value)
|
return super().to_python(value)
|
||||||
except MultipleObjectsReturned as e:
|
except MultipleObjectsReturned:
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
f'"{value}" is not a unique value for this field; multiple objects were found'
|
f'"{value}" is not a unique value for this field; multiple objects were found'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class CSVContentTypeField(CSVModelChoiceField):
|
class CSVContentTypeField(CSVModelChoiceField):
|
||||||
|
"""
|
||||||
|
Reference a ContentType in the form <app>.<model>
|
||||||
|
"""
|
||||||
|
STATIC_CHOICES = True
|
||||||
|
|
||||||
|
def prepare_value(self, value):
|
||||||
|
return f'{value.app_label}.{value.model}'
|
||||||
|
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user