mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Webhook.http_content_type to slug (#3569)
This commit is contained in:
35
netbox/extras/migrations/0032_3569_webhook_fields.py
Normal file
35
netbox/extras/migrations/0032_3569_webhook_fields.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
WEBHOOK_CONTENTTYPE_CHOICES = (
|
||||
(1, 'application/json'),
|
||||
(2, 'application/x-www-form-urlencoded'),
|
||||
)
|
||||
|
||||
|
||||
def webhook_contenttype_to_slug(apps, schema_editor):
|
||||
Webhook = apps.get_model('extras', 'Webhook')
|
||||
for id, slug in WEBHOOK_CONTENTTYPE_CHOICES:
|
||||
Webhook.objects.filter(http_content_type=str(id)).update(http_content_type=slug)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
atomic = False
|
||||
|
||||
dependencies = [
|
||||
('extras', '0031_3569_exporttemplate_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
||||
# Webhook.http_content_type
|
||||
migrations.AlterField(
|
||||
model_name='webhook',
|
||||
name='http_content_type',
|
||||
field=models.CharField(default='application/json', max_length=50),
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=webhook_contenttype_to_slug
|
||||
),
|
||||
|
||||
]
|
Reference in New Issue
Block a user