def get_comments_received_content(request): if request.is_ajax(): user_id = request.GET.get("user_id") user = get_object_or_404(User, id=user_id) notification_list = NotificationService.get_comment_reply_notifications( user) comment_list = list() # get comment list for notification in notification_list: comment = notification.content_object # add related notification field comment.related_notification_id = notification.id comment.unread = notification.unread comment_list.append(comment) comment_list = sorted(comment_list, key=lambda x: x.publish_time, reverse=True) page = request.GET.get('page') comments, page_list = BlogService.get_paginated_items( comment_list, page) context = {} context['comments'] = comments context['page_list'] = page_list context['origin_ajax_url'] = request.get_full_path() return render(request, "accounts/comment_received.html", context) else: raise Http404("Page not found!")
def get_subscribe_blogs_content(request): if request.is_ajax(): user_id = request.GET.get("user_id") user = get_object_or_404(User, id=user_id) notification_list = NotificationService.get_subscribe_blog_notifications( user) blog_list = list() # get blog list for notification in notification_list: blog = notification.content_object # add related notification field blog.related_notification_id = notification.id blog.unread = notification.unread blog_list.append(blog) blog_list = sorted(blog_list, key=lambda x: x.publish_time, reverse=True) page = request.GET.get('page') blogs, page_list = BlogService.get_paginated_items(blog_list, page) context = {} context['blogs'] = blogs context['page_list'] = page_list context['origin_ajax_url'] = request.get_full_path() return render(request, "accounts/blog_posts.html", context) else: raise Http404("Page not found!")
def get_blog_posts_content(request): if request.is_ajax(): user_id = request.GET.get("user_id") user = get_object_or_404(User, id=user_id) blog_list = Blog.objects.filter(author=user).order_by('-publish_time') page = request.GET.get('page') blogs, page_list = BlogService.get_paginated_items(blog_list, page) context = {} context['blogs'] = blogs context['page_list'] = page_list context['origin_ajax_url'] = request.get_full_path() return render(request, "accounts/blog_posts.html", context) else: raise Http404("Page not found!")
def get_at_content(request): if request.is_ajax(): user_id = request.GET.get("user_id") user = get_object_or_404(User, id=user_id) at_blog_notification_list = NotificationService.get_at_blog_notifications( user) at_comment_notification_list = NotificationService.get_at_comment_notifications( user) at_notifications = [] for ind in range(len(at_blog_notification_list)): at_blog_notification_list[ind].src = "blog" at_notifications.append(at_blog_notification_list[ind]) for ind in range(len(at_comment_notification_list)): at_comment_notification_list[ind].src = "comment" at_notifications.append(at_comment_notification_list[ind]) at_list = list() # get obj list for notification in at_notifications: obj = notification.content_object # add related notification field obj.related_notification_id = notification.id obj.unread = notification.unread obj.src = notification.src at_list.append(obj) at_list = sorted(at_list, key=lambda x: x.publish_time, reverse=True) page = request.GET.get('page') items, page_list = BlogService.get_paginated_items(at_list, page) context = {} context['items'] = items context['page_list'] = page_list context['origin_ajax_url'] = request.get_full_path() return render(request, "accounts/at_received.html", context) else: raise Http404("Page not found!")