Compare commits
3 Commits
e4124fb20b
...
3faa98a60e
Author | SHA1 | Date |
---|---|---|
Thomas Nahuel Rusiecki | 3faa98a60e | |
Thomas Nahuel Rusiecki | 7653c9d5f9 | |
Thomas Nahuel Rusiecki | 7d4ef21cef |
|
@ -58,7 +58,7 @@
|
||||||
<div class="col-lg-9 col-md-8">{{ object.type }}</div>
|
<div class="col-lg-9 col-md-8">{{ object.type }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if object.is_websnapshot %}
|
{% if object.is_websnapshot and object.last_user_evidence %}
|
||||||
{% for k, v in object.last_user_evidence %}
|
{% for k, v in object.last_user_evidence %}
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-lg-3 col-md-4 label">{{ k }}</div>
|
<div class="col-lg-3 col-md-4 label">{{ k }}</div>
|
||||||
|
|
|
@ -37,6 +37,8 @@ class UploadForm(forms.Form):
|
||||||
if exist_annotation:
|
if exist_annotation:
|
||||||
raise ValidationError("error: {} exist".format(file_name))
|
raise ValidationError("error: {} exist".format(file_name))
|
||||||
|
|
||||||
|
except ValueError:
|
||||||
|
raise ValidationError("Error in parsing JSON: {}. Check for file corruption.".format(file_name))
|
||||||
except Exception:
|
except Exception:
|
||||||
raise ValidationError("error in: {}".format(file_name))
|
raise ValidationError("error in: {}".format(file_name))
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
elif os.path.isdir(path):
|
elif os.path.isdir(path):
|
||||||
self.read_directory(path)
|
self.read_directory(path)
|
||||||
|
else:
|
||||||
|
raise ValueError(f"The path {path} is neither a file nor a directory")
|
||||||
|
|
||||||
self.parsing()
|
self.parsing()
|
||||||
|
|
||||||
|
@ -47,10 +49,16 @@ class Command(BaseCommand):
|
||||||
self.open(filepath)
|
self.open(filepath)
|
||||||
|
|
||||||
def open(self, filepath):
|
def open(self, filepath):
|
||||||
|
try:
|
||||||
with open(filepath, 'r') as file:
|
with open(filepath, 'r') as file:
|
||||||
content = json.loads(file.read())
|
content = json.loads(file.read())
|
||||||
path_name = save_in_disk(content, self.user.institution.name)
|
path_name = save_in_disk(content, self.user.institution.name)
|
||||||
self.snapshots.append((content, path_name))
|
self.snapshots.append((content, path_name))
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
raise ValueError(f"Invalid JSON format in file {filepath}.")
|
||||||
|
#or we cath'em all
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception(f"Oops! Something went wrong there")
|
||||||
|
|
||||||
def parsing(self):
|
def parsing(self):
|
||||||
for s, p in self.snapshots:
|
for s, p in self.snapshots:
|
||||||
|
|
Loading…
Reference in New Issue