diff --git a/admin/templates/states_panel.html b/admin/templates/states_panel.html
index 129f4e3..4fdc30c 100644
--- a/admin/templates/states_panel.html
+++ b/admin/templates/states_panel.html
@@ -38,6 +38,9 @@
{{ state_definition.state }} |
+
@@ -90,6 +93,40 @@
+
+{% for state_definition in state_definitions %}
+
+{% endfor %}
+
+
{% for state_definition in state_definitions %}
diff --git a/admin/urls.py b/admin/urls.py
index 6c7b3e9..8aafced 100644
--- a/admin/urls.py
+++ b/admin/urls.py
@@ -10,8 +10,9 @@ urlpatterns = [
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"),
- path("states/", views.StatesPanelView.as_view(), name="states"),
+ path("states/", views.StatesPanelView.as_view(), name="states_panel"),
path("states/add", views.AddStateDefinitionView.as_view(), name="add_state_definition"),
- path('states/delete/', views.DeleteStateDefinitionView.as_view(), name='delete_state_definition'),
- path('states/update_order/', views.UpdateStateOrderView.as_view(), name='update_state_order'),
+ path("states/delete/", views.DeleteStateDefinitionView.as_view(), name='delete_state_definition'),
+ path("states/update_order/", views.UpdateStateOrderView.as_view(), name='update_state_order'),
+ path("states/edit//", views.UpdateStateDefinitionView.as_view(), name='edit_state_definition'),
]
diff --git a/admin/views.py b/admin/views.py
index 4458ce4..f24a90f 100644
--- a/admin/views.py
+++ b/admin/views.py
@@ -153,7 +153,7 @@ class AddStateDefinitionView(AdminView, StateDefinitionContextMixin, CreateView)
template_name = "states_panel.html"
title = _("New State Definition")
breadcrumb = "Admin / New state"
- success_url = reverse_lazy('admin:states')
+ success_url = reverse_lazy('admin:states_panel')
model = StateDefinition
fields = ('state',)
@@ -175,7 +175,7 @@ class AddStateDefinitionView(AdminView, StateDefinitionContextMixin, CreateView)
class DeleteStateDefinitionView(AdminView, StateDefinitionContextMixin, SuccessMessageMixin, DeleteView):
model = StateDefinition
- success_url = reverse_lazy('admin:states')
+ success_url = reverse_lazy('admin:states_panel')
def get_success_message(self, cleaned_data):
device_logger.info(f" StateDefinition with value {self.object.state} by user {self.request.user}.")
@@ -192,7 +192,7 @@ class DeleteStateDefinitionView(AdminView, StateDefinitionContextMixin, SuccessM
class UpdateStateOrderView(AdminView, TemplateView):
- success_url = reverse_lazy('admin:states')
+ success_url = reverse_lazy('admin:states_panel')
def post(self, request, *args, **kwargs):
form = OrderingStateForm(request.POST)
@@ -218,3 +218,19 @@ class UpdateStateOrderView(AdminView, TemplateView):
else:
return Http404
+
+class UpdateStateDefinitionView(AdminView, UpdateView):
+ model = StateDefinition
+ template_name = 'states_panel.html'
+ fields = ['state']
+ pk_url_kwarg = 'pk'
+
+ def get_queryset(self):
+ return StateDefinition.objects.filter(institution=self.request.user.institution)
+
+ def get_success_url(self):
+ messages.success(self.request, _("State definition updated successfully."))
+ return reverse_lazy('admin:states_panel')
+
+ def form_valid(self, form):
+ return super().form_valid(form)
diff --git a/dashboard/templates/base.html b/dashboard/templates/base.html
index 910a989..be3966b 100644
--- a/dashboard/templates/base.html
+++ b/dashboard/templates/base.html
@@ -98,7 +98,7 @@
-
+
{% trans 'States' %}
|