Exemplo n.º 1
0
    def save(self):
        is_create = self.pk is None and not self.is_draft_for
        is_draft_apply = self.is_draft_for and self.approved

        if is_draft_apply:
            original = Example.objects.get(id=self.is_draft_for.id)
            original.title = self.title
            original.category = self.category
            original.content = self.content
            original.note = self.note
            original.save()
            self.delete()

        if is_create:
            user = self.author

            forum = Forum.objects.get(name=u'Обсуждение рецептов')
            topic = Topic(forum=forum, name=self.title, user=user)
            topic.save()

            self.topic_id = topic.pk

        if not is_draft_apply:
            super(Example, self).save()

        if is_create:
            body = u"""Обсуждение рецепта "%s" (http://djbook.ru%s)."""
            title = self.title
            url = self.get_absolute_url()

            post = Post(topic=topic, user=user, body=body % (title, url))
            post.save()
Exemplo n.º 2
0
    def save(self):
        is_create = self.pk is None and not self.is_draft_for
        is_draft_apply = self.is_draft_for and self.approved

        if is_draft_apply:
            original = Example.objects.get(id=self.is_draft_for.id)
            original.title = self.title
            original.category = self.category
            original.content = self.content
            original.note = self.note
            original.save()
            self.delete()

        if is_create:
            user = self.author

            forum = Forum.objects.get(name=u'Обсуждение рецептов')
            topic = Topic(forum=forum, name=self.title, user=user)
            topic.save()

            self.topic_id = topic.pk

        if not is_draft_apply:
            super(Example, self).save()

        if is_create:
            body = u"""Обсуждение рецепта "%s" (http://djbook.ru%s)."""
            title = self.title
            url = self.get_absolute_url()

            post = Post(topic=topic, user=user,
                        body=body % (title, url))
            post.save()
Exemplo n.º 3
0
    def save(self):
        is_create = self.pk is None

        if is_create:
            user = self.author

            forum = Forum.objects.get(name=u'Обсуждение рецептов')
            topic = Topic(forum=forum, name=self.title, user=user)
            topic.save()

            self.topic_id = topic.pk

        super(Example, self).save()

        if is_create:
            body = u"""Обсуждение рецепта "%s" (http://djbook.ru%s)."""
            title = self.title
            url = self.get_absolute_url()

            post = Post(topic=topic, user=user, body=body % (title, url))
            post.save()
Exemplo n.º 4
0
    def save(self):
        is_create = self.pk is None

        if is_create:
            user = self.author

            forum = Forum.objects.get(name=u'Обсуждение рецептов')
            topic = Topic(forum=forum, name=self.title, user=user)
            topic.save()

            self.topic_id = topic.pk

        super(Example, self).save()

        if is_create:
            body = u"""Обсуждение рецепта "%s" (http://djbook.ru%s)."""
            title = self.title
            url = self.get_absolute_url()

            post = Post(topic=topic, user=user,
                        body=body % (title, url))
            post.save()