Skip to content

Commit

Permalink
Remove django-smart-selects from requirements.
Browse files Browse the repository at this point in the history
This dependency is no longer necessary. The database migrations that
referenced the `ChainedForeignKey` field were updated to swap it with a
regular `ForeignKey` field.

While it sounds bad, underneath the `ChainedForeignKey` field was still
just an FK with extra app-level behavior so reverting it to FK is really
a no-op from the perspective of the underlying db schema.
  • Loading branch information
jathanism committed Mar 2, 2018
1 parent 3495329 commit 3bd9b37
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 17 deletions.
1 change: 0 additions & 1 deletion nsot/conf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
'django_extensions',
'django_filters',
'guardian',
'smart_selects',
'rest_framework',
'rest_framework_swagger',
'custom_user',
Expand Down
3 changes: 0 additions & 3 deletions nsot/conf/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
name='favicon'
),

# Smart selects chaining
url(r'^chaining/', include('smart_selects.urls')),

# FE handlers
# Catch index
url(r'^$', FeView.as_view(), name='index'),
Expand Down
3 changes: 1 addition & 2 deletions nsot/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
from macaddress.fields import MACAddressField as BaseMACAddressField
import ipaddress
import logging
from smart_selects.db_fields import ChainedForeignKey
import types

from . import exc


__all__ = (
'BinaryIPAddressField', 'ChainedForeignKey', 'JSONField', 'MACAddressField'
'BinaryIPAddressField', 'JSONField', 'MACAddressField'
)


Expand Down
3 changes: 1 addition & 2 deletions nsot/migrations/0012_auto_20151002_1427.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import unicode_literals

from django.db import models, migrations
import smart_selects.db_fields
import django.db.models.deletion


Expand All @@ -26,7 +25,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='interface',
name='parent',
field=smart_selects.db_fields.ChainedForeignKey(chained_model_field='device', related_name='children', on_delete=django.db.models.deletion.PROTECT, default=None, auto_choose=True, to='nsot.Interface', chained_field='device', blank=True, help_text='Unique ID of the parent Interface.', null=True, verbose_name='Parent'),
field=models.ForeignKey(related_name='children', on_delete=django.db.models.deletion.PROTECT, default=None, to='nsot.Interface', blank=True, help_text='Unique ID of the parent Interface.', null=True, verbose_name='Parent'),
),
migrations.AlterField(
model_name='interface',
Expand Down
3 changes: 1 addition & 2 deletions nsot/migrations/0014_auto_20151002_1653.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import unicode_literals

from django.db import models, migrations
import smart_selects.db_fields
import django.db.models.deletion


Expand All @@ -16,6 +15,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='interface',
name='parent',
field=smart_selects.db_fields.ChainedForeignKey(chained_model_field='device', related_name='children', on_delete=django.db.models.deletion.PROTECT, default=None, to='nsot.Interface', chained_field='device', blank=True, help_text='Unique ID of the parent Interface.', null=True, verbose_name='Parent'),
field=models.ForeignKey(related_name='children', on_delete=django.db.models.deletion.PROTECT, default=None, to='nsot.Interface', blank=True, help_text='Unique ID of the parent Interface.', null=True, verbose_name='Parent'),
),
]
3 changes: 1 addition & 2 deletions nsot/migrations/0015_move_attribute_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import unicode_literals

from django.db import models, migrations
import smart_selects.db_fields
import django.db.models.deletion
import django_extensions.db.fields.json
import nsot.fields
Expand Down Expand Up @@ -111,7 +110,7 @@ class Migration(migrations.Migration):
('speed', models.IntegerField(default=10000, help_text='Integer of Mbps of interface (e.g. 20000 for 20 Gbps). If not provided, defaults to 10000.', db_index=True, blank=True)),
('addresses', models.ManyToManyField(related_name='addresses', through='nsot.Assignment_temp', to='nsot.Network_temp', db_index=True)),
('device', models.ForeignKey(related_name='interfaces', verbose_name='Device', to='nsot.Device_temp', help_text='Unique ID of the connected Device.')),
('parent', smart_selects.db_fields.ChainedForeignKey(chained_model_field='device', related_name='children', on_delete=django.db.models.deletion.PROTECT, default=None, auto_choose=True, to='nsot.Interface_temp', chained_field='device', blank=True, help_text='Unique ID of the parent Interface.', null=True, verbose_name='Parent')),
('parent', models.ForeignKey(related_name='children', on_delete=django.db.models.deletion.PROTECT, default=None, to='nsot.Interface_temp', blank=True, help_text='Unique ID of the parent Interface.', null=True, verbose_name='Parent')),
('site', models.ForeignKey(related_name='interfaces', on_delete=django.db.models.deletion.PROTECT, to='nsot.Site')),
],
),
Expand Down
3 changes: 1 addition & 2 deletions nsot/migrations/0021_remove_resource_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from django.db import models, migrations
import django.db.models.deletion
import django_extensions.db.fields.json
import smart_selects.db_fields


class Migration(migrations.Migration):
Expand Down Expand Up @@ -135,7 +134,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='interface',
name='parent',
field=smart_selects.db_fields.ChainedForeignKey(chained_model_field='device', related_name='children', on_delete=django.db.models.deletion.PROTECT, default=None, to='nsot.Interface', chained_field='device', blank=True, help_text='Unique ID of the parent Interface.', null=True, verbose_name='Parent'),
field=models.ForeignKey(related_name='children', on_delete=django.db.models.deletion.PROTECT, default=None, to='nsot.Interface', blank=True, help_text='Unique ID of the parent Interface.', null=True, verbose_name='Parent'),
),

###############
Expand Down
3 changes: 1 addition & 2 deletions nsot/models/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ class Interface(Resource):
)
)

parent = fields.ChainedForeignKey(
parent = models.ForeignKey(
'self', blank=True, null=True, related_name='children',
default=None, db_index=True, on_delete=models.PROTECT,
chained_field='device', chained_model_field='device',
verbose_name='Parent', help_text='Unique ID of the parent Interface.',
)

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ django-guardian~=1.4.9
django-jinja~=1.4.1
django-macaddress~=1.3.2
django-rest-swagger~=0.3.5
django-smart-selects~=1.3.0
djangorestframework~=3.5.0
djangorestframework-bulk~=0.2.1
drf-extensions~=0.2.8
Expand Down

0 comments on commit 3bd9b37

Please sign in to comment.