mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-09 00:58:16 -06:00
PEP 8 resolution
This commit is contained in:
parent
780f3cda5b
commit
761ac9230b
@ -1294,7 +1294,6 @@ class Device(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
|
||||
objects = DeviceManager()
|
||||
tags = TaggableManager()
|
||||
|
||||
|
||||
csv_headers = [
|
||||
'name', 'device_role', 'tenant', 'manufacturer', 'model_name', 'platform', 'serial', 'asset_tag', 'status',
|
||||
'site', 'rack_group', 'rack_name', 'position', 'face', 'comments',
|
||||
|
@ -130,8 +130,6 @@ EMAIL_SUBJECT_PREFIX = '[NetBox] '
|
||||
|
||||
# Installed applications
|
||||
INSTALLED_APPS = [
|
||||
'corsheaders',
|
||||
'debug_toolbar',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
@ -139,9 +137,10 @@ INSTALLED_APPS = [
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.humanize',
|
||||
'corsheaders',
|
||||
'debug_toolbar',
|
||||
'django_filters',
|
||||
'django_tables2',
|
||||
'drf_yasg',
|
||||
'mptt',
|
||||
'rest_framework',
|
||||
'taggit',
|
||||
@ -156,6 +155,7 @@ INSTALLED_APPS = [
|
||||
'users',
|
||||
'utilities',
|
||||
'virtualization',
|
||||
'drf_yasg',
|
||||
]
|
||||
|
||||
# Only load django-rq if the webhook backend is enabled
|
||||
|
@ -43,6 +43,7 @@ class SecretObjectRelatedField(serializers.RelatedField):
|
||||
dict.update({'class': 'device'})
|
||||
return dict
|
||||
|
||||
|
||||
class SecretSerializer(TaggitSerializer, CustomFieldModelSerializer):
|
||||
object = SecretObjectRelatedField(queryset=Secret.objects.all(), required=False)
|
||||
role = NestedSecretRoleSerializer()
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def migrate_device_secret(apps, schema_editor):
|
||||
"""
|
||||
Move data from device foreign key into GenericForeignKey
|
||||
@ -17,6 +18,7 @@ def migrate_device_secret(apps, schema_editor):
|
||||
secret.object_id = secret.device.pk
|
||||
secret.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
@ -25,5 +27,5 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(migrate_device_secret)
|
||||
migrations.RunPython(migrate_device_secret)
|
||||
]
|
||||
|
@ -350,7 +350,7 @@ class Secret(ChangeLoggedModel, CustomFieldModel):
|
||||
content_type = models.ForeignKey(
|
||||
ContentType,
|
||||
on_delete=models.CASCADE,
|
||||
default= ContentType.objects.get(app_label='dcim', model='device').pk
|
||||
default=ContentType.objects.get(app_label='dcim', model='device').pk
|
||||
)
|
||||
object_id = models.PositiveIntegerField(default=1)
|
||||
object = GenericForeignKey('content_type', 'object_id')
|
||||
|
@ -100,9 +100,9 @@ def secret_add(request, pk):
|
||||
object = path.split(os.sep)[2]
|
||||
secret = {
|
||||
'devices': lambda pk: Secret(
|
||||
object_id=pk,
|
||||
content_type=ContentType.objects.get(app_label='dcim',model='device')
|
||||
)
|
||||
object_id=pk,
|
||||
content_type=ContentType.objects.get(app_label='dcim', model='device')
|
||||
)
|
||||
}[object](pk)
|
||||
|
||||
session_key = get_session_key(request)
|
||||
|
Loading…
Reference in New Issue
Block a user