From 46adecc3db6ac820b7710fc3c47c46dff69453fe Mon Sep 17 00:00:00 2001 From: Horilla Date: Tue, 4 Mar 2025 14:15:01 +0530 Subject: [PATCH] [FIX] HORILLA VIEWS: Inside htmx not trigger due to one-time hx --- horilla_views/generic/cbv/pipeline.py | 59 +++++++++++++++++ .../templates/generic/horilla_tabs.html | 9 +-- .../templates/generic/pipeline/pipeline.html | 64 +++++++++++++++++++ 3 files changed, 126 insertions(+), 6 deletions(-) create mode 100644 horilla_views/generic/cbv/pipeline.py create mode 100644 horilla_views/templates/generic/pipeline/pipeline.html diff --git a/horilla_views/generic/cbv/pipeline.py b/horilla_views/generic/cbv/pipeline.py new file mode 100644 index 000000000..e3a04d642 --- /dev/null +++ b/horilla_views/generic/cbv/pipeline.py @@ -0,0 +1,59 @@ +""" +horilla_views/generic/cbv/pipeline +""" + +from django.views.generic import ListView +from django.db import models +from django_filters import FilterSet +from horilla_views.cbv_methods import get_short_uuid +from horilla.horilla_middlewares import _thread_locals + + +class Pipeline(ListView): + """ + Pipeline + """ + + model: models.Model = None + filter_class: FilterSet = None + field: str = "" + field_filter_class: FilterSet = None + field_model: models.Model = None + selected_instances_key_name: str = "" + allowed_fields: list = [] + columns: list = [] + view_id: str = get_short_uuid(10, "pipeline") + actions: list = [] + + template_name = "generic/pipeline/pipeline.html" + + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.request = getattr(_thread_locals, "request", None) + self.grouper = self.request.GET.get("grouper", self.grouper) + for allowed_field in self.allowed_fields: + if self.grouper == allowed_field["field"]: + self.field_model = allowed_field["model"] + self.field_filter_class = allowed_field["filter"] + self.url = allowed_field["url"] + self.parameters = allowed_field["parameters"] + self.actions = allowed_field["actions"] + + def get_queryset(self): + if not self.queryset: + self.queryset = self.field_filter_class(self.request.GET).qs.filter( + **self.kwargs + ) + return self.queryset + + def get_context_data(self, **kwargs): + + context = super().get_context_data(**kwargs) + context["groups"] = self.queryset + context["view_id"] = self.view_id + context["allowed_fields"] = self.allowed_fields + context["url"] = self.url + context["parameters"] = self.parameters + context["actions"] = self.actions + context["selected_instances_key_name"] = self.selected_instances_key_name + return context diff --git a/horilla_views/templates/generic/horilla_tabs.html b/horilla_views/templates/generic/horilla_tabs.html index 40a58993a..e1468ed38 100644 --- a/horilla_views/templates/generic/horilla_tabs.html +++ b/horilla_views/templates/generic/horilla_tabs.html @@ -15,14 +15,11 @@
  • @@ -68,7 +65,7 @@ {% if instance %} {% if action.accessibility|accessibility:instance %}
  • - {{action.action}} + {{action.action}}
  • {% endif %} {% else %} diff --git a/horilla_views/templates/generic/pipeline/pipeline.html b/horilla_views/templates/generic/pipeline/pipeline.html new file mode 100644 index 000000000..24c82d195 --- /dev/null +++ b/horilla_views/templates/generic/pipeline/pipeline.html @@ -0,0 +1,64 @@ +{% load i18n recruitmentfilters %} +{% load generic_template_filters %} +
    + {% for group in groups %} +
    +
    +
    +
    + + +
    +
    + + +
    +
    +
    +
    +
    +
    +
    + {% endfor %} + +
    + \ No newline at end of file