I've added MentionableMixin to a Post model, that has statuses of "Draft" and "Published", and I'm trying to work out how I can ensure that webmentions are only sent when a Post object's saved and it's in "Published" state. At the moment, overriding the save() method, I can't figure out a way to do it.
My initial thought is to give MentionableMixin a get_allow_outgoing_webmentions() method that, by default, just returns the value of allow_outgoing_webmentions. Child classes could override this with something like:
def get_allow_outgoing_webmentions(self):
if self.allow_outgoing_webmentions and self.status == LIVE:
return True
else:
return False
Then the existing MentionableMixin.save() method could check that instead of allow_outgoing_webmentions before handling them.
I guess add a matching get_allow_incoming_webmentions() method for completeness too.
I've added
MentionableMixin
to aPost
model, that has statuses of "Draft" and "Published", and I'm trying to work out how I can ensure that webmentions are only sent when aPost
object's saved and it's in "Published" state. At the moment, overriding thesave()
method, I can't figure out a way to do it.My initial thought is to give
MentionableMixin
aget_allow_outgoing_webmentions()
method that, by default, just returns the value ofallow_outgoing_webmentions
. Child classes could override this with something like:Then the existing
MentionableMixin.save()
method could check that instead ofallow_outgoing_webmentions
before handling them.I guess add a matching
get_allow_incoming_webmentions()
method for completeness too.