def list_fingerprint_files(request, fingerprint):

    if not hasFingerprintPermissions(request, fingerprint):
        return HttpResponse("Access forbidden", status=403)

    data = {'conf': list_fingerprint_files_aux(request, fingerprint)}

    response = JSONResponse(data, mimetype=response_mimetype(request))
    response['Content-Disposition'] = 'inline; filename=files.json'
    return response
def upload_document(request,
                    fingerprint_id,
                    template_name='documents_upload_form.html'):
    """Store the files at the backend
    """

    data = upload_document_aux(request, fingerprint_id)

    response = JSONResponse(data, mimetype=response_mimetype(request))
    response['Content-Disposition'] = 'inline; filename=files.json'
    return response
def parsejerboa(request, template_name='documents_upload_form.html'):
    """ Parse files from Jerboa
    """
    path_file = "C:/Users/lbastiao/Projects/TEST_DataProfile_v1.5.6b.txt"
    #path_file = "/Volumes/EXT1/Dropbox/MAPi-Dropbox/EMIF/Jerboa/TEST_DataProfile_v1.5.6b.txt"

    _json = import_population_characteristics_data(filename=path_file)

    pc = PopulationCharacteristic()
    pc.submit_new_revision()
    data = {'data': _json}
    response = JSONResponse(data, mimetype=response_mimetype(request))
    response['Content-Disposition'] = 'inline; filename=files.json'
    return response
Example #4
0
def parsejerboa(request, template_name='documents_upload_form.html'):
    """ Parse files from Jerboa
    """
    path_file = "C:/Users/lbastiao/Projects/TEST_DataProfile_v1.5.6b.txt"
    #path_file = "/Volumes/EXT1/Dropbox/MAPi-Dropbox/EMIF/Jerboa/TEST_DataProfile_v1.5.6b.txt"


    _json = import_population_characteristics_data(filename=path_file)

    pc = PopulationCharacteristic()
    pc.submit_new_revision()
    data = {'data': _json}
    response = JSONResponse(data, mimetype=response_mimetype(request))
    response['Content-Disposition'] = 'inline; filename=files.json'
    return response
Example #5
0
def upload_document(request, fingerprint_id, template_name='documents_upload_form.html'):
    """Store the files at the backend
    """

    # compute revision
    revision = get_revision()

    # Create the backend to store the file
    fh = FileSystemHandleFile()
    g_fh = HandleFile(fh)

    files = []
    # Run it for all the sent files (apply the persistence storage)
    path_file = None
    file_name = None
    if request.FILES:
        for name, f in request.FILES.items():
            # Handle file
            path_file = g_fh.handle_file(f, revision=revision)
            file_name = f.name
            # Serialize the response
            files.append(serialize(f))


    data = {'files': files}

    # Store the metadata in the database
    fd = FingerprintDocuments()
    fd.user = request.user
    fd.fingerprint_id = fingerprint_id
    fd.revision = revision
    fd.path = path_file
    fd.file_name = file_name
    fd.name = request.POST['pc_name']
    fd.description = request.POST['pc_comments']
    fd.save()

    response = JSONResponse(data, mimetype=response_mimetype(request))
    response['Content-Disposition'] = 'inline; filename=files.json'
    return response
Example #6
0
def document_form_view_upload(request, template_name='documents_upload_form.html'):
    """Store the files at the backend
    """

    # Create the backend to store the file
    fh = FileSystemHandleFile()
    g_fh = HandleFile(fh)

    files = []
    # Run it for all the sent files (apply the persistence storage)
    if request.FILES:
        for name, f in request.FILES.items():
            # Handle file
            g_fh.handle_file(f)

            # Serialize the response
            files.append(serialize(f))

    data = {'files': files}
    response = JSONResponse(data, mimetype=response_mimetype(request))
    response['Content-Disposition'] = 'inline; filename=files.json'
    return response
def document_form_view_upload(request,
                              template_name='documents_upload_form.html'):
    """Store the files at the backend
    """

    # Create the backend to store the file
    fh = FileSystemHandleFile()
    g_fh = HandleFile(fh)

    files = []
    # Run it for all the sent files (apply the persistence storage)
    if request.FILES:
        for name, f in request.FILES.items():
            # Handle file
            g_fh.handle_file(f)

            # Serialize the response
            files.append(serialize(f))

    data = {'files': files}
    response = JSONResponse(data, mimetype=response_mimetype(request))
    response['Content-Disposition'] = 'inline; filename=files.json'
    return response
Example #8
0
def list_fingerprint_files(request, fingerprint):

    if not hasFingerprintPermissions(request, fingerprint):
        return HttpResponse("Access forbidden",status=403)

    # List the Jerboa files for a particular fingerprint
    jerboa_files = FingerprintDocuments.objects.filter(
            fingerprint_id=fingerprint,
            removed=False
        )

    files_latest_version = jerboa_files.values('file_name').annotate(latest=Max('latest_date'))

    file_records = []
    for file in files_latest_version:
        #print file['file_name']
        file_records.append(jerboa_files.get(file_name = file['file_name'], latest_date = file['latest']))

    #print file_records

    _data = []

    for f in file_records:
        _doc = {'name': f.name,
                'comments': f.description,
                'revision': f.revision,
                'file_name': f.file_name,
                #'path': f.path.replace(settings.PROJECT_DIR_ROOT, ''),
                'fingerprint_id': f.fingerprint_id  ,
                'latest_date': serialize_date(f.latest_date),
                }
        _data.append(_doc)

    data = {'conf': _data}
    response = JSONResponse(data, mimetype=response_mimetype(request))
    response['Content-Disposition'] = 'inline; filename=files.json'
    return response