def _get_fixture_upload_args_from_request(request, domain): try: upload_file = request.FILES["file-to-upload"] replace = request.POST["replace"] if replace.lower() == "true": replace = True elif replace.lower() == "false": replace = False user_email = None if toggles.SUPPORT.enabled(request.couch_user.username): user_email = request.couch_user.email if request.couch_user.email is not None \ else request.couch_user.username except Exception: raise FixtureAPIRequestError( "Invalid post request." "Submit the form with field 'file-to-upload' and POST parameter 'replace'" ) is_async = request.POST.get("async", "").lower() == "true" if not request.couch_user.has_permission(domain, Permissions.edit_data.name): raise FixtureAPIRequestError( "User {} doesn't have permission to upload fixtures".format( request.couch_user.username)) skip_orm = False if request.POST.get( 'skip_orm') == 'true' and SKIP_ORM_FIXTURE_UPLOAD.enabled(domain): skip_orm = True return _excel_upload_file( upload_file), replace, is_async, skip_orm, user_email
def _get_fixture_upload_args_from_request(request, domain): try: upload_file = request.FILES["file-to-upload"] replace = request.POST["replace"] if replace.lower() == "true": replace = True elif replace.lower() == "false": replace = False except Exception: raise FixtureAPIRequestError( u"Invalid post request." u"Submit the form with field 'file-to-upload' and POST parameter 'replace'") if not request.couch_user.has_permission(domain, Permissions.edit_data.name): raise FixtureAPIRequestError( u"User {} doesn't have permission to upload fixtures" .format(request.couch_user.username)) return _excel_upload_file(upload_file), replace