paravesh changes in view
This commit is contained in:
parent
0eebab5185
commit
cd58abf19f
|
@ -261,17 +261,8 @@ def run_audit_in_counter(msg):
|
|||
if file_to_original and file_to_original.file and hasattr(file_to_original.file, 'path') and file_to_original.file.path:
|
||||
with open(file_to_original.file.path, 'rb') as file:
|
||||
hash = uploadDataToIPFSNode(file)
|
||||
filename = os.path.basename(file_to_original.file.path)
|
||||
file = ContentFile(
|
||||
file.read(),
|
||||
filename,
|
||||
)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="script-original",
|
||||
)
|
||||
savefiles(file, file_to_original.file.path, script_id,"script-original")
|
||||
script_original["script_file"] = hash
|
||||
files.public_file.save(filename, file, save=True)
|
||||
script_original["type"] = "script-original"
|
||||
script_original["script_file_path"] = file_to_original.file.path
|
||||
audit_data["script-original"] = script_original
|
||||
|
@ -300,16 +291,7 @@ def run_audit_in_counter(msg):
|
|||
script_path1 = file_to_audit_docx.file.path
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2_docx = uploadDataToIPFSNode(_file)
|
||||
filename = os.path.basename(script_path1)
|
||||
django_file = ContentFile(
|
||||
_file.read(),
|
||||
filename,
|
||||
)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="script-docx",
|
||||
)
|
||||
files.public_file.save(filename, django_file, save=True)
|
||||
savefiles(_file, script_path1, script_id,"script-docx")
|
||||
script_docx["script_file_path"] = script_path1
|
||||
script_docx["script_file"] = hash2_docx
|
||||
script_docx["type"] = "script-docx"
|
||||
|
@ -342,16 +324,7 @@ def run_audit_in_counter(msg):
|
|||
script_size = file_to_audit_docx.file.size
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2_docx = uploadDataToIPFSNode(_file)
|
||||
filename = os.path.basename(script_path1)
|
||||
django_file = ContentFile(
|
||||
_file.read(),
|
||||
filename,
|
||||
)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="script-docx",
|
||||
)
|
||||
files.public_file.save(filename, django_file, save=True)
|
||||
savefiles(_file, script_path1, script_id,"script-docx")
|
||||
script_docx["script_file_path"] = script_path1
|
||||
script_docx["script_file"] = hash2_docx
|
||||
script_docx["type"] = "script-docx"
|
||||
|
@ -377,16 +350,7 @@ def run_audit_in_counter(msg):
|
|||
# script_size = file_to_audit_docx.file.size
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2 = uploadDataToIPFSNode(_file)
|
||||
filename = os.path.basename(script_path1)
|
||||
django_file = ContentFile(
|
||||
_file.read(),
|
||||
filename,
|
||||
)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="script-pdf",
|
||||
)
|
||||
files.public_file.save(filename, django_file, save=True)
|
||||
savefiles(_file, script_path1, script_id,"script-pdf")
|
||||
script_pdf["script_file_path"] = script_path1
|
||||
script_pdf["script_file"] = hash2
|
||||
script_pdf["type"] = "script-pdf"
|
||||
|
@ -411,16 +375,7 @@ def run_audit_in_counter(msg):
|
|||
# script_size = file_to_audit_docx.file.size
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2 = uploadDataToIPFSNode(_file)
|
||||
filename = os.path.basename(script_path1)
|
||||
django_file = ContentFile(
|
||||
_file.read(),
|
||||
filename,
|
||||
)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="script-json",
|
||||
)
|
||||
files.public_file.save(filename, django_file, save=True)
|
||||
savefiles(_file, script_path1, script_id,"script-json")
|
||||
script_json["script_file_path"] = script_path1
|
||||
script_json["script_file"] = hash2
|
||||
script_json["type"] = "script-json"
|
||||
|
@ -436,16 +391,7 @@ def run_audit_in_counter(msg):
|
|||
print("script_file_path_is_here",script_path)
|
||||
with open(script_path, 'rb') as _file:
|
||||
hash1 = uploadDataToIPFSNode(_file)
|
||||
filename = os.path.basename(script_path)
|
||||
django_file = ContentFile(
|
||||
_file.read(),
|
||||
filename,
|
||||
)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="script-csv",
|
||||
)
|
||||
files.public_file.save(filename, django_file, save=True)
|
||||
savefiles(_file, script_path, script_id,"script-csv")
|
||||
script_csv["script_file"] = hash1
|
||||
script_csv["script_file_path"] = script_path
|
||||
script_csv["type"] = "script-csv"
|
||||
|
@ -523,16 +469,7 @@ def run_audit_in_counter(msg):
|
|||
script_path1 = file_to_audit_docx.file.path
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2_docx = uploadDataToIPFSNode(_file)
|
||||
filename = os.path.basename(script_path1)
|
||||
django_file = ContentFile(
|
||||
_file.read(),
|
||||
filename,
|
||||
)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="script-docx",
|
||||
)
|
||||
files.public_file.save(filename, django_file, save=True)
|
||||
savefiles(_file, script_path1, script_id,"script-docx")
|
||||
script_docx["script_file_path"] = script_path1
|
||||
script_docx["script_file"] = hash2_docx
|
||||
script_docx["type"] = "script-docx"
|
||||
|
@ -565,16 +502,7 @@ def run_audit_in_counter(msg):
|
|||
script_size = file_to_audit_docx.file.size
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2_docx = uploadDataToIPFSNode(_file)
|
||||
filename = os.path.basename(script_path1)
|
||||
django_file = ContentFile(
|
||||
_file.read(),
|
||||
filename,
|
||||
)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="script-docx",
|
||||
)
|
||||
files.public_file.save(filename, django_file, save=True)
|
||||
savefiles(_file, script_path1, script_id,"script-docx")
|
||||
script_docx["script_file_path"] = script_path1
|
||||
script_docx["script_file"] = hash2_docx
|
||||
script_docx["type"] = "script-docx"
|
||||
|
@ -600,16 +528,7 @@ def run_audit_in_counter(msg):
|
|||
# script_size = file_to_audit_docx.file.size
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2 = uploadDataToIPFSNode(_file)
|
||||
filename = os.path.basename(script_path1)
|
||||
django_file = ContentFile(
|
||||
_file.read(),
|
||||
filename,
|
||||
)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="script-pdf",
|
||||
)
|
||||
files.public_file.save(filename, django_file, save=True)
|
||||
savefiles(_file, script_path1, script_id,"script-pdf")
|
||||
script_pdf["script_file_path"] = script_path1
|
||||
script_pdf["script_file"] = hash2
|
||||
script_pdf["type"] = "script-pdf"
|
||||
|
@ -633,16 +552,7 @@ def run_audit_in_counter(msg):
|
|||
# script_size = file_to_audit_docx.file.size
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2 = uploadDataToIPFSNode(_file)
|
||||
filename = os.path.basename(script_path1)
|
||||
django_file = ContentFile(
|
||||
_file.read(),
|
||||
filename,
|
||||
)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="script-json",
|
||||
)
|
||||
files.public_file.save(filename, django_file, save=True)
|
||||
savefiles(_file, script_path1, script_id,"script-json")
|
||||
script_json["script_file_path"] = script_path1
|
||||
script_json["script_file"] = hash2
|
||||
script_json["type"] = "script-json"
|
||||
|
@ -664,16 +574,7 @@ def run_audit_in_counter(msg):
|
|||
with open(script_path, 'rb') as _file:
|
||||
hash1 = uploadDataToIPFSNode(_file)
|
||||
script_csv["script_file"] = hash1
|
||||
filename = os.path.basename(script_path)
|
||||
django_file = ContentFile(
|
||||
_file.read(),
|
||||
filename,
|
||||
)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="script-csv",
|
||||
)
|
||||
files.public_file.save(filename, django_file, save=True)
|
||||
savefiles(_file, script_path, script_id,"script-csv")
|
||||
script_csv["script_file_path"] = script_path
|
||||
script_csv["type"] = "script-csv"
|
||||
|
||||
|
@ -681,16 +582,7 @@ def run_audit_in_counter(msg):
|
|||
audit_report_path = file_to_audit_report.file.path
|
||||
with open(audit_report_path, 'rb') as file1:
|
||||
hash2 = uploadDataToIPFSNode(file1)
|
||||
filename = os.path.basename(audit_report_path)
|
||||
django_file = ContentFile(
|
||||
file1.read(),
|
||||
filename,
|
||||
)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="audit-report",
|
||||
)
|
||||
files.public_file.save(filename, django_file, save=True)
|
||||
savefiles(file1, audit_report_path, script_id,"audit-report")
|
||||
audit_report["script_file"] = hash2
|
||||
audit_report["script_file_path"] = audit_report_path
|
||||
audit_report["type"] = "audit-report"
|
||||
|
@ -852,6 +744,15 @@ def run_audit(msg):
|
|||
run_audit_in_counter(audit_parameters)
|
||||
"""
|
||||
|
||||
def savefiles(file, path, script_id,File_type):
|
||||
filename = os.path.basename(path)
|
||||
django_file = File2(file)
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type=File_type,
|
||||
)
|
||||
files.public_file.save(filename, django_file)
|
||||
|
||||
class AuditedScriptsView_Without_blockchain(LoginRequiredMixin, APIView):
|
||||
login_url = "/personal-login"
|
||||
authentication_classes = [BasicAuthentication,SessionAuthentication]
|
||||
|
|
Loading…
Reference in New Issue