def refresh_index(request, lastid, pagenumber): url = request.META['HTTP_REFERER'] usere = r'(.*)/user/(?P<username>[^\?\/]*)' publice = r'(.*)/public_timeline' lastid=int(lastid) user_timeline = re.match(usere, url) public_timeline = re.match(publice, url) if user_timeline: latest_post_list = uapi.user_timeline(user_timeline.group('username'), request, paginated=False) elif public_timeline: latest_post_list = uapi.public_timeline(request, paginated=False) else: try: latest_post_list = uapi.own_timeline(request, paginated=False) except: latest_post_list = uapi.public_timeline(request, paginated=False) lastpost = Post.objects.filter(pk=lastid)[0] latest_post_list = latest_post_list.filter(pub_date__gt=lastpost.pub_date) if latest_post_list: latest_post_list = paginate_list(request, latest_post_list, int(pagenumber)) return render_to_response('status/refresh.html', {'latest_post_list': latest_post_list }, context_instance=RequestContext(request)) else: return HttpResponse("")
def refresh_index(request, lastid=1, latest_post_list=None): url = request.META.get('HTTP_REFERER', '/public_timeline') usere = r'(.*)/user/(?P<username>[^\?\/]*)' publice = r'(.*)/public_timeline' lastid = int(lastid) if not lastid: lastid = 1 user_timeline = re.match(usere, url) public_timeline = re.match(publice, url) if latest_post_list: pass elif user_timeline: latest_post_list = uapi.user_timeline(user_timeline.group('username'), request, paginated=False) elif public_timeline: latest_post_list = uapi.public_timeline(request, paginated=False) else: try: latest_post_list = uapi.own_timeline(request, paginated=False) except: latest_post_list = uapi.public_timeline(request, paginated=False) try: lastpost = Post.active().get(pk=lastid) if request.GET.get('viewmore', False): filter = Q(pub_date__lt=lastpost.pub_date) latest_post_list = latest_post_list.filter( filter)[:settings.POST_PER_PAGE] else: filter = Q(pub_date__gt=lastpost.pub_date) latest_post_list = latest_post_list.filter(filter) return render_to_response('status/refresh.html', {'latest_post_list': latest_post_list}, context_instance=RequestContext(request)) except: return HttpResponse("")
def refresh_index(request, lastid=1, latest_post_list=None): url = request.META.get('HTTP_REFERER', '/public_timeline') usere = r'(.*)/user/(?P<username>[^\?\/]*)' publice = r'(.*)/public_timeline' lastid=int(lastid) if not lastid: lastid = 1 user_timeline = re.match(usere, url) public_timeline = re.match(publice, url) if latest_post_list: pass elif user_timeline: latest_post_list = uapi.user_timeline(user_timeline.group('username'), request, paginated=False) elif public_timeline: latest_post_list = uapi.public_timeline(request, paginated=False) else: try: latest_post_list = uapi.own_timeline(request, paginated=False) except: latest_post_list = uapi.public_timeline(request, paginated=False) try: lastpost = Post.active().get(pk=lastid) if request.GET.get('viewmore', False): filter = Q(pub_date__lt=lastpost.pub_date) latest_post_list = latest_post_list.filter(filter)[:settings.POST_PER_PAGE] else: filter = Q(pub_date__gt=lastpost.pub_date) latest_post_list = latest_post_list.filter(filter) return render_to_response('status/refresh.html', {'latest_post_list': latest_post_list }, context_instance=RequestContext(request)) except: return HttpResponse("")
def user(request, user_name): u = get_object_or_404(User, username=user_name) latest_post_list = uapi.user_timeline(user_name, request) return show_statuses(request, latest_post_list, user=u)
def user_timeline(request, username): posts = uapi.user_timeline(username, paginated=False)[:20] posts = [jsonize_post(i) for i in posts] return HttpResponse(json.dumps(posts), mimetype='application/json')
def items(self, obj): sweetT = "%s: %s" sweets = uapi.user_timeline(obj.username, paginated=False)[:20] for sweet in sweets: sweet.text = sweetT % (sweet.user.username, sweet.text) return sweets