コード例 #1
0
ファイル: networkviews.py プロジェクト: KaiBot3000/facet
def network_stories(request):
    """ Displays a filterable table of stories marked as shared/ready to share by any
    organizations that a user's organization is a part of.

    Initial display organizes content by story>facet>est. run date
    Filterable by story name, facet type, facet name, due for edit, est. run date, credit,
    editor, status.

    Stories marked as share appear but are greyed out/inaccessible until the owner marks
    them as Ready to Share. (This is so partners know it will exist and can plan to incorporate
    it once it becomes available.)
    """

    org_id = request.user.organization_id
    organization = get_object_or_404(Organization, id=org_id)

    networks = Organization.get_org_networks(organization)

    shared_networkstories = []
    for network in networks:
        stories = Network.get_network_shared_stories(network)
        shared_networkstories.extend(stories)

    networkstories = set(shared_networkstories)

    return render(request, 'editorial/networkstories.html', {
        'networkstories': networkstories,
        })
コード例 #2
0
ファイル: generalviews.py プロジェクト: ProjectFacet/facet
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,
    })