def index(): fingerprints = Fingerprint.objects.all() for fingerprint in fingerprints: jerboa_files = Characteristic.objects.filter( fingerprint_id=fingerprint.fingerprint_hash).order_by( 'latest_date') if len(jerboa_files) > 0: self.stdout.write( '-- Indexing Jerboa Files from fingerprint ' + str(fingerprint) + '.\n') for jerboa_file in jerboa_files: pc = PopulationCharacteristic() data_jerboa = pc.submit_new_revision( jerboa_file.user, jerboa_file.fingerprint_id, jerboa_file.revision, jerboa_file.path) aggregation.apply_async( [jerboa_file.fingerprint_id, data_jerboa]) self.stdout.write('---- Indexing file ' + str(jerboa_file.file_name) + '.\n') self.stdout.write( '-- Finished indexing all population characteristic files to mongodb.\n' )
def document_form_view_upload(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 chracteristic = Characteristic() chracteristic.user = request.user chracteristic.fingerprint_id = fingerprint_id chracteristic.revision = revision chracteristic.path = path_file chracteristic.file_name = file_name chracteristic.name = request.POST['pc_name'] chracteristic.description = request.POST['pc_comments'] chracteristic.save() # Parse the Jerboa and insert it in MongoDB # The best option will be use django-celery #_json = import_population_characteristics_data(request.user, fingerprint_id,filename=path_file) pc = PopulationCharacteristic() data_jerboa = pc.submit_new_revision(request.user, fingerprint_id, revision, path_file) aggregation.apply_async([fingerprint_id, data_jerboa]) response = JSONResponse(data, mimetype=response_mimetype(request)) response['Content-Disposition'] = 'inline; filename=files.json' return response
def index(): fingerprints = Fingerprint.objects.all() for fingerprint in fingerprints: jerboa_files = Characteristic.objects.filter(fingerprint_id=fingerprint.fingerprint_hash).order_by('latest_date') if len(jerboa_files) > 0: self.stdout.write('-- Indexing Jerboa Files from fingerprint '+str(fingerprint)+'.\n') for jerboa_file in jerboa_files: pc = PopulationCharacteristic() data_jerboa = pc.submit_new_revision(jerboa_file.user, jerboa_file.fingerprint_id, jerboa_file.revision, jerboa_file.path) aggregation.apply_async([jerboa_file.fingerprint_id, data_jerboa]) self.stdout.write('---- Indexing file '+str(jerboa_file.file_name)+'.\n') self.stdout.write('-- Finished indexing all population characteristic files to mongodb.\n')