diff --git a/idhub/admin/views.py b/idhub/admin/views.py index 9e5b4e7..dc4c016 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -456,24 +456,13 @@ class AdminDidRegisterView(Credentials, CreateView): icon = 'bi bi-patch-check-fill' wallet = True model = DID - fields = ('did', 'label') + fields = ('label',) success_url = reverse_lazy('idhub:admin_dids') object = None - def get_form_kwargs(self): - kwargs = super().get_form_kwargs() - kwargs['initial'] = { - 'did': iota.issue_did() - } - return kwargs - - def get_form(self): - form = super().get_form() - form.fields['did'].required = False - form.fields['did'].disabled = True - return form - def form_valid(self, form): + form.instance.user = self.request.user + form.instance.did = iota.issue_did() form.save() messages.success(self.request, _('DID created successfully')) return super().form_valid(form) @@ -485,7 +474,7 @@ class AdminDidEditView(Credentials, UpdateView): icon = 'bi bi-patch-check-fill' wallet = True model = DID - fields = ('did', 'label') + fields = ('label',) success_url = reverse_lazy('idhub:admin_dids') def get(self, request, *args, **kwargs): @@ -493,12 +482,6 @@ class AdminDidEditView(Credentials, UpdateView): self.object = get_object_or_404(self.model, pk=self.pk) return super().get(request, *args, **kwargs) - def get_form(self): - form = super().get_form() - form.fields['did'].required = False - form.fields['did'].disabled = True - return form - def form_valid(self, form): user = form.save() messages.success(self.request, _('DID updated successfully')) diff --git a/idhub/templates/idhub/admin/dids.html b/idhub/templates/idhub/admin/dids.html index 00765af..0bac4c5 100644 --- a/idhub/templates/idhub/admin/dids.html +++ b/idhub/templates/idhub/admin/dids.html @@ -43,7 +43,7 @@