Update 290_webhooks.py
Move to a more standard method of object handling
This commit is contained in:
parent
2e5d84612d
commit
e4e2c788a9
@ -20,8 +20,7 @@ for hook in webhooks:
|
|||||||
obj_types = hook.pop('object_types')
|
obj_types = hook.pop('object_types')
|
||||||
obj_type_ids = [ get_content_type_id(obj) for obj in obj_types ]
|
obj_type_ids = [ get_content_type_id(obj) for obj in obj_types ]
|
||||||
if obj_type_ids is not None:
|
if obj_type_ids is not None:
|
||||||
webhook = Webhook(**hook)
|
webhook, created = Webhook.objects.get_or_create(**hook)
|
||||||
if not Webhook.objects.filter(name=webhook.name):
|
if created:
|
||||||
webhook.save()
|
|
||||||
webhook.content_types.set(obj_type_ids)
|
webhook.content_types.set(obj_type_ids)
|
||||||
print("🖥️ Created Webhook {0}".format(webhook.name))
|
print("🖥️ Created Webhook {0}".format(webhook.name))
|
||||||
|
Loading…
Reference in New Issue
Block a user