Group serializer special v1 functionality

Returns a related `inventory_source` and related link for groups
if accessed from /api/v1/, but not for API v2.
Also inserts corresponding fields to inventory source serializer.
Keep migrated manual sources and auto-create in API v1.
This commit is contained in:
AlanCoding
2017-04-13 11:10:34 -04:00
parent 84c6d41bd4
commit 7223177684
8 changed files with 121 additions and 8 deletions

View File

@@ -28,7 +28,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='inventorysource',
name='deprecated_group',
field=models.ForeignKey(related_name='deprecated_inventory_source', default=None, null=True, to='main.Group'),
field=models.OneToOneField(related_name='deprecated_inventory_source', null=True, default=None, to='main.Group'),
),
migrations.AlterField(
model_name='inventorysource',

View File

@@ -19,7 +19,6 @@ class Migration(migrations.Migration):
operations = [
# Inventory Refresh
migrations.RunPython(migration_utils.set_current_apps_for_migrations),
migrations.RunPython(invsrc.remove_manual_inventory_sources),
migrations.RunPython(invsrc.remove_inventory_source_with_no_inventory_link),
migrations.RunPython(invsrc.rename_inventory_sources),
]

View File

@@ -10,6 +10,7 @@ def remove_manual_inventory_sources(apps, schema_editor):
Group creation and we would use the parent Group as our interface for the user.
During that process we would create InventorySource that had a source of "manual".
'''
# TODO: use this in the 3.3 data migrations
InventorySource = apps.get_model('main', 'InventorySource')
# see models/inventory.py SOURCE_CHOICES - ('', _('Manual'))
logger.debug("Removing all Manual InventorySource from database.")