added admin state definition panel

This commit is contained in:
Thomas Nahuel Rusiecki 2024-12-01 02:58:22 -03:00 committed by Cayo Puigdefabregas
parent 0c09da7f8a
commit 4561c5fb72
3 changed files with 21 additions and 0 deletions

View file

@ -10,4 +10,5 @@ urlpatterns = [
path("users/edit/<int:pk>", views.EditUserView.as_view(), name="edit_user"), path("users/edit/<int:pk>", views.EditUserView.as_view(), name="edit_user"),
path("users/delete/<int:pk>", views.DeleteUserView.as_view(), name="delete_user"), path("users/delete/<int:pk>", views.DeleteUserView.as_view(), name="delete_user"),
path("institution/<int:pk>", views.InstitutionView.as_view(), name="institution"), path("institution/<int:pk>", views.InstitutionView.as_view(), name="institution"),
path("states/", views.StatesPanelView.as_view(), name="states"),
] ]

View file

@ -11,6 +11,7 @@ from django.views.generic.edit import (
from dashboard.mixins import DashboardView, Http403 from dashboard.mixins import DashboardView, Http403
from user.models import User, Institution from user.models import User, Institution
from admin.email import NotifyActivateUserByEmail from admin.email import NotifyActivateUserByEmail
from action.models import State, StateDefinition
class AdminView(DashboardView): class AdminView(DashboardView):
@ -124,3 +125,17 @@ class InstitutionView(AdminView, UpdateView):
self.object = self.request.user.institution self.object = self.request.user.institution
kwargs = super().get_form_kwargs() kwargs = super().get_form_kwargs()
return kwargs return kwargs
class StatesPanelView(AdminView, TemplateView):
template_name = "states_panel.html"
title = _("States")
breadcrumb = _("admin / States") + " /"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
"states": State.objects.filter(institution=self.request.user.institution),
"state_definitions" : StateDefinition.objects.filter(institution=self.request.user.institution).order_by('order')
})
return context

View file

@ -96,6 +96,11 @@
{% trans 'Users' %} {% trans 'Users' %}
</a> </a>
</li> </li>
<li class="nav-item">
<a class="nav-link{% if path == 'states' %} active2{% endif %}" href="{% url 'admin:states' %}">
{% trans 'States' %}
</a>
</li>
</ul> </ul>
</li> </li>
{% endif %} {% endif %}