Exemplo n.º 1
0
def media_home(request, media, page, **kwargs):
    """
    'Homepage' of a MediaEntry()
    """
    comment_id = request.matchdict.get('comment', None)
    if comment_id:
        if request.user:
            mark_comment_notification_seen(comment_id, request.user)

        pagination = Pagination(
            page, media.get_comments(
                mg_globals.app_config['comments_ascending']),
            MEDIA_COMMENTS_PER_PAGE,
            comment_id)
    else:
        pagination = Pagination(
            page, media.get_comments(
                mg_globals.app_config['comments_ascending']),
            MEDIA_COMMENTS_PER_PAGE)

    comments = pagination()

    comment_form = user_forms.MediaCommentForm(request.form)

    media_template_name = media.media_manager.display_template

    return render_to_response(
        request,
        media_template_name,
        {'media': media,
         'comments': comments,
         'pagination': pagination,
         'comment_form': comment_form,
         'app_config': mg_globals.app_config})
Exemplo n.º 2
0
def media_home(request, media, page, **kwargs):
    """
    'Homepage' of a MediaEntry()
    """
    comment_id = request.matchdict.get("comment", None)
    if comment_id:
        if request.user:
            mark_comment_notification_seen(comment_id, request.user)

        pagination = Pagination(
            page, media.get_comments(mg_globals.app_config["comments_ascending"]), MEDIA_COMMENTS_PER_PAGE, comment_id
        )
    else:
        pagination = Pagination(
            page, media.get_comments(mg_globals.app_config["comments_ascending"]), MEDIA_COMMENTS_PER_PAGE
        )

    comments = pagination()

    comment_form = user_forms.MediaCommentForm(request.form)

    media_template_name = media.media_manager.display_template

    return render_to_response(
        request,
        media_template_name,
        {
            "media": media,
            "comments": comments,
            "pagination": pagination,
            "comment_form": comment_form,
            "app_config": mg_globals.app_config,
        },
    )
Exemplo n.º 3
0
def mark_all_comment_notifications_seen(request):
    """
    Marks all comment notifications seen.
    """
    for comment in get_notifications(request.user.id):
        mark_comment_notification_seen(comment.subject_id, request.user)

    if request.GET.get('next'):
        return redirect(request, location=request.GET.get('next'))
    else:
        return redirect(request, 'index')
Exemplo n.º 4
0
def mark_all_comment_notifications_seen(request):
    """
    Marks all comment notifications seen.
    """
    for comment in get_notifications(request.user.id):
        mark_comment_notification_seen(comment.subject_id, request.user)

    if request.GET.get("next"):
        return redirect(request, location=request.GET.get("next"))
    else:
        return redirect(request, "index")
Exemplo n.º 5
0
def mark_all_comment_notifications_seen(request):
    """
    Marks all comment notifications seen.
    """
    for comment in get_notifications(request.user.id):
        mark_comment_notification_seen(
            comment.obj().get_comment_link().id,
            request.user
        )

    if request.GET.get('next'):
        return redirect(request, location=request.GET.get('next'))
    else:
        return redirect(request, 'index')
def media_home(request, media, page, **kwargs):
    """
    'Homepage' of a MediaEntry()
    """
    comment_id = request.matchdict.get('comment', None)
    if comment_id:
        if request.user:
            mark_comment_notification_seen(comment_id, request.user)

        pagination = Pagination(
            page, media.get_comments(
                mg_globals.app_config['comments_ascending']),
            MEDIA_COMMENTS_PER_PAGE,
            comment_id)
    else:
        pagination = Pagination(
            page, media.get_comments(
                mg_globals.app_config['comments_ascending']),
            MEDIA_COMMENTS_PER_PAGE)

    comments = pagination()

    comment_form = user_forms.MediaCommentForm(request.form)

    media_template_name = media.media_manager.display_template

    context = {
        'media': media,
        'comments': comments,
        'pagination': pagination,
        'comment_form': comment_form,
        'app_config': mg_globals.app_config}

    # Since the media template name gets swapped out for each media
    # type, normal context hooks don't work if you want to affect all
    # media displays.  This gives a general purpose hook.
    context = hook_transform(
        "media_home_context", context)

    return render_to_response(
        request,
        media_template_name,
        context)
Exemplo n.º 7
0
def media_home(request, media, page, **kwargs):
    """
    'Homepage' of a MediaEntry()
    """
    comment_id = request.matchdict.get('comment', None)
    if comment_id:
        if request.user:
            mark_comment_notification_seen(comment_id, request.user)

        pagination = Pagination(
            page, media.get_comments(
                mg_globals.app_config['comments_ascending']),
            MEDIA_COMMENTS_PER_PAGE,
            comment_id)
    else:
        pagination = Pagination(
            page, media.get_comments(
                mg_globals.app_config['comments_ascending']),
            MEDIA_COMMENTS_PER_PAGE)

    comments = pagination()

    comment_form = user_forms.MediaCommentForm(request.form)

    media_template_name = media.media_manager.display_template

    context = {
        'media': media,
        'comments': comments,
        'pagination': pagination,
        'comment_form': comment_form,
        'app_config': mg_globals.app_config}

    # Since the media template name gets swapped out for each media
    # type, normal context hooks don't work if you want to affect all
    # media displays.  This gives a general purpose hook.
    context = hook_transform(
        "media_home_context", context)

    return render_to_response(
        request,
        media_template_name,
        context)