Esempio n. 1
0
def people(request, did):
    if not did:
        return HttpResponseRedirect("/")
    query = DUser.objects(uid=did)
    people = None
    if query:
        people = query[0]
    else:
        #TODO remove
        url = ApiOperation.apiGenerator('USER', did)
        api = Api(url=url, api_type='USER', api_id=did)
        processor = UserProcessor(api)
        result = processor.getUser()
        if result:
            people = result
        else:
            return HttpResponseRedirect("/")
        #TODO end
    if people.content and people.content.find('\n') != -1:
        people.content = people.content.split('\n')
    people.image_link = people.image_link.replace('icon/u', 'icon/ul')
    
    try:
        follower = UserProfile.objects.get(did=did).user
    except:
        error_message = "抱歉,该用户还没有注册本网站..."
        return render_to_response('error.html', {'error':error_message,
                'redirect_url':'/people/follow/'},
                context_instance=RequestContext(request))
        
    followed = len(FollowRelation.objects.filter(user=request.user, follower=follower)) > 0
    return render_to_response('people/people.html', 
            {'people': people, 'followed': followed},
            context_instance=RequestContext(request))
Esempio n. 2
0
def downloadBook(bid, old=None):
    url = ApiOperation.apiGenerator('BOOK', bid)
    api = douban.Api(url=url, api_type='BOOK')
    processor = BookProcessor(api)
    if old:
        return processor.getBook(old)
    else:
        return processor.getBook()
Esempio n. 3
0
def downloadBookTags(bid):
    url = ApiOperation.apiGenerator('BOOK_TAGS', bid)
    api = douban.Api(url=url, api_type='BOOK_TAGS')
    processor = BookProcessor(api)
    tags = processor.getBookTags()
    if tags:
        return tags
    else:
        return []