Update 290_webhooks.py

Move to a more standard method of object handling
This commit is contained in:
Schylar Utley 2021-01-20 21:42:24 -06:00 committed by Christian Mäder
parent 2e5d84612d
commit e4e2c788a9

View File

@ -20,8 +20,7 @@ for hook in webhooks:
obj_types = hook.pop('object_types')
obj_type_ids = [ get_content_type_id(obj) for obj in obj_types ]
if obj_type_ids is not None:
webhook = Webhook(**hook)
if not Webhook.objects.filter(name=webhook.name):
webhook.save()
webhook, created = Webhook.objects.get_or_create(**hook)
if created:
webhook.content_types.set(obj_type_ids)
print("🖥️ Created Webhook {0}".format(webhook.name))