From 3b70a6c7cc93ba900fc94ba89847bf585a0e51e0 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 11 Oct 2024 17:04:33 +0200 Subject: [PATCH] add form for edit institution details --- admin/templates/admin_panel.html | 7 +++++++ admin/urls.py | 1 + admin/views.py | 23 ++++++++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/admin/templates/admin_panel.html b/admin/templates/admin_panel.html index 6d3bd14..3dd5ed1 100644 --- a/admin/templates/admin_panel.html +++ b/admin/templates/admin_panel.html @@ -8,5 +8,12 @@ +
+ +
{% endblock %} diff --git a/admin/urls.py b/admin/urls.py index cd79c3f..9a26cbf 100644 --- a/admin/urls.py +++ b/admin/urls.py @@ -9,4 +9,5 @@ urlpatterns = [ path("users/new", views.CreateUserView.as_view(), name="new_user"), path("users/edit/", views.EditUserView.as_view(), name="edit_user"), path("users/delete/", views.DeleteUserView.as_view(), name="delete_user"), + path("institution/", views.InstitutionView.as_view(), name="institution"), ] diff --git a/admin/views.py b/admin/views.py index bcc8889..1ba392f 100644 --- a/admin/views.py +++ b/admin/views.py @@ -8,7 +8,7 @@ from django.views.generic.edit import ( DeleteView, ) from dashboard.mixins import DashboardView -from user.models import User +from user.models import User, Institution class PanelView(DashboardView, TemplateView): @@ -87,3 +87,24 @@ class EditUserView(DashboardView, UpdateView): #self.object.set_password(self.object.password) kwargs = super().get_form_kwargs() return kwargs + + +class InstitutionView(DashboardView, UpdateView): + template_name = "institution.html" + title = _("Edit institution") + section = "admin" + subtitle = _('Edit institution') + model = Institution + success_url = reverse_lazy('admin:panel') + fields = ( + "name", + "logo", + "location", + "responsable_person", + "supervisor_person" + ) + + def get_form_kwargs(self): + self.object = self.request.user.institution + kwargs = super().get_form_kwargs() + return kwargs