Ejemplo n.º 1
0
def my_documents(request, **kwargs):
    u"""
    Renders a list of all documents added by current user.
    
    We need a User here, not an AnonymousUser, so the view is wrapped with
    login_required decorator.
    """
    queryset = Document.objects.filter(added_by=request.user)
    return document_list(request, queryset, "briefcase/my_documents.html", **kwargs)
Ejemplo n.º 2
0
def documents_for_user(request, username=None, user_id=None, **kwargs):
    u"""
    Renders a list of documents added by a specific user.
    
    The user can be identified by his username or user_id. If both are 
    specified, username takes precedence.
    """
    if username is not None:
        queryset = Document.objects.filter(added_by__username=username)
    elif user_id is not None:
        queryset = Document.objects.filter(added_by_id=user_id)
    else:
        raise AttributeError(_("documents_for_user requires either username or user_id."))
    return document_list(request, queryset, "briefcase/documents_for_user.html", **kwargs)
Ejemplo n.º 3
0
def recent_documents(request, **kwargs):
    u"""
    Renders a list of all documents sorted by creation date.
    """
    queryset = Document.objects.all().order_by("-added_at")
    return document_list(request, queryset, "briefcase/recent_documents.html", **kwargs)