#NEWLINE# @ api_endpoint #NEWLINE# @ ajax_request #NEWLINE# @ login_required #NEWLINE# def handle_s3_upload_complete( request ) : #NEWLINE# #INDENT# "\n    Notify the system that an upload to S3 has been completed. This is\n    a necessary step after uploading to S3 or the SEED instance will not\n    be aware the file exists.\n\n    Valid source_type values are found in ``seed.models.SEED_DATA_SOURCES``\n\n    :GET: Expects the following in the query string:\n\n        key: The full path to the file, within the S3 bucket.\n            E.g. data_importer/bldgs.csv\n\n        source_type: The source of the file.\n            E.g. 'Assessed Raw' or 'Portfolio Raw'\n\n        import_record: The ID of the ImportRecord this file belongs to.\n\n    Returns::\n\n        {'success': True,\n         'import_file_id': The ID of the newly-created ImportFile object.\n        }\n    " #NEWLINE# if ( 'S3' not in settings . DEFAULT_FILE_STORAGE ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'success' : False , #NEWLINE# 'message' : 'Direct-to-S3 uploads not enabled' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# import_record_pk = request . REQUEST [ 'import_record' ] #NEWLINE# try : #NEWLINE# #INDENT# record = ImportRecord . objects . get ( pk = f ) #NEWLINE# #UNINDENT# except ImportRecord . DoesNotExist : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'success' : False , #NEWLINE# 'message' : ( 'Import Record %s not found' % import_record_pk ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# filename = request . REQUEST [ 'key' ] #NEWLINE# source_type = request . REQUEST [ 'source_type' ] #NEWLINE# f = ImportFile . objects . create ( import_record = record , file = filename , source_type = source_type ) #NEWLINE# return { #NEWLINE# #INDENT# 'success' : True , #NEWLINE# 'import_file_id' : f . pk , #NEWLINE# #UNINDENT# }