Beispiel #1
1
    def save(self):
        if self.forum:
            topic = Topic(forum=self.forum,
                          user=self.user,
                          name=self.cleaned_data['name'])
            topic.save()
            #aumentando 5 puntos al user profile##############
            self.user.get_profile().add_points(5)
            ##################################################
        else:
            topic = self.topic
            #aumentando 5 puntos al user profile##############
            self.user.get_profile().add_points(2)
            ##################################################

        post = Post(topic=topic,
                    user=self.user,
                    user_ip=self.ip,
                    markup=self.user.forum_profile.markup,
                    body=self.cleaned_data['body'])

        post.save()
        if forum_settings.ATTACHMENT_SUPPORT:
            self.save_attachment(post, self.cleaned_data['attachment'])

        return post
Beispiel #2
0
    def save(self):
        if self.forum:
            topic = Topic(forum=self.forum,
                          user=self.user,
                          name=self.cleaned_data['name'])
            topic.save()
        else:
            topic = self.topic

        if self.cleaned_data['subscribe']:
            # User would like to subscripe to this topic
            topic.subscribers.add(self.user)

        post = Post(topic=topic, user=self.user, user_ip=self.ip,
                    markup=self.user.forum_profile.markup,
                    body=self.cleaned_data['body'])

        post.save()
        if self.user.groups.filter(name="New Scratchers").exists():
            tracking_data = dict(**self.request_data)
            tracking_data['permalink'] = self.url
            status = PostStatus.objects.create_for_post(post, **tracking_data)
        if forum_settings.ATTACHMENT_SUPPORT:
            self.save_attachment(post, self.cleaned_data['attachment'])
        return post
Beispiel #3
0
    def save(self):
        if self.forum:
            topic = Topic(forum=self.forum,
                          user=self.user,
                          name=self.cleaned_data['name'])
            topic.save()
        else:
            topic = self.topic

        if self.cleaned_data['subscribe']:
            # User would like to subscripe to this topic
            topic.subscribers.add(self.user)

        post = Post(topic=topic,
                    user=self.user,
                    user_ip=self.ip,
                    markup=self.user.forum_profile.markup,
                    body=self.cleaned_data['body'])

        post.save()
        if self.user.groups.filter(name="New Scratchers").exists():
            tracking_data = dict(**self.request_data)
            tracking_data['permalink'] = self.url
            status = PostStatus.objects.create_for_post(post, **tracking_data)
        if forum_settings.ATTACHMENT_SUPPORT:
            self.save_attachment(post, self.cleaned_data['attachment'])
        return post
Beispiel #4
0
    def save(self):
        from djangobb_forum.models import Forum, Topic, Post
        from accounts.models import User

        is_create = self.pk is None

        if is_create:
            user = User.objects.get(username='******')
            forum = Forum.objects.get(name='Обсуждение рецептов')

            topic = Topic(forum=forum, name=self.title, user=user)
            topic.save()

            self.topic_id = topic.pk

        super(Example, self).save()

        if is_create:
            body_plain = u"""Обсуждение рецепта "%s" (http://djbook.ru%s)."""
            body_html = u"""Обсуждение рецепта &laquo;<a href="%s">%s</a>&raquo;."""
            title = self.title
            url = self.get_absolute_url()

            post = Post(topic=topic, user=user,
                        body=body_plain % (title, url),
                        body_html=body_html % (url, title))
            post.save()
Beispiel #5
0
    def save(self):
        if self.forum:
            topic = Topic(forum=self.forum,
                          user=self.user,
                          name=self.cleaned_data['name'])
            topic.save()
            #aumentando 5 puntos al user profile##############
            self.user.get_profile().add_points(5)
            ##################################################
        else:
            topic = self.topic
            #aumentando 5 puntos al user profile##############
            self.user.get_profile().add_points(2)
            ##################################################


        post = Post(topic=topic, user=self.user, user_ip=self.ip,
                    markup=self.user.forum_profile.markup,
                    body=self.cleaned_data['body'])

        post.save()
        if forum_settings.ATTACHMENT_SUPPORT:
            self.save_attachment(post, self.cleaned_data['attachment'])

        return post
