From 33f51fcdbc8471d37b5d2d7c2aec9460bc61b799 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 27 Oct 2023 11:19:10 +0200 Subject: [PATCH] add user dids management --- idhub/admin/views.py | 6 +- idhub/models.py | 2 +- idhub/templates/idhub/admin/dids.html | 4 +- idhub/templates/idhub/base.html | 2 +- idhub/templates/idhub/user/did_register.html | 30 ++++++ idhub/templates/idhub/user/dids.html | 56 ++++++++++ idhub/templates/idhub/user/identities.html | 5 - idhub/templates/idhub/user/roles.html | 2 +- idhub/urls.py | 10 +- idhub/user/views.py | 104 +++++++++++++++++-- 10 files changed, 195 insertions(+), 26 deletions(-) create mode 100644 idhub/templates/idhub/user/did_register.html create mode 100644 idhub/templates/idhub/user/dids.html delete mode 100644 idhub/templates/idhub/user/identities.html diff --git a/idhub/admin/views.py b/idhub/admin/views.py index 35c7f9c..e1c0fef 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -460,7 +460,7 @@ class AdminDidRegisterView(Credentials, CreateView): return form def form_valid(self, form): - user = form.save() + form.save() messages.success(self.request, _('DID created successfully')) return super().form_valid(form) @@ -487,7 +487,7 @@ class AdminDidEditView(Credentials, UpdateView): def form_valid(self, form): user = form.save() - messages.success(self.request, _('DID created successfully')) + messages.success(self.request, _('DID updated successfully')) return super().form_valid(form) @@ -499,10 +499,10 @@ class AdminDidDeleteView(Credentials, DeleteView): success_url = reverse_lazy('idhub:admin_dids') def get(self, request, *args, **kwargs): - # import pdb; pdb.set_trace() self.pk = kwargs['pk'] self.object = get_object_or_404(self.model, pk=self.pk) self.object.delete() + messages.success(self.request, _('DID delete successfully')) return redirect(self.success_url) diff --git a/idhub/models.py b/idhub/models.py index 52f3010..f58f1a2 100644 --- a/idhub/models.py +++ b/idhub/models.py @@ -152,7 +152,7 @@ class Service(models.Model): return ", ".join([x.name for x in self.rol.all()]) def __str__(self): - return "{} -> {}".format(self.domain, self.rol.name) + return "{} -> {}".format(self.domain, self.get_roles()) class UserRol(models.Model): diff --git a/idhub/templates/idhub/admin/dids.html b/idhub/templates/idhub/admin/dids.html index b7156c0..00765af 100644 --- a/idhub/templates/idhub/admin/dids.html +++ b/idhub/templates/idhub/admin/dids.html @@ -43,11 +43,11 @@