def sync(client, article, social_type): if article.status == 2 \ and article.share \ and article.shares.filter(type=social_type).count() == 0: share_id = client.update_status(get_sync_content(article, client, social_type)) content_type = ContentType.objects.get(model='article') share = SocialItem(share_id=share_id, content_type=content_type, type=social_type, object_id=article.id) share.save()
def renren_share(sender, instance, **kwargs): article = instance if settings.ENABLE_RENREN_ACCOUNT \ and article.status == 2 \ and article.share \ and article.shares.filter(type=3).count() == 0: content = u'残阳似血的博客发表了文章《%s》 - %s' % (article.title, strip_html(article.content[:100]+"...")) content = content.encode('utf-8') renren_share = renren_client('share.share', url='%s%s' % (settings.SITE, article.get_absolute_url()), comment=content, type=6) if 'error_code' in renren_share and renren_share['error_code'] != 0: return share_id = renren_share['id'] # 6 in renren api means this is a url content_type = ContentType.objects.get(model='article') share = SocialItem(share_id=share_id, content_type=content_type, type=3, object_id=article.id) share.save()