diff --git a/idhub/admin/forms.py b/idhub/admin/forms.py index 2293aac..8354422 100644 --- a/idhub/admin/forms.py +++ b/idhub/admin/forms.py @@ -3,7 +3,7 @@ from django.contrib.auth.models import User class ProfileForm(forms.ModelForm): - MANDATORY_FIELDS = ['first_name', 'last_name', 'email'] + MANDATORY_FIELDS = ['first_name', 'last_name', 'email', 'username'] class Meta: model = User diff --git a/idhub/admin/views.py b/idhub/admin/views.py index 26852c7..a6f9807 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -81,6 +81,10 @@ class AdminPeopleActivateView(AdminPeopleView): self.pk = kwargs['pk'] self.object = get_object_or_404(self.model, pk=self.pk) + if self.object == self.request.user: + messages.error(self.request, _('Is not possible deactivate your account!')) + return redirect('idhub:admin_people', self.object.id) + if self.object.is_active: self.object.is_active = False else: @@ -96,14 +100,17 @@ class AdminPeopleDeleteView(AdminPeopleView): self.pk = kwargs['pk'] self.object = get_object_or_404(self.model, pk=self.pk) - self.object.delete() + if self.object != self.request.user: + self.object.delete() + else: + messages.error(self.request, _('Is not possible delete your account!')) return redirect('idhub:admin_people_list') class AdminPeopleEditView(AdminPeopleView, UpdateView): template_name = "idhub/admin_user_edit.html" from_class = ProfileForm - fields = ('first_name', 'last_name', 'email') + fields = ('first_name', 'last_name', 'email', 'username') success_url = reverse_lazy('idhub:admin_people_list') @@ -113,7 +120,7 @@ class AdminPeopleRegisterView(People, CreateView): icon = 'bi bi-person' model = User from_class = ProfileForm - fields = ('first_name', 'last_name', 'email') + fields = ('first_name', 'last_name', 'email', 'username') success_url = reverse_lazy('idhub:admin_people_list') diff --git a/idhub/templates/idhub/admin_people_register.html b/idhub/templates/idhub/admin_people_register.html index a48b4de..52a667f 100644 --- a/idhub/templates/idhub/admin_people_register.html +++ b/idhub/templates/idhub/admin_people_register.html @@ -13,19 +13,17 @@ {% endif %} {% bootstrap_form form %}
- {% translate "Cancel" %} - + {% translate "Cancel" %} +
diff --git a/idhub/templates/idhub/admin_user.html b/idhub/templates/idhub/admin_user.html index 4400ef1..92ee4e1 100644 --- a/idhub/templates/idhub/admin_user.html +++ b/idhub/templates/idhub/admin_user.html @@ -4,7 +4,7 @@ {% block content %}
-

+

{{ subtitle }}

diff --git a/idhub/templates/idhub/admin_user_edit.html b/idhub/templates/idhub/admin_user_edit.html index a48b4de..f599d81 100644 --- a/idhub/templates/idhub/admin_user_edit.html +++ b/idhub/templates/idhub/admin_user_edit.html @@ -24,8 +24,8 @@ {% endif %} {% bootstrap_form form %} diff --git a/idhub/templates/idhub/base.html b/idhub/templates/idhub/base.html index daaf793..17627ad 100644 --- a/idhub/templates/idhub/base.html +++ b/idhub/templates/idhub/base.html @@ -128,10 +128,9 @@
{% block messages %} {% for message in messages %} -