fix vp with new type in credentials
This commit is contained in:
parent
60ede69ad3
commit
f8574569ac
|
@ -610,17 +610,7 @@ class VerificableCredential(models.Model):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def get_type(self, lang=None):
|
def get_type(self, lang=None):
|
||||||
schema = json.loads(self.schema.data)
|
return self.type
|
||||||
if not schema.get('name'):
|
|
||||||
return ''
|
|
||||||
try:
|
|
||||||
for x in schema['name']:
|
|
||||||
if lang or settings.LANGUAGE_CODE in x['lang']:
|
|
||||||
return x.get('value', '')
|
|
||||||
except:
|
|
||||||
return self.schema.type
|
|
||||||
|
|
||||||
return ''
|
|
||||||
|
|
||||||
def get_status(self):
|
def get_status(self):
|
||||||
return self.Status(self.status).label
|
return self.Status(self.status).label
|
||||||
|
|
|
@ -35,8 +35,8 @@ class AuthorizeForm(forms.Form):
|
||||||
for vp in self.presentation_definition:
|
for vp in self.presentation_definition:
|
||||||
vp = vp.lower()
|
vp = vp.lower()
|
||||||
choices = [
|
choices = [
|
||||||
(str(x.id), x.schema.type.lower()) for x in self.credentials.filter(
|
(str(x.id), x.type.lower()) for x in self.credentials.filter(
|
||||||
schema__type__iexact=vp)
|
type__iexact=vp)
|
||||||
]
|
]
|
||||||
self.fields[vp.lower()] = forms.ChoiceField(
|
self.fields[vp.lower()] = forms.ChoiceField(
|
||||||
widget=forms.RadioSelect,
|
widget=forms.RadioSelect,
|
||||||
|
@ -46,7 +46,7 @@ class AuthorizeForm(forms.Form):
|
||||||
data = super().clean()
|
data = super().clean()
|
||||||
self.list_credentials = []
|
self.list_credentials = []
|
||||||
for c in self.credentials:
|
for c in self.credentials:
|
||||||
if str(c.id) == data.get(c.schema.type.lower()):
|
if str(c.id) == data.get(c.type.lower()):
|
||||||
if c.status is not c.Status.ISSUED.value or not c.data:
|
if c.status is not c.Status.ISSUED.value or not c.data:
|
||||||
txt = _('There are some problems with this credentials')
|
txt = _('There are some problems with this credentials')
|
||||||
raise ValidationError(txt)
|
raise ValidationError(txt)
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for f in form.credentials.all %}
|
{% for f in form.credentials.all %}
|
||||||
{% if f.schema.type.lower == presentation.lower %}
|
{% if f.type.lower == presentation.lower %}
|
||||||
<tr style="font-size:15px;">
|
<tr style="font-size:15px;">
|
||||||
<td><input class="form-check-input" type="radio" value="{{ f.id }}" name="{{ presentation.lower }}"></td>
|
<td><input class="form-check-input" type="radio" value="{{ f.id }}" name="{{ presentation.lower }}"></td>
|
||||||
<td>{{ f.type }}</td>
|
<td>{{ f.type }}</td>
|
||||||
|
|
Loading…
Reference in New Issue