Exemplo n.º 1
0
        super(Comment, self).parse(response)

        if '_' not in str(self.remote_id):
            self.remote_id = '%s_%s' % (self.post.remote_id.split('_')[0], self.remote_id)

        for field_name in ['likes']:
            if field_name in response and 'count' in response[field_name]:
                setattr(self, field_name, response.pop(field_name)['count'])

        self.author = User.objects.get_or_create(remote_id=response['uid'])[0]

        if 'reply_to_uid' in response:
            self.reply_for = User.objects.get_or_create(remote_id=response['reply_to_uid'])[0]
        if 'reply_to_cid' in response:
            try:
                self.reply_to = Comment.objects.get(remote_id=response['reply_to_cid'])
            except:
                pass

Group.add_to_class('wall_posts', generic.GenericRelation(Post, content_type_field='wall_owner_content_type', object_id_field='wall_owner_id', related_name='group_wall', verbose_name=u'Сообщения на стене'))
User.add_to_class('wall_posts', generic.GenericRelation(Post, content_type_field='wall_owner_content_type', object_id_field='wall_owner_id', related_name='user_wall', verbose_name=u'Сообщения на стене'))

Group.add_to_class('posts', generic.GenericRelation(Post, content_type_field='author_content_type', object_id_field='author_id', related_name='group', verbose_name=u'Сообщения'))
User.add_to_class('posts', generic.GenericRelation(Post, content_type_field='author_content_type', object_id_field='author_id', related_name='user', verbose_name=u'Сообщения'))

Group.add_to_class('comments', generic.GenericRelation(Comment, content_type_field='author_content_type', object_id_field='author_id', related_name='group', verbose_name=u'Комментарии'))
User.add_to_class('comments', generic.GenericRelation(Comment, content_type_field='author_content_type', object_id_field='author_id', related_name='user', verbose_name=u'Комментарии'))

Group.add_to_class('replies', generic.GenericRelation(Comment, content_type_field='reply_for_content_type', object_id_field='reply_for_id', related_name='group_wall_reply', verbose_name=u'Ответы на комментарии'))
User.add_to_class('replies', generic.GenericRelation(Comment, content_type_field='reply_for_content_type', object_id_field='reply_for_id', related_name='user_wall_reply', verbose_name=u'Ответы на комментарии'))
Exemplo n.º 2
0
        super(Post, self).parse(response)

        self.remote_id = '%s_%s' % (self.owner_remote_id, self.remote_id)

    def fetch_statistic(self, *args, **kwargs):
        if 'vkontakte_wall_statistic' not in settings.INSTALLED_APPS:
            raise ImproperlyConfigured(
                "Application 'vkontakte_wall_statistic' not in INSTALLED_APPS")

        from vkontakte_wall_statistic.models import PostStatistic
        return PostStatistic.remote.fetch(post=self, *args, **kwargs)

    def fetch_reach(self, *args, **kwargs):
        if 'vkontakte_wall_statistic' not in settings.INSTALLED_APPS:
            raise ImproperlyConfigured(
                "Application 'vkontakte_wall_statistic' not in INSTALLED_APPS")

        from vkontakte_wall_statistic.models import PostReach
        return PostReach.remote.fetch(post=self, *args, **kwargs)


Group.add_to_class('wall_posts', generic.GenericRelation(
    Post, content_type_field='owner_content_type', object_id_field='owner_id', related_query_name='group_wall', verbose_name=u'Сообщения на стене'))
User.add_to_class('wall_posts', generic.GenericRelation(
    Post, content_type_field='owner_content_type', object_id_field='owner_id', related_query_name='user_wall', verbose_name=u'Сообщения на стене'))

Group.add_to_class('posts', generic.GenericRelation(
    Post, content_type_field='author_content_type', object_id_field='author_id', related_query_name='group', verbose_name=u'Сообщения'))
User.add_to_class('posts', generic.GenericRelation(
    Post, content_type_field='author_content_type', object_id_field='author_id', related_query_name='user', verbose_name=u'Сообщения'))
Exemplo n.º 3
0
        super(Post, self).parse(response)

        self.remote_id = '%s_%s' % (self.owner_remote_id, self.remote_id)

    def fetch_statistic(self, *args, **kwargs):
        if 'vkontakte_wall_statistic' not in settings.INSTALLED_APPS:
            raise ImproperlyConfigured(
                "Application 'vkontakte_wall_statistic' not in INSTALLED_APPS")

        from vkontakte_wall_statistic.models import PostStatistic
        return PostStatistic.remote.fetch(post=self, *args, **kwargs)

    def fetch_reach(self, *args, **kwargs):
        if 'vkontakte_wall_statistic' not in settings.INSTALLED_APPS:
            raise ImproperlyConfigured(
                "Application 'vkontakte_wall_statistic' not in INSTALLED_APPS")

        from vkontakte_wall_statistic.models import PostReach
        return PostReach.remote.fetch(post=self, *args, **kwargs)


Group.add_to_class('wall_posts', generic.GenericRelation(
    Post, content_type_field='owner_content_type', object_id_field='owner_id', related_query_name='group_wall', verbose_name=u'Сообщения на стене'))
User.add_to_class('wall_posts', generic.GenericRelation(
    Post, content_type_field='owner_content_type', object_id_field='owner_id', related_query_name='user_wall', verbose_name=u'Сообщения на стене'))

Group.add_to_class('posts', generic.GenericRelation(
    Post, content_type_field='author_content_type', object_id_field='author_id', related_query_name='group', verbose_name=u'Сообщения'))
User.add_to_class('posts', generic.GenericRelation(
    Post, content_type_field='author_content_type', object_id_field='author_id', related_query_name='user', verbose_name=u'Сообщения'))
Exemplo n.º 4
0
        if 'reply_to_uid' in response:
            self.reply_for = User.objects.get_or_create(
                remote_id=response['reply_to_uid'])[0]
        if 'reply_to_cid' in response:
            try:
                self.reply_to = Comment.objects.get(
                    remote_id=response['reply_to_cid'])
            except:
                pass


Group.add_to_class(
    'wall_posts',
    generic.GenericRelation(Post,
                            content_type_field='wall_owner_content_type',
                            object_id_field='wall_owner_id',
                            related_name='group_wall',
                            verbose_name=u'Сообщения на стене'))
User.add_to_class(
    'wall_posts',
    generic.GenericRelation(Post,
                            content_type_field='wall_owner_content_type',
                            object_id_field='wall_owner_id',
                            related_name='user_wall',
                            verbose_name=u'Сообщения на стене'))

Group.add_to_class(
    'posts',
    generic.GenericRelation(Post,
                            content_type_field='author_content_type',