Exemplo n.º 1
0
def GetDocuments(uID=None, archived=False, start=0, end=50):
    'archived: None - Return All Documents; True - Only return archived; False - Only not archived.'

    if uID:
        # In the future, this should not only return documents which the uID owns but also display
        # document the uID have access to.

        # Check if end is 0. If it is, then there should not be a limit.
        if archived == None:
            if end == 0:
                return Document.objects(
                    Q(owner__iexact=uID)
                    | Q(policies__uID__iexact=uID)).order_by('-dScanned')
            else:
                return Document.objects(
                    Q(owner__iexact=uID)
                    | Q(policies__uID__iexact=uID)).order_by(
                        '-dScanned')[start:end]
        else:
            if end == 0:
                return Document.objects(
                    (Q(owner__iexact=uID) | Q(policies__uID__iexact=uID))
                    & Q(archived=archived)).order_by('-dScanned')
            else:
                return Document.objects(
                    (Q(owner__iexact=uID) | Q(policies__uID__iexact=uID))
                    & Q(archived=archived)).order_by('-dScanned')[start:end]

    return []
Exemplo n.º 2
0
def SearchDocsByName(uID, name, start=0, end=50):
    if end == 0:
        return Document.objects(
            Q(name__icontains=name)
            & (Q(owner__iexact=uID)
               | Q(policies__uID__iexact=uID))).order_by('-dScanned')
    return Document.objects(
        Q(name__icontains=name)
        & (Q(owner__iexact=uID)
           | Q(policies__uID__iexact=uID))).order_by('-dScanned')[start:end]
Exemplo n.º 3
0
def SearchDocsByHashTag(uID, hashTag, start=0, end=50):
    if end == 0:
        return Document.objects(
            Q(hashTags__icontains=hashTag)
            & (Q(owner__iexact=uID)
               | Q(policies__uID__iexact=uID))).order_by('-dScanned')
    return Document.objects(
        Q(hashTags__icontains=hashTag)
        & (Q(owner__iexact=uID)
           | Q(policies__uID__iexact=uID)))[start:end].order_by('-dScanned')
Exemplo n.º 4
0
def SearchDocsBySubject(uID, subject, start=0, end=50):
    if end == 0:
        return Document.objects(
            Q(subject__icontains=subject)
            & (Q(owner__iexact=uID)
               | Q(policies__uID__iexact=uID))).order_by('-dScanned')
    return Document.objects(
        Q(subject__icontains=subject)
        & (Q(owner__iexact=uID)
           | Q(policies__uID__iexact=uID)))[start:end].order_by('-dScanned')
Exemplo n.º 5
0
def GetDocByDocID(docID):
    return Document.objects(docID__iexact=docID).first()