add field type in form

This commit is contained in:
Cayo Puigdefabregas 2024-01-16 14:00:59 +01:00
parent 72a895a6de
commit 01bc21d1a4
2 changed files with 5 additions and 3 deletions

View file

@ -199,13 +199,13 @@ class DidRegisterView(MyWallet, CreateView):
icon = 'bi bi-patch-check-fill' icon = 'bi bi-patch-check-fill'
wallet = True wallet = True
model = DID model = DID
fields = ('label',) fields = ('label', 'type')
success_url = reverse_lazy('idhub:user_dids') success_url = reverse_lazy('idhub:user_dids')
object = None object = None
def form_valid(self, form): def form_valid(self, form):
form.instance.user = self.request.user form.instance.user = self.request.user
form.instance.set_did(form.instance.type) form.instance.set_did()
form.save() form.save()
messages.success(self.request, _('DID created successfully')) messages.success(self.request, _('DID created successfully'))

View file

@ -33,7 +33,9 @@ class LoginView(auth_views.LoginView):
def serve_did(request, did_id): def serve_did(request, did_id):
document = get_object_or_404(DID, did=f'did:web:{settings.DOMAIN}:{did_id}').didweb_document id_did = f'did:web:{settings.DOMAIN}:did-registry:{did_id}'
did = get_object_or_404(DID, did=id_did)
document = did.didweb_document
retval = HttpResponse(document) retval = HttpResponse(document)
retval.headers["Content-Type"] = "application/json" retval.headers["Content-Type"] = "application/json"
return retval return retval