def comments_html(request, comment_type): """Return comment feeds.""" print "comment type: ", comment_type # returns all comments involving any user of an Organization all_comments = Organization.get_org_user_comments(request.user.organization) if comment_type=="organization": # returns all comments made for an Organization comments = Organization.get_org_comments(request.user.organization) elif comment_type=="network": # returns all comments for any networks an Organization is part of comments = Organization.get_network_comments(request.user.organization) elif comment_type=="story": # returns all comments for any story of an Organization comments = Organization.get_story_comments(request.user.organization) elif comment_type=="series": # returns all comments for any series of an Organization comments = Organization.get_series_comments(request.user.organization) elif comment_type=="facet": # returns all comments for any facets of stories of an Organization comments = Organization.get_facet_comments(request.user.organization) comments_html = render_to_string('inbox-comments.html', { 'comments': comments, 'comment_type': comment_type, }) return HttpResponse(comments_html)
def dashboard(request): """ Returns user's unique dashboard. Displays new comments since last_login from any discussions including user. Ex: Felicity S. replied to Series: "Palmer Tech Innovation Conference" discussion Displays table of new content created since last_login Displays any content with deadlines sameday/next day for any content where user is part of team. Displays log of other user activity since last_login Ex: Oliver Q. added "Dhark Indicted" to Story: "Star City Organized Crime Leader Arrested" """ # get user organization organization = request.user.organization # query for new comments since last_login from any discussions the user has participated in recent_comments = User.recent_comments(request.user) # if no new comments, display 10 most recent older comments older_comments = User.inbox_comments(request.user)[:10] if organization: # retrieve all organization comments all_comments = Organization.get_org_comments(organization) # query for new stories shared to network networks = Organization.get_org_networks(organization) # facets where run_date=today running_today = Organization.get_org_stories_running_today(organization) # facets where due_edit=today edit_today = Organization.get_org_stories_due_for_edit_today(organization) else: all_comments = [] networks = [] running_today = [] edit_today = [] shared_networkstories = [] for network in networks: stories = Network.get_network_shared_stories(network) shared_networkstories.extend(stories) shared_networkstories = [story for story in shared_networkstories if story.organization != organization] networkstories = set(shared_networkstories) # query for any new content created since last_login new_stories = Story.objects.filter(creation_date__gte=request.user.last_login)[:8] # if no new stories, display 10 most recent stories old_stories = Story.objects.filter(organization = request.user.organization)[:10] copied_shared_stories = StoryCopyDetail.objects.filter(original_org=request.user.organization) # TODO: query for other user activity since last_login return render(request, 'editorial/dashboard.html', { 'networks': networks, 'recent_comments': recent_comments, 'older_comments': older_comments, 'all_comments': all_comments, 'new_stories': new_stories, 'old_stories': old_stories, 'running_today': running_today, 'edit_today': edit_today, 'shared_networkstories': shared_networkstories, 'copied_shared_stories': copied_shared_stories, })