def get_notifications(request): message_type = request.GET.get("type", "unread") endtime = request.GET.get("endtime") skip = int(request.GET.get("skip", 0)) try: t = time.strptime(endtime, TIME_STRF) endtime = datetime(*t[:6], tzinfo=CMT8()) itmes = {} if message_type == "unread": items = get_unread_message_list(request.user.id, endtime, skip, PAGE_COUNT - 1) else: items = get_message_list(request.user.id, endtime, skip, PAGE_COUNT - 1) html_str = render_to_string("message_list.html", items) endtime = None if items["endtime"]: endtime = items["endtime"].strftime(TIME_STRF) return HttpResponse( json.dumps({ "html": html_str, "count": items["count"], "endtime": endtime })) except Exception, e: return HttpResponse( json.dumps({ "html": "", "count": None, "endtime": None }))
def get_notification_list(request): message_type = request.GET.get("type", "unread") itmes = {} if message_type == "unread": items = get_unread_message_list(request.user.id, skip=0, count=19) else: items = get_message_list(request.user.id, skip=0, count=19) items["notification_type"] = message_type return render_to_response("message.html", items, context_instance=RequestContext(request))