From e428204b8b36442d35a0b04b3281287ee9cd5de8 Mon Sep 17 00:00:00 2001 From: Horilla Date: Thu, 13 Jun 2024 11:22:59 +0530 Subject: [PATCH] Pylint updates --- horilla/signals.py | 1 - horilla_automations/apps.py | 5 +-- horilla_automations/forms.py | 4 ++- horilla_automations/methods/methods.py | 4 ++- horilla_automations/methods/serialize.py | 4 +-- horilla_automations/migrations/__init__.py | 1 - horilla_automations/models.py | 6 ++-- horilla_automations/signals.py | 25 +++++++-------- .../static/automation/automation.js | 8 ++--- .../horilla_automations/automation_form.html | 6 ++-- .../horilla_automations/automations.html | 2 +- horilla_automations/urls.py | 3 +- horilla_automations/views/cbvs.py | 10 +++--- horilla_automations/views/views.py | 13 ++++---- horilla_views/admin.py | 9 +++--- horilla_views/apps.py | 4 +-- horilla_views/cbv_methods.py | 18 +++++------ horilla_views/forms.py | 3 +- horilla_views/generic/cbv/views.py | 31 +++++++++---------- horilla_views/models.py | 7 +++-- horilla_views/templates/generic/as_list.html | 2 +- .../templates/generic/custom_list.html | 2 +- .../templates/generic/filter_tags.html | 10 +++--- horilla_views/templates/generic/form.html | 4 +-- horilla_views/templates/generic/group_by.html | 26 ++++++++-------- horilla_views/templates/generic/hello.html | 2 +- .../templates/generic/horilla_card.html | 2 +- .../templates/generic/horilla_form.html | 3 +- .../templates/generic/horilla_list.html | 24 +++++++------- .../templates/generic/horilla_nav.html | 16 +++++----- .../templates/generic/horilla_section.html | 16 +++++----- .../templates/generic/horilla_tabs.html | 10 +++--- horilla_views/templates/generic/index.html | 2 +- .../generic/reload_select_field.html | 4 +-- .../templatetags/generic_template_filters.py | 9 +++--- horilla_views/urls.py | 2 +- horilla_views/views.py | 6 +++- 37 files changed, 156 insertions(+), 148 deletions(-) diff --git a/horilla/signals.py b/horilla/signals.py index b0acc5554..4be6ab3b9 100644 --- a/horilla/signals.py +++ b/horilla/signals.py @@ -4,6 +4,5 @@ horilla/signals.py from django.dispatch import Signal, receiver - pre_bulk_update = Signal() post_bulk_update = Signal() diff --git a/horilla_automations/apps.py b/horilla_automations/apps.py index 6bedeb5ac..18968799a 100644 --- a/horilla_automations/apps.py +++ b/horilla_automations/apps.py @@ -1,4 +1,5 @@ from django.apps import AppConfig + from horilla_automations.signals import start_automation @@ -9,10 +10,10 @@ class HorillaAutomationConfig(AppConfig): def ready(self) -> None: ready = super().ready() try: - from recruitment.models import Candidate - from horilla_automations.models import MODEL_CHOICES from employee.models import Employee from horilla_automations.methods.methods import get_related_models + from horilla_automations.models import MODEL_CHOICES + from recruitment.models import Candidate main_models = [Candidate, Employee] for main_model in main_models: diff --git a/horilla_automations/forms.py b/horilla_automations/forms.py index 81dc12a68..78d858d7d 100644 --- a/horilla_automations/forms.py +++ b/horilla_automations/forms.py @@ -3,11 +3,13 @@ horilla_automations/forms.py """ from typing import Any + from django import forms from django.template.loader import render_to_string + +from base.forms import ModelForm from horilla_automations.methods.methods import generate_choices from horilla_automations.models import MODEL_CHOICES, MailAutomation -from base.forms import ModelForm class AutomationForm(ModelForm): diff --git a/horilla_automations/methods/methods.py b/horilla_automations/methods/methods.py index 61c445db8..d35953e42 100644 --- a/horilla_automations/methods/methods.py +++ b/horilla_automations/methods/methods.py @@ -4,8 +4,10 @@ horilla_automations/methods/methods.py """ import operator -from django.http import QueryDict + from django.core.exceptions import FieldDoesNotExist +from django.http import QueryDict + from employee.models import Employee from horilla.models import HorillaModel from recruitment.models import Candidate diff --git a/horilla_automations/methods/serialize.py b/horilla_automations/methods/serialize.py index fa58d18dc..3eb1fa594 100644 --- a/horilla_automations/methods/serialize.py +++ b/horilla_automations/methods/serialize.py @@ -70,9 +70,7 @@ def serialize_form(form, prefix=""): related_field_structure = { "name": prefix + field_name + "__" + related_field["name"], "type": related_field["type"], - "label": related_field["label"].capitalize() - + " | " - + field.label, + "label": related_field["label"].capitalize() + " | " + field.label, "required": related_field["required"], } if related_field.get("options"): diff --git a/horilla_automations/migrations/__init__.py b/horilla_automations/migrations/__init__.py index 8b1378917..e69de29bb 100644 --- a/horilla_automations/migrations/__init__.py +++ b/horilla_automations/migrations/__init__.py @@ -1 +0,0 @@ - diff --git a/horilla_automations/models.py b/horilla_automations/models.py index 2e62b45e3..b0f4949fd 100644 --- a/horilla_automations/models.py +++ b/horilla_automations/models.py @@ -1,11 +1,13 @@ from typing import Any + from django.conf import settings from django.db import models from django.urls import reverse -from horilla.models import HorillaModel from django.utils.translation import gettext_lazy as _trans -from horilla_automations.methods.methods import get_related_models + from employee.models import Employee +from horilla.models import HorillaModel +from horilla_automations.methods.methods import get_related_models from horilla_views.cbv_methods import render_template from recruitment.models import RecruitmentMailTemplate diff --git a/horilla_automations/signals.py b/horilla_automations/signals.py index ff5321caf..418d141a8 100644 --- a/horilla_automations/signals.py +++ b/horilla_automations/signals.py @@ -6,14 +6,16 @@ horilla_automation/signals.py import copy import threading import types + from django import template -from django.db.models.signals import post_save, pre_save, post_delete -from django.dispatch import receiver -from django.db.models.query import QuerySet -from django.db import models from django.core.mail import EmailMessage +from django.db import models +from django.db.models.query import QuerySet +from django.db.models.signals import post_delete, post_save, pre_save +from django.dispatch import receiver + from base.thread_local_middleware import _thread_locals -from horilla.signals import pre_bulk_update, post_bulk_update +from horilla.signals import post_bulk_update, pre_bulk_update @classmethod @@ -35,11 +37,8 @@ def start_automation(): """ Automation signals """ + from horilla_automations.methods.methods import get_model_class, split_query_string from horilla_automations.models import MailAutomation - from horilla_automations.methods.methods import ( - split_query_string, - get_model_class, - ) @receiver(post_delete, sender=MailAutomation) @receiver(post_save, sender=MailAutomation) @@ -327,14 +326,14 @@ def send_mail(request, automation, instance): """ mail sending method """ - from horilla_views.templatetags.generic_template_filters import getattribute + from base.backends import ConfiguredEmailBackend + from base.methods import generate_pdf + from horilla.decorators import logger from horilla_automations.methods.methods import ( get_model_class, get_related_field_model, ) - from base.methods import generate_pdf - from base.backends import ConfiguredEmailBackend - from horilla.decorators import logger + from horilla_views.templatetags.generic_template_filters import getattribute mail_template = automation.mail_template pk = getattribute(instance, automation.mail_details) diff --git a/horilla_automations/static/automation/automation.js b/horilla_automations/static/automation/automation.js index d3f11b9b4..c96870931 100644 --- a/horilla_automations/static/automation/automation.js +++ b/horilla_automations/static/automation/automation.js @@ -61,7 +61,7 @@ function getToMail(element) {
- -
\ No newline at end of file + diff --git a/horilla_automations/templates/horilla_automations/automations.html b/horilla_automations/templates/horilla_automations/automations.html index 819adb719..a924e0f21 100644 --- a/horilla_automations/templates/horilla_automations/automations.html +++ b/horilla_automations/templates/horilla_automations/automations.html @@ -1,3 +1,3 @@ {% extends "index.html" %} {% block content %} -{% endblock content %} \ No newline at end of file +{% endblock content %} diff --git a/horilla_automations/urls.py b/horilla_automations/urls.py index 490b19c69..5f566d6d3 100644 --- a/horilla_automations/urls.py +++ b/horilla_automations/urls.py @@ -3,9 +3,8 @@ horilla_automations/urls.py """ from django.urls import path -from horilla_automations.views import views -from horilla_automations.views import cbvs +from horilla_automations.views import cbvs, views urlpatterns = [ path( diff --git a/horilla_automations/views/cbvs.py b/horilla_automations/views/cbvs.py index a4e44cfab..75035fe38 100644 --- a/horilla_automations/views/cbvs.py +++ b/horilla_automations/views/cbvs.py @@ -3,13 +3,15 @@ horilla_automations/views/cbvs.py """ from typing import Any + +from django.contrib import messages +from django.urls import reverse_lazy +from django.utils.translation import gettext_lazy as _trans + +from horilla_automations import models from horilla_automations.filters import AutomationFilter from horilla_automations.forms import AutomationForm from horilla_views.generic.cbv import views -from django.urls import reverse_lazy -from django.utils.translation import gettext_lazy as _trans -from django.contrib import messages -from horilla_automations import models class AutomationSectionView(views.HorillaSectionView): diff --git a/horilla_automations/views/views.py b/horilla_automations/views/views.py index b41f416de..5d4ec8d4a 100644 --- a/horilla_automations/views/views.py +++ b/horilla_automations/views/views.py @@ -3,18 +3,17 @@ horilla_automation/views/views.py """ from django import forms +from django.contrib import messages from django.http import JsonResponse -from horilla.decorators import login_required from django.shortcuts import redirect from django.urls import reverse -from django.contrib import messages -from horilla_automations.methods.methods import generate_choices -from horilla_automations.models import MailAutomation -from horilla.decorators import permission_required -from recruitment.models import Candidate -from employee.models import Employee +from employee.models import Employee +from horilla.decorators import login_required, permission_required +from horilla_automations.methods.methods import generate_choices from horilla_automations.methods.serialize import serialize_form +from horilla_automations.models import MailAutomation +from recruitment.models import Candidate @login_required diff --git a/horilla_views/admin.py b/horilla_views/admin.py index 656effc43..3334b93b7 100644 --- a/horilla_views/admin.py +++ b/horilla_views/admin.py @@ -1,10 +1,11 @@ from django.contrib import admin + from horilla_views.models import ( - ToggleColumn, - ParentModel, - childModel, - ActiveTab, ActiveGroup, + ActiveTab, + ParentModel, + ToggleColumn, + childModel, ) admin.site.register([ToggleColumn, ParentModel, childModel, ActiveTab, ActiveGroup]) diff --git a/horilla_views/apps.py b/horilla_views/apps.py index d5819ff6f..0643df3f6 100644 --- a/horilla_views/apps.py +++ b/horilla_views/apps.py @@ -2,5 +2,5 @@ from django.apps import AppConfig class HorillaViewsConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'horilla_views' + default_auto_field = "django.db.models.BigAutoField" + name = "horilla_views" diff --git a/horilla_views/cbv_methods.py b/horilla_views/cbv_methods.py index 37339a0e3..acaaeb0c6 100644 --- a/horilla_views/cbv_methods.py +++ b/horilla_views/cbv_methods.py @@ -2,26 +2,27 @@ horilla/cbv_methods.py """ -from urllib.parse import urlencode import uuid +from urllib.parse import urlencode from venv import logger + from django import template +from django.contrib import messages +from django.core.paginator import Paginator +from django.http import HttpResponse +from django.middleware.csrf import get_token from django.shortcuts import redirect, render from django.template import loader -from django.template.loader import render_to_string from django.template.defaultfilters import register +from django.template.loader import render_to_string from django.urls import reverse -from django.contrib import messages -from django.http import HttpResponse -from django.core.paginator import Paginator -from django.middleware.csrf import get_token -from django.utils.html import format_html from django.utils.functional import lazy +from django.utils.html import format_html from django.utils.safestring import SafeString +from base.thread_local_middleware import _thread_locals from horilla import settings from horilla_views.templatetags.generic_template_filters import getattribute -from base.thread_local_middleware import _thread_locals def decorator_with_arguments(decorator): @@ -119,7 +120,6 @@ def permission_required(function, perm): return _function - def csrf_input(request): return format_html( '', diff --git a/horilla_views/forms.py b/horilla_views/forms.py index 4726429b2..1fbd96c26 100644 --- a/horilla_views/forms.py +++ b/horilla_views/forms.py @@ -3,8 +3,9 @@ horilla_views/forms.py """ from django import forms -from django.utils.safestring import SafeText from django.template.loader import render_to_string +from django.utils.safestring import SafeText + from base.thread_local_middleware import _thread_locals diff --git a/horilla_views/generic/cbv/views.py b/horilla_views/generic/cbv/views.py index e47f999b3..6cf64d9f0 100644 --- a/horilla_views/generic/cbv/views.py +++ b/horilla_views/generic/cbv/views.py @@ -3,35 +3,32 @@ horilla/generic/views.py """ import json +from typing import Any +from urllib.parse import parse_qs + from django import forms +from django.core.paginator import Page from django.http import HttpRequest, HttpResponse, QueryDict from django.shortcuts import render -from django.urls import reverse -from typing import Any -from django.urls import resolve -from urllib.parse import parse_qs -from django.core.paginator import Page -from django.views.generic import ListView, DetailView, TemplateView, FormView +from django.urls import resolve, reverse +from django.views.generic import DetailView, FormView, ListView, TemplateView + from attendance.methods.group_by import group_by_queryset -from base.methods import ( - closest_numbers, - get_key_instances, -) +from base.methods import closest_numbers, get_key_instances +from base.thread_local_middleware import _thread_locals from horilla.filters import FilterSet from horilla_views import models from horilla_views.cbv_methods import ( get_short_uuid, paginator_qry, - update_initial_cache, sortby, + structured, + update_initial_cache, update_saved_filter_cache, ) -from base.thread_local_middleware import _thread_locals -from horilla_views.cbv_methods import structured from horilla_views.forms import ToggleColumnForm from horilla_views.templatetags.generic_template_filters import getattribute - cache = {} saved_filters = {} @@ -198,7 +195,7 @@ class HorillaListView(ListView): groups, self._saved_filters.get("page"), 10 ) cache[self.request.session.session_key][HorillaListView] = context - from horilla.urls import urlpatterns, path + from horilla.urls import path, urlpatterns self.export_path = f"export-list-view-{get_short_uuid(4)}/" @@ -216,7 +213,7 @@ class HorillaListView(ListView): """ Export list view visible columns """ - from import_export import resources, fields + from import_export import fields, resources request = getattr(_thread_locals, "request", None) ids = eval(request.GET["ids"]) @@ -598,7 +595,7 @@ class HorillaFormView(FormView): "form": form, } - from horilla.urls import urlpatterns, path + from horilla.urls import path, urlpatterns urlpatterns.append( path( diff --git a/horilla_views/models.py b/horilla_views/models.py index 3899ce772..93a54c6f9 100644 --- a/horilla_views/models.py +++ b/horilla_views/models.py @@ -1,8 +1,10 @@ import json -from django.db import models + from django.contrib.auth.models import User -from horilla.models import HorillaModel +from django.db import models + from base.thread_local_middleware import _thread_locals +from horilla.models import HorillaModel # Create your models here. @@ -44,6 +46,7 @@ class ActiveGroup(HorillaModel): """ ActiveGroup """ + path = models.CharField(max_length=256) group_target = models.CharField(max_length=256) group_by_field = models.CharField(max_length=256) diff --git a/horilla_views/templates/generic/as_list.html b/horilla_views/templates/generic/as_list.html index 205984c3b..d703cf509 100644 --- a/horilla_views/templates/generic/as_list.html +++ b/horilla_views/templates/generic/as_list.html @@ -29,4 +29,4 @@ {% endfor %} - \ No newline at end of file + diff --git a/horilla_views/templates/generic/custom_list.html b/horilla_views/templates/generic/custom_list.html index 237433c14..f5cae0684 100644 --- a/horilla_views/templates/generic/custom_list.html +++ b/horilla_views/templates/generic/custom_list.html @@ -6,4 +6,4 @@

Footer

- \ No newline at end of file + diff --git a/horilla_views/templates/generic/filter_tags.html b/horilla_views/templates/generic/filter_tags.html index fbc18ba85..b7a2e8670 100644 --- a/horilla_views/templates/generic/filter_tags.html +++ b/horilla_views/templates/generic/filter_tags.html @@ -44,11 +44,11 @@ {% trans 'Filters' %}: - {% endif %} - {%for field,values in filter_dict.items %} {% if values %} + {% endif %} + {%for field,values in filter_dict.items %} {% if values %} {% with translation_field=field|filter_field %} - {% trans translation_field %} : + {% trans translation_field %} : {% for value in values %} ${fieldLabel("{% trans value %}", "{{field}}")} {% endfor %} @@ -66,8 +66,8 @@ {% if filter_dict %} - {% endif %} + > + {% endif %} `); nav.html(tags); diff --git a/horilla_views/templates/generic/form.html b/horilla_views/templates/generic/form.html index d0edf7056..b730ca6ee 100644 --- a/horilla_views/templates/generic/form.html +++ b/horilla_views/templates/generic/form.html @@ -37,7 +37,7 @@
{{ field|add_class:'oh-switch__checkbox' }}
- {% else %} + {% else %}
{{ field|add_class:'form-control' }} {% endif %} {{ field.errors }}
@@ -58,4 +58,4 @@ - \ No newline at end of file + diff --git a/horilla_views/templates/generic/group_by.html b/horilla_views/templates/generic/group_by.html index a93c6dc72..ef763b7ea 100644 --- a/horilla_views/templates/generic/group_by.html +++ b/horilla_views/templates/generic/group_by.html @@ -12,8 +12,8 @@ style="cursor: pointer;"> {% trans "Select All" %}{{select_all_path}} -
-
{{cell.0}}
{% endfor %}{% if options or option_method%}
@@ -171,7 +171,7 @@
{% endif %} - {% for cell in columns %} + {% for cell in columns %} {% with attribute=cell.1 index=forloop.counter %} {% if not cell.2 %}
- {% trans "Page" %} {{ group.list.number }} + {% trans "Page" %} {{ group.list.number }} {% trans "of" %} {{ group.list.paginator.num_pages }}.
\ No newline at end of file +
diff --git a/horilla_views/templates/generic/hello.html b/horilla_views/templates/generic/hello.html index d18125b98..a324165d4 100644 --- a/horilla_views/templates/generic/hello.html +++ b/horilla_views/templates/generic/hello.html @@ -1,3 +1,3 @@ \ No newline at end of file + diff --git a/horilla_views/templates/generic/horilla_card.html b/horilla_views/templates/generic/horilla_card.html index b1e62d37d..b04cf531a 100644 --- a/horilla_views/templates/generic/horilla_card.html +++ b/horilla_views/templates/generic/horilla_card.html @@ -15,7 +15,7 @@ {% if show_filter_tags %} {% include "generic/filter_tags.html" %} - {% endif %} + {% endif %}
{% for instance in queryset %}
diff --git a/horilla_views/templates/generic/horilla_form.html b/horilla_views/templates/generic/horilla_form.html index c8010794a..d105ab397 100644 --- a/horilla_views/templates/generic/horilla_form.html +++ b/horilla_views/templates/generic/horilla_form.html @@ -26,7 +26,7 @@ Reload Field {% endfor %} - diff --git a/horilla_views/templates/generic/horilla_list.html b/horilla_views/templates/generic/horilla_list.html index 199fcf49a..76b5e0541 100644 --- a/horilla_views/templates/generic/horilla_list.html +++ b/horilla_views/templates/generic/horilla_list.html @@ -16,8 +16,8 @@ style="cursor: pointer;"> {% trans "Select All" %}{{select_all_path}}
-
-
@@ -116,11 +116,11 @@
{% endif %} {% for cell in columns %} -
-
{{cell.0}} @@ -190,7 +190,7 @@ />
- {% endif %} {% for cell in columns %} + {% endif %} {% for cell in columns %} {% with attribute=cell.1 index=forloop.counter %} {% if not cell.2 %}
selectSelected("#{{view_id|safe}}") - {% endif %} + {% endif %} {% endif %}
\ No newline at end of file + diff --git a/horilla_views/templates/generic/horilla_section.html b/horilla_views/templates/generic/horilla_section.html index bb5ece020..1b95eecb1 100644 --- a/horilla_views/templates/generic/horilla_section.html +++ b/horilla_views/templates/generic/horilla_section.html @@ -21,24 +21,24 @@ >
-
-
-
-
diff --git a/horilla_views/templates/generic/horilla_tabs.html b/horilla_views/templates/generic/horilla_tabs.html index cb059c49a..b62a9d22c 100644 --- a/horilla_views/templates/generic/horilla_tabs.html +++ b/horilla_views/templates/generic/horilla_tabs.html @@ -1,5 +1,5 @@ -{% comment %} {% extends "index.html" %} -{% block content %} +{% comment %} {% extends "index.html" %} +{% block content %} {% comment %} {% include "generic/components.html" %} {% endcomment %} {% comment %} {% include "attendance/attendance/attendance_nav.html" %} {% endcomment %} {% load i18n generic_template_filters %} @@ -79,7 +79,7 @@
\ No newline at end of file + diff --git a/horilla_views/templates/generic/index.html b/horilla_views/templates/generic/index.html index 00d586b6b..b839437ea 100644 --- a/horilla_views/templates/generic/index.html +++ b/horilla_views/templates/generic/index.html @@ -35,4 +35,4 @@
-{% endblock content %} \ No newline at end of file +{% endblock content %} diff --git a/horilla_views/templates/generic/reload_select_field.html b/horilla_views/templates/generic/reload_select_field.html index 4c2093e37..b423c5700 100644 --- a/horilla_views/templates/generic/reload_select_field.html +++ b/horilla_views/templates/generic/reload_select_field.html @@ -3,11 +3,11 @@ - \ No newline at end of file + diff --git a/horilla_views/templatetags/generic_template_filters.py b/horilla_views/templatetags/generic_template_filters.py index bceb34a3b..2fd04b8a4 100644 --- a/horilla_views/templatetags/generic_template_filters.py +++ b/horilla_views/templatetags/generic_template_filters.py @@ -5,11 +5,12 @@ This module is used to write custom template filters. """ -import re, types -from django import template -from django.template.defaultfilters import register -from django.conf import settings +import re +import types +from django import template +from django.conf import settings +from django.template.defaultfilters import register register = template.Library() diff --git a/horilla_views/urls.py b/horilla_views/urls.py index 927b0835c..f429f68e0 100644 --- a/horilla_views/urls.py +++ b/horilla_views/urls.py @@ -3,10 +3,10 @@ horilla_views/urls.py """ from django.urls import path + from horilla_views import views from horilla_views.generic.cbv.views import ReloadMessages - urlpatterns = [ path("toggle-columns", views.ToggleColumn.as_view(), name="toggle-columns"), path("active-tab", views.ActiveTab.as_view(), name="active-tab"), diff --git a/horilla_views/views.py b/horilla_views/views.py index 09989021b..9e21fbb86 100644 --- a/horilla_views/views.py +++ b/horilla_views/views.py @@ -1,8 +1,10 @@ import importlib + from django import forms from django.http import HttpResponse, JsonResponse from django.shortcuts import render from django.views import View + from horilla_views import models from horilla_views.cbv_methods import get_short_uuid from horilla_views.generic.cbv.views import dynamic_create_cache @@ -14,6 +16,7 @@ class ToggleColumn(View): """ ToggleColumn """ + def get(self, *args, **kwargs): """ method to toggle columns @@ -43,6 +46,7 @@ class ReloadField(View): """ ReloadField """ + def get(self, request, *args, **kwargs): """ Http method to reload dynamic create fields @@ -89,7 +93,7 @@ class ReloadField(View): class ActiveTab(View): def get(self, *args, **kwargs): - """ + """ CBV method to handle active tab """ path = self.request.GET.get("path")