outposts: ensure the user and token are created on initial outpost save

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-05-21 15:55:19 +02:00
parent 5c91658484
commit 75d6cd1674
1 changed files with 4 additions and 1 deletions

View File

@ -52,7 +52,7 @@ def m2m_changed_update(sender, instance: Model, action: str, **_):
@receiver(post_save) @receiver(post_save)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def post_save_update(sender, instance: Model, **_): def post_save_update(sender, instance: Model, created: bool, **_):
"""If an Outpost is saved, Ensure that token is created/updated """If an Outpost is saved, Ensure that token is created/updated
If an OutpostModel, or a model that is somehow connected to an OutpostModel is saved, If an OutpostModel, or a model that is somehow connected to an OutpostModel is saved,
@ -63,6 +63,9 @@ def post_save_update(sender, instance: Model, **_):
return return
if not isinstance(instance, UPDATE_TRIGGERING_MODELS): if not isinstance(instance, UPDATE_TRIGGERING_MODELS):
return return
if isinstance(instance, Outpost) and created:
LOGGER.info("New outpost saved, ensuring initial token and user are created")
_ = instance.token
outpost_post_save.delay(class_to_path(instance.__class__), instance.pk) outpost_post_save.delay(class_to_path(instance.__class__), instance.pk)