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 @@ +
+
+ + {% translate "Institution" %} + +
+
{% 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