예제 #1
0
 def _get_document(self, pk):
     if isinstance(pk, int) or (pk and pk.isdigit()):
         query = Document.all().where(Document._meta.primary_key == pk)
         try:
             return query.get()
         except Document.DoesNotExist:
             pass
     return get_object_or_404(Document.all(), Document.identifier == pk)
예제 #2
0
def attachment_download(document_id, pk):
    document = get_object_or_404(Document.all(),
                                 Document._meta.primary_key == document_id)
    attachment = get_object_or_404(document.attachments,
                                   Attachment.filename == pk)

    response = make_response(attachment.blob.data)
    response.headers['Content-Type'] = attachment.mimetype
    response.headers['Content-Length'] = attachment.length
    response.headers['Content-Disposition'] = 'inline; filename=%s' % (
        attachment.filename)

    return response
예제 #3
0
 def refresh_doc(self, doc):
     return (Document.all().where(
         Document._meta.primary_key == doc.get_id()).get())