mirror of
				https://github.com/netbox-community/netbox.git
				synced 2024-05-10 07:54:54 +00:00 
			
		
		
		
	* #9045 - remove legacy fields from Provider * Add safegaurd for legacy data to migration * 9045 remove fields from forms and tables * Update unrelated tests to use ASN model instead of Provider * Fix migrations collision Co-authored-by: jeremystretch <jstretch@ns1.com>
		
			
				
	
	
		
			78 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from circuits.choices import CircuitStatusChoices
 | |
| from circuits.models import *
 | |
| from netbox.forms import NetBoxModelCSVForm
 | |
| from tenancy.models import Tenant
 | |
| from utilities.forms import CSVChoiceField, CSVModelChoiceField, SlugField
 | |
| 
 | |
| __all__ = (
 | |
|     'CircuitCSVForm',
 | |
|     'CircuitTypeCSVForm',
 | |
|     'ProviderCSVForm',
 | |
|     'ProviderNetworkCSVForm',
 | |
| )
 | |
| 
 | |
| 
 | |
| class ProviderCSVForm(NetBoxModelCSVForm):
 | |
|     slug = SlugField()
 | |
| 
 | |
|     class Meta:
 | |
|         model = Provider
 | |
|         fields = (
 | |
|             'name', 'slug', 'account', 'comments',
 | |
|         )
 | |
| 
 | |
| 
 | |
| class ProviderNetworkCSVForm(NetBoxModelCSVForm):
 | |
|     provider = CSVModelChoiceField(
 | |
|         queryset=Provider.objects.all(),
 | |
|         to_field_name='name',
 | |
|         help_text='Assigned provider'
 | |
|     )
 | |
| 
 | |
|     class Meta:
 | |
|         model = ProviderNetwork
 | |
|         fields = [
 | |
|             'provider', 'name', 'service_id', 'description', 'comments',
 | |
|         ]
 | |
| 
 | |
| 
 | |
| class CircuitTypeCSVForm(NetBoxModelCSVForm):
 | |
|     slug = SlugField()
 | |
| 
 | |
|     class Meta:
 | |
|         model = CircuitType
 | |
|         fields = ('name', 'slug', 'description')
 | |
|         help_texts = {
 | |
|             'name': 'Name of circuit type',
 | |
|         }
 | |
| 
 | |
| 
 | |
| class CircuitCSVForm(NetBoxModelCSVForm):
 | |
|     provider = CSVModelChoiceField(
 | |
|         queryset=Provider.objects.all(),
 | |
|         to_field_name='name',
 | |
|         help_text='Assigned provider'
 | |
|     )
 | |
|     type = CSVModelChoiceField(
 | |
|         queryset=CircuitType.objects.all(),
 | |
|         to_field_name='name',
 | |
|         help_text='Type of circuit'
 | |
|     )
 | |
|     status = CSVChoiceField(
 | |
|         choices=CircuitStatusChoices,
 | |
|         help_text='Operational status'
 | |
|     )
 | |
|     tenant = CSVModelChoiceField(
 | |
|         queryset=Tenant.objects.all(),
 | |
|         required=False,
 | |
|         to_field_name='name',
 | |
|         help_text='Assigned tenant'
 | |
|     )
 | |
| 
 | |
|     class Meta:
 | |
|         model = Circuit
 | |
|         fields = [
 | |
|             'cid', 'provider', 'type', 'status', 'tenant', 'install_date', 'termination_date', 'commit_rate',
 | |
|             'description', 'comments',
 | |
|         ]
 |