def save(self, commit=True): inst = self.instance inst.author = self.user inst.preview, inst.text = utils.cut(inst.text) inst.preview = utils.parse(inst.preview, settings.VALID_TAGS, settings.VALID_ATTRS) inst.text = utils.parse(inst.text, settings.VALID_TAGS, settings.VALID_ATTRS) inst = super(CreatePostForm, self).save(commit) Tag.objects.update_tags(inst, inst.raw_tags) inst.create_comment_root() for mention in utils.find_mentions(inst.text): Notify.new_mention_notify(mention, post=inst) if settings.PUBSUB: ping_hub(settings.FEED_URL, hub_url=settings.PUSH_HUB) return inst
def save(self, commit=True): self.instance.author = self.user post = super(CreateAnswerForm, self).save(commit) for answer in self.cleaned_data.get('answers'): Answer.objects.create( post=post, value=answer, ) Tag.objects.update_tags(post, post.raw_tags) post.create_comment_root() for mention in utils.find_mentions(post.text): Notify.new_mention_notify(mention, post=post) if settings.PUBSUB: ping_hub(settings.FEED_URL, hub_url=settings.PUSH_HUB) return post