-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaces device_role with role on device model (#13342)
* replaces device_role with role on device model #6391 * fixes lint issue #6391 * revert the database user * revert test_runner comment * changes as per review * Update references to device_role column in UserConfigs --------- Co-authored-by: Jeremy Stretch <[email protected]>
- Loading branch information
1 parent
79030ec
commit 0bb86f1
Showing
37 changed files
with
422 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
netbox/dcim/migrations/0181_rename_device_role_device_role.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from django.db import migrations | ||
|
||
|
||
def update_table_configs(apps, schema_editor): | ||
""" | ||
Replace the `device_role` column in DeviceTable configs with `role`. | ||
""" | ||
UserConfig = apps.get_model('users', 'UserConfig') | ||
|
||
for table in ('DeviceTable', 'DeviceBayTable'): | ||
for config in UserConfig.objects.filter(**{f'data__tables__{table}__columns__contains': 'device_role'}): | ||
config.data['tables'][table]['columns'] = [ | ||
'role' if x == 'device_role' else x | ||
for x in config.data['tables'][table]['columns'] | ||
] | ||
config.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dcim', '0180_powerfeed_tenant'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='device', | ||
old_name='device_role', | ||
new_name='role', | ||
), | ||
migrations.RunPython( | ||
code=update_table_configs, | ||
reverse_code=migrations.RunPython.noop | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.