fix vp with new type in credentials

This commit is contained in:
Cayo Puigdefabregas 2024-01-24 16:53:19 +01:00
parent 60ede69ad3
commit f8574569ac
3 changed files with 5 additions and 15 deletions

View File

@ -610,17 +610,7 @@ class VerificableCredential(models.Model):
return ''
def get_type(self, lang=None):
schema = json.loads(self.schema.data)
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 ''
return self.type
def get_status(self):
return self.Status(self.status).label

View File

@ -35,8 +35,8 @@ class AuthorizeForm(forms.Form):
for vp in self.presentation_definition:
vp = vp.lower()
choices = [
(str(x.id), x.schema.type.lower()) for x in self.credentials.filter(
schema__type__iexact=vp)
(str(x.id), x.type.lower()) for x in self.credentials.filter(
type__iexact=vp)
]
self.fields[vp.lower()] = forms.ChoiceField(
widget=forms.RadioSelect,
@ -46,7 +46,7 @@ class AuthorizeForm(forms.Form):
data = super().clean()
self.list_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:
txt = _('There are some problems with this credentials')
raise ValidationError(txt)

View File

@ -43,7 +43,7 @@
</thead>
<tbody>
{% for f in form.credentials.all %}
{% if f.schema.type.lower == presentation.lower %}
{% if f.type.lower == presentation.lower %}
<tr style="font-size:15px;">
<td><input class="form-check-input" type="radio" value="{{ f.id }}" name="{{ presentation.lower }}"></td>
<td>{{ f.type }}</td>