From 8185c280d5e1307afc9737436d4e22a6ce352891 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 3 Nov 2023 11:44:58 +0100 Subject: [PATCH] fix form presentation --- idhub/user/forms.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/idhub/user/forms.py b/idhub/user/forms.py index 8cbc94e..a8f6997 100644 --- a/idhub/user/forms.py +++ b/idhub/user/forms.py @@ -3,10 +3,6 @@ from idhub_auth.models import User from idhub.models import DID, VerificableCredential, Organization -ORGANIZATION = [ - (x.id, x.name) for x in Organization.objects.filter() -] - class ProfileForm(forms.ModelForm): MANDATORY_FIELDS = ['first_name', 'last_name', 'email'] @@ -59,12 +55,15 @@ class RequestCredentialForm(forms.Form): class CredentialPresentationForm(forms.Form): - organization = forms.ChoiceField(choices=ORGANIZATION) + organization = forms.ChoiceField(choices=[]) credential = forms.ChoiceField(choices=[]) def __init__(self, *args, **kwargs): self.user = kwargs.pop('user', None) super().__init__(*args, **kwargs) + self.fields['organization'].choices = [ + (x.id, x.name) for x in Organization.objects.filter() + ] self.fields['credential'].choices = [ (x.id, x.type()) for x in VerificableCredential.objects.filter( user=self.user,