fix some things

This commit is contained in:
Cayo Puigdefabregas 2023-11-22 11:18:47 +01:00
parent 5ac3790588
commit 6bf642c720
4 changed files with 17 additions and 8 deletions

View File

@ -27,6 +27,7 @@ class ImportForm(forms.Form):
self._schema = None
self._did = None
self.rows = {}
self.properties = {}
self.user = kwargs.pop('user', None)
super().__init__(*args, **kwargs)
self.fields['did'].choices = [
@ -59,6 +60,16 @@ class ImportForm(forms.Form):
raise ValidationError("Schema is not valid!")
self._schema = schema.first()
try:
self.json_schema = json.loads(self._schema.data)
prop = self.json_schema['properties']
self.properties = prop['credentialSubject']['properties']
except Exception:
raise ValidationError("Schema is not valid!")
if not self.properties:
raise ValidationError("Schema is not valid!")
return data
@ -68,15 +79,13 @@ class ImportForm(forms.Form):
if File_datas.objects.filter(file_name=self.file_name, success=True).exists():
raise ValidationError("This file already exists!")
self.json_schema = json.loads(self._schema.data)
df = pd.read_csv (data, delimiter="\t", quotechar='"', quoting=csv.QUOTE_ALL)
data_pd = df.fillna('').to_dict()
if not data_pd:
self.exception("This file is empty!")
properties = self.json_schema['properties']['credentialSubject']['properties']
head_row = {x: '' for x in properties.keys()}
head_row = {x: '' for x in self.properties.keys()}
for n in range(df.last_valid_index()+1):
row = head_row.copy()
for k in data_pd.keys():

View File

@ -35,7 +35,7 @@
{% endfor %}
<div class="row mt-3">
<div class="col-3 text-end">
<strong>Date of Issue:</strong>
<strong>{% trand 'Issuance date' %}:</strong>
</div>
<div class="col bg-light text-secondary">
{{ object.issuer_on|default_if_none:"" }}
@ -43,7 +43,7 @@
</div>
<div class="row mt-3">
<div class="col-3 text-end">
<strong>Status:</strong>
<strong>{% trand 'Status' %}:</strong>
</div>
<div class="col bg-light text-secondary">
{{ object.get_status}}

View File

@ -22,7 +22,7 @@
{% endfor %}
<div class="row mt-3">
<div class="col-3 text-end">
<strong>Date of Issue:</strong>
<strong>{% trand 'Issuance date' %}:</strong>
</div>
<div class="col bg-light text-secondary">
{{ object.issuer_on|default_if_none:"" }}
@ -30,7 +30,7 @@
</div>
<div class="row mt-3">
<div class="col-3 text-end">
<strong>Status:</strong>
<strong>{% trand 'Status' %}:</strong>
</div>
<div class="col bg-light text-secondary">
{{ object.get_status}}

View File

@ -18,7 +18,7 @@
<tbody>
{% for ev in user.events.all %}
<tr>
<td>{{ ev.get_type }}</td>
<td>{{ ev.get_type_name }}</td>
<td>{{ ev.message }}</td>
<td>{{ ev.created }}</td>
</tr>