Rename url to source_url

This commit is contained in:
jeremystretch 2023-02-01 20:50:48 -05:00
parent 0b610c6c1d
commit 81b3062e1e
7 changed files with 13 additions and 13 deletions

View File

@ -31,8 +31,8 @@ class DataSourceSerializer(NetBoxModelSerializer):
class Meta:
model = DataSource
fields = [
'id', 'url', 'display', 'name', 'type', 'url', 'enabled', 'status', 'description', 'comments', 'parameters',
'ignore_rules', 'created', 'last_updated', 'file_count',
'id', 'url', 'display', 'name', 'type', 'source_url', 'enabled', 'status', 'description', 'comments',
'parameters', 'ignore_rules', 'created', 'last_updated', 'file_count',
]

View File

@ -11,5 +11,5 @@ class DataSourceImportForm(NetBoxModelImportForm):
class Meta:
model = DataSource
fields = (
'name', 'type', 'url', 'enabled', 'description', 'comments', 'parameters', 'ignore_rules',
'name', 'type', 'source_url', 'enabled', 'description', 'comments', 'parameters', 'ignore_rules',
)

View File

@ -11,14 +11,14 @@ __all__ = (
class DataSourceForm(NetBoxModelForm):
# fieldsets = (
# ('Source', ('name', 'type', 'url', 'enabled', 'description')),
# ('Source', ('name', 'type', 'source_url', 'enabled', 'description')),
# ('Backend', ('parameters', 'ignore_rules')),
# )
class Meta:
model = DataSource
fields = [
'name', 'type', 'url', 'enabled', 'description', 'comments', 'ignore_rules',
'name', 'type', 'source_url', 'enabled', 'description', 'comments', 'ignore_rules',
]
widgets = {
'type': StaticSelect(

View File

@ -1,4 +1,4 @@
# Generated by Django 4.1.5 on 2023-02-01 20:27
# Generated by Django 4.1.5 on 2023-02-02 01:47
import django.core.validators
from django.db import migrations, models
@ -27,7 +27,7 @@ class Migration(migrations.Migration):
('comments', models.TextField(blank=True)),
('name', models.CharField(max_length=100, unique=True)),
('type', models.CharField(default='local', max_length=50)),
('url', models.CharField(max_length=200)),
('source_url', models.CharField(max_length=200)),
('status', models.CharField(default='new', editable=False, max_length=50)),
('enabled', models.BooleanField(default=True)),
('ignore_rules', models.TextField(blank=True)),

View File

@ -23,8 +23,8 @@ from ..exceptions import SyncError
from ..signals import post_sync, pre_sync
__all__ = (
'DataSource',
'DataFile',
'DataSource',
)
logger = logging.getLogger('netbox.core.data')
@ -43,7 +43,7 @@ class DataSource(PrimaryModel):
choices=DataSourceTypeChoices,
default=DataSourceTypeChoices.LOCAL
)
url = models.CharField(
source_url = models.CharField(
max_length=200,
verbose_name=_('URL')
)
@ -91,7 +91,7 @@ class DataSource(PrimaryModel):
@property
def url_scheme(self):
return urlparse(self.url).scheme.lower()
return urlparse(self.source_url).scheme.lower()
@property
def ready_for_sync(self):
@ -129,7 +129,7 @@ class DataSource(PrimaryModel):
backend_cls = registry['data_backends'].get(self.type)
backend_params = self.parameters or {}
return backend_cls(self.url, **backend_params)
return backend_cls(self.source_url, **backend_params)
def sync(self):
"""

View File

@ -7,7 +7,7 @@ class DataSourceIndex(SearchIndex):
model = models.DataSource
fields = (
('name', 100),
('url', 300),
('source_url', 300),
('description', 500),
('comments', 5000),
)

View File

@ -26,7 +26,7 @@ class DataSourceTable(NetBoxTable):
class Meta(NetBoxTable.Meta):
model = DataSource
fields = (
'pk', 'id', 'name', 'type', 'status', 'enabled', 'url', 'description', 'comments', 'parameters', 'created',
'pk', 'id', 'name', 'type', 'status', 'enabled', 'source_url', 'description', 'comments', 'parameters', 'created',
'last_updated', 'file_count',
)
default_columns = ('pk', 'name', 'type', 'status', 'enabled', 'description', 'file_count')