diff --git a/idhub/admin/forms.py b/idhub/admin/forms.py index 2917932..4682579 100644 --- a/idhub/admin/forms.py +++ b/idhub/admin/forms.py @@ -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(): diff --git a/idhub/templates/idhub/admin/issue_credentials.html b/idhub/templates/idhub/admin/issue_credentials.html index 953c806..61aac91 100644 --- a/idhub/templates/idhub/admin/issue_credentials.html +++ b/idhub/templates/idhub/admin/issue_credentials.html @@ -35,7 +35,7 @@ {% endfor %}
- Date of Issue: + {% trand 'Issuance date' %}:
{{ object.issuer_on|default_if_none:"" }} @@ -43,7 +43,7 @@
- Status: + {% trand 'Status' %}:
{{ object.get_status}} diff --git a/idhub/templates/idhub/user/credential.html b/idhub/templates/idhub/user/credential.html index 4593adf..65d2da1 100644 --- a/idhub/templates/idhub/user/credential.html +++ b/idhub/templates/idhub/user/credential.html @@ -22,7 +22,7 @@ {% endfor %}
- Date of Issue: + {% trand 'Issuance date' %}:
{{ object.issuer_on|default_if_none:"" }} @@ -30,7 +30,7 @@
- Status: + {% trand 'Status' %}:
{{ object.get_status}} diff --git a/idhub/templates/idhub/user/dashboard.html b/idhub/templates/idhub/user/dashboard.html index 4586035..c13f776 100644 --- a/idhub/templates/idhub/user/dashboard.html +++ b/idhub/templates/idhub/user/dashboard.html @@ -18,7 +18,7 @@ {% for ev in user.events.all %} - {{ ev.get_type }} + {{ ev.get_type_name }} {{ ev.message }} {{ ev.created }}