diff --git a/horilla_views/generic/cbv/views.py b/horilla_views/generic/cbv/views.py index e68aad9f8..d49517ed8 100644 --- a/horilla_views/generic/cbv/views.py +++ b/horilla_views/generic/cbv/views.py @@ -15,7 +15,7 @@ from django.http import HttpRequest, HttpResponse, QueryDict from django.shortcuts import render from django.urls import resolve, reverse from django.utils.decorators import method_decorator -from django.utils.translation import gettext_lazy as _trans +from django.utils.translation import gettext_lazy as _ from django.views.generic import DetailView, FormView, ListView, TemplateView from base.methods import closest_numbers, eval_validate, get_key_instances @@ -142,7 +142,7 @@ class HorillaListView(ListView): form = self.get_bulk_form() form.verbose_name = ( form.verbose_name - + f" ({len((eval_validate(request.GET.get('instance_ids','[]'))))} {_trans('Records')})" + + f" ({len((eval_validate(request.GET.get('instance_ids','[]'))))} {_('Records')})" ) return render( request, @@ -168,7 +168,7 @@ class HorillaListView(ListView): ) if instance_ids and form.is_valid(): form.save() - messages.success(request, _trans("Selected Records updated")) + messages.success(request, _("Selected Records updated")) script_id = get_short_uuid(length=3, prefix="bulk") return HttpResponse( @@ -181,7 +181,7 @@ class HorillaListView(ListView): """ ) if not instance_ids: - messages.info(request, _trans("No records selected")) + messages.info(request, _("No records selected")) return render( request, self.bulk_template, @@ -297,7 +297,9 @@ class HorillaListView(ListView): if key in ["filter_applied", "nav_url"] + self.filter_keys_to_remove ] - for key in keys_to_remove + ["referrer"]: + for key in ( + keys_to_remove + ["referrer", "nav_url"] + self.filter_keys_to_remove + ): if key in data_dict.keys(): data_dict.pop(key) context["filter_dict"] = data_dict @@ -500,7 +502,11 @@ class HorillaDetailedView(DetailView): title = "Detailed View" template_name = "generic/horilla_detailed_view.html" - header: dict = {"title": "Horilla", "subtitle": "Horilla Detailed View"} + header: dict = { + "title": "Horilla", + "subtitle": "Horilla Detailed View", + "avatar": "", + } body: list = [] action_method: list = [] @@ -697,9 +703,12 @@ class HorillaCardView(ListView): if value[0] in ["unknown", "on"] + self.filter_keys_to_remove ] - for key in keys_to_remove + ["referrer"]: + for key in ( + keys_to_remove + ["referrer", "nav_url"] + self.filter_keys_to_remove + ): if key in data_dict.keys(): data_dict.pop(key) + context["filter_dict"] = data_dict ordered_ids = list(queryset.values_list("id", flat=True)) @@ -1089,6 +1098,8 @@ class HorillaProfileView(DetailView): template_name = "generic/horilla_profile_view.html" view_id: str = None filter_class: FilterSet = None + push_url: str = None + key_name: str = "pk" # add these method under the model # get_avatar --> image/profile @@ -1209,10 +1220,14 @@ class HorillaProfileView(DetailView): url_name = url.url_name next_url = reverse(url_name, kwargs={key: next_id}) previous_url = reverse(url_name, kwargs={key: previous_id}) + push_url_next = reverse(self.push_url, kwargs={self.key_name: next_id}) + push_url_prev = reverse(self.push_url, kwargs={self.key_name: previous_id}) context["instance_ids"] = str(instance_ids) if instance_ids: context["next_url"] = next_url context["previous_url"] = previous_url + context["push_url_next"] = push_url_next + context["push_url_prev"] = push_url_prev context["display_count"] = display_count context["actions"] = self.actions diff --git a/horilla_views/templates/generic/horilla_list_table.html b/horilla_views/templates/generic/horilla_list_table.html index 6009fa946..56ceb2b4e 100644 --- a/horilla_views/templates/generic/horilla_list_table.html +++ b/horilla_views/templates/generic/horilla_list_table.html @@ -363,4 +363,10 @@ {% endif %} + diff --git a/horilla_views/templates/generic/horilla_profile_view.html b/horilla_views/templates/generic/horilla_profile_view.html index 46ec27e36..104197fb9 100644 --- a/horilla_views/templates/generic/horilla_profile_view.html +++ b/horilla_views/templates/generic/horilla_profile_view.html @@ -17,6 +17,7 @@
  • @@ -80,6 +81,7 @@ + {% if instance|getattribute:"is_active" %} + {% endif %}

    {{instance}}

    diff --git a/horilla_views/templates/generic/quick_actions.html b/horilla_views/templates/generic/quick_actions.html index 80a153f4f..73773592b 100644 --- a/horilla_views/templates/generic/quick_actions.html +++ b/horilla_views/templates/generic/quick_actions.html @@ -133,14 +133,3 @@
    {% endif %} - diff --git a/horilla_views/views.py b/horilla_views/views.py index 0aac9718b..44422d9ef 100644 --- a/horilla_views/views.py +++ b/horilla_views/views.py @@ -520,21 +520,19 @@ class HorillaDeleteConfirmationView(View): model = type(obj) protected_model_count[model._meta.verbose_name_plural] += 1 protected_model_count = dict(protected_model_count) + context = { + "model_map": merge_dicts(MODEL_MAP, PROTECTED_MODEL_MAP), + "dynamic_list_path": DYNAMIC_PATH_MAP, + "delete_object": delete_object, + "protected": protected, + "model_count_sum": sum(model_count.values()), + "related_objects_count": model_count, + "protected_objects_count": protected_model_count, + } + for key, value in self.get_context_data().items(): + context[key] = value - return render( - self.request, - "generic/delete_confirmation.html", - { - "model_map": merge_dicts(MODEL_MAP, PROTECTED_MODEL_MAP), - "dynamic_list_path": DYNAMIC_PATH_MAP, - "delete_object": delete_object, - "protected": protected, - "model_count_sum": sum(model_count.values()), - "related_objects_count": model_count, - "protected_objects_count": protected_model_count, - } - | self.get_context_data(), - ) + return render(self.request, "generic/delete_confirmation.html", context) def post(self, *args, **kwargs): """