Beispiel #6
0
    def save(self):
        if self.forum:
            topic = Topic(forum=self.forum,
                          user=self.user,
                          name=self.cleaned_data['name'])
            topic.save()
        else:
            topic = self.topic

        post = Post(topic=topic, user=self.user, user_ip=self.ip,
                    markup=self.user.forum_profile.markup,
                    body=self.cleaned_data['body'])

        post.save()
        if forum_settings.ATTACHMENT_SUPPORT:
            self.save_attachment(post, self.cleaned_data['attachment'])
        return post
Beispiel #7
0
    def save(self):
        if self.forum:
            topic = Topic(forum=self.forum,
                          user=self.user,
                          name=self.cleaned_data['name'])
            topic.save()
        else:
            topic = self.topic

        post = Post(topic=topic,
                    user=self.user,
                    user_ip=self.ip,
                    markup=self.user.forum_profile.markup,
                    body=self.cleaned_data['body'])

        post.save()
        if forum_settings.ATTACHMENT_SUPPORT:
            self.save_attachment(post, self.cleaned_data['attachment'])
        return post
Beispiel #8
0
    def save(self):
        if self.forum:
            topic = Topic(forum=self.forum,
                          user=self.user,
                          name=self.cleaned_data['name'])
            topic.save()
        else:
            topic = self.topic

        if self.cleaned_data['subscribe']:
            # User would like to subscripe to this topic
            topic.subscribers.add(self.user)

        post = Post(topic=topic, user=self.user, user_ip=self.ip,
                    markup=self.user.forum_profile.markup,
                    body=self.cleaned_data['body'])

        post.save()
        if forum_settings.ATTACHMENT_SUPPORT:
            self.save_attachment(post, self.cleaned_data['attachment'])
        return post
Beispiel #9
0
    def save(self):
        if self.forum:
            topic = Topic(forum=self.forum,
                          user=self.user,
                          name=self.cleaned_data['name'])
            topic.save()
        else:
            topic = self.topic

        if self.cleaned_data['subscribe']:
            # User would like to subscripe to this topic
            topic.subscribers.add(self.user)

        post = Post(topic=topic, user=self.user, user_ip=self.ip,
                    markup=self.user.forum_profile.markup,
                    body=self.cleaned_data['body'])

        post.save()
        if forum_settings.ATTACHMENT_SUPPORT:
            self.save_attachment(post, self.cleaned_data['attachment'])
        return post
    def forwards(self, orm):
        u"""Create topic for each recipe that already exists."""
        user = User.objects.get(username='******')
        forum = Forum.objects.get(name='Обсуждение рецептов')
        examples = Example.objects.all()

        for item in examples:
            topic = Topic(forum=forum,
                          name=item.title,
                          user=user)
            topic.save()

            body_plain = u"""Обсуждение рецепта "%s" (http://djbook.ru%s)."""
            body_html = u"""Обсуждение рецепта &laquo;<a href="%s">%s</a>&raquo;."""
            title = item.title
            url = item.get_absolute_url()
            post = Post(topic=topic,
                        user=user,
                        body=body_plain % (title, url),
                        body_html=body_html % (url, title))
            post.save()

            item.topic_id = topic.pk
            item.save()
Beispiel #11
0
def new_topic(request, forum_id, subject, text_body, prefix_id='', attachment_id_array=[], group_id=''):
    from djangobb_forum.models import Topic, Post
    t = Topic()
    t.forum_id = int(forum_id)
    t.name = str(subject)
    t.user_id = request.user.pk
    t.save()

    p = Post()
    p.user_id = request.user.pk
    p.topic_id = t.id
    p.body = str(text_body)
    p.save()

    return {
        'result': True,
        'topic_id': t.id,
    }