From 9f78911328d1f6c3222791366d9ec933b8ad1a67 Mon Sep 17 00:00:00 2001 From: Horilla Date: Wed, 26 Feb 2025 10:56:53 +0530 Subject: [PATCH] [UPDT] Pylint updates --- dynamic_fields/admin.py | 5 +++-- dynamic_fields/forms.py | 3 ++- dynamic_fields/management/commands/add_field.py | 10 ++++++---- .../management/commands/delete_field.py | 10 +++++----- dynamic_fields/models.py | 12 ++++++------ dynamic_fields/signals.py | 4 +++- .../templates/dynamic_fields/common/form.html | 2 +- dynamic_fields/templates/dynamic_fields/df.html | 10 +++++----- dynamic_fields/templates/dynamic_fields/form.html | 9 ++++----- dynamic_fields/urls.py | 1 + dynamic_fields/views.py | 7 ++++--- horilla/horilla_settings.py | 5 ++++- outlook_auth/__init__.py | 2 +- outlook_auth/admin.py | 2 +- outlook_auth/apps.py | 2 +- outlook_auth/backends.py | 2 ++ outlook_auth/cbv/views.py | 10 ++++++---- outlook_auth/filters.py | 1 + outlook_auth/models.py | 3 +-- outlook_auth/scheduler.py | 7 ++++--- outlook_auth/templates/outlook/view_records.html | 2 +- outlook_auth/urls.py | 2 +- outlook_auth/views.py | 15 +++++++-------- 23 files changed, 70 insertions(+), 56 deletions(-) diff --git a/dynamic_fields/admin.py b/dynamic_fields/admin.py index 1d4aab74d..8402a7dd7 100644 --- a/dynamic_fields/admin.py +++ b/dynamic_fields/admin.py @@ -1,8 +1,9 @@ from django.contrib import admin -# Register your models here. - from dynamic_fields.models import Choice, DynamicField +# Register your models here. + + admin.site.register(DynamicField) admin.site.register(Choice) diff --git a/dynamic_fields/forms.py b/dynamic_fields/forms.py index 4b021b9d2..62b8e359b 100644 --- a/dynamic_fields/forms.py +++ b/dynamic_fields/forms.py @@ -4,11 +4,12 @@ dynamic_fields/forms.py from django import forms from django.utils.translation import gettext_lazy as _ + from base.forms import ModelForm -from horilla.horilla_middlewares import _thread_locals from dynamic_fields import models from dynamic_fields.df_not_allowed_models import DF_NOT_ALLOWED_MODELS from dynamic_fields.models import DynamicField +from horilla.horilla_middlewares import _thread_locals class DynamicFieldForm(ModelForm): diff --git a/dynamic_fields/management/commands/add_field.py b/dynamic_fields/management/commands/add_field.py index 418b9cf68..c8dc130bc 100644 --- a/dynamic_fields/management/commands/add_field.py +++ b/dynamic_fields/management/commands/add_field.py @@ -1,11 +1,13 @@ import logging -from django.db import connection -from django.core.management.base import BaseCommand -from django.db.backends.base.schema import BaseDatabaseSchemaEditor + from django.contrib.contenttypes.models import ContentType +from django.core.management.base import BaseCommand +from django.db import connection +from django.db.backends.base.schema import BaseDatabaseSchemaEditor from simple_history.models import HistoricalRecords -from dynamic_fields.models import DynamicField + from dynamic_fields.methods import column_exists +from dynamic_fields.models import DynamicField logger = logging.getLogger(__name__) diff --git a/dynamic_fields/management/commands/delete_field.py b/dynamic_fields/management/commands/delete_field.py index d53c8bbec..9503212e6 100644 --- a/dynamic_fields/management/commands/delete_field.py +++ b/dynamic_fields/management/commands/delete_field.py @@ -1,14 +1,14 @@ import logging -from django.db import models -from django.db import connection -from django.core.management.base import BaseCommand -from django.db.backends.base.schema import BaseDatabaseSchemaEditor + from django.contrib.contenttypes.models import ContentType +from django.core.management.base import BaseCommand +from django.db import connection, models +from django.db.backends.base.schema import BaseDatabaseSchemaEditor from simple_history.models import HistoricalRecords + from dynamic_fields.methods import column_exists from dynamic_fields.models import DynamicField - logger = logging.getLogger(__name__) diff --git a/dynamic_fields/models.py b/dynamic_fields/models.py index 70f3bf203..36f11feb4 100644 --- a/dynamic_fields/models.py +++ b/dynamic_fields/models.py @@ -1,16 +1,16 @@ -import logging, re +import logging +import re + from django import forms -from django.utils.translation import gettext_lazy as _ +from django.core.management import call_command from django.db import models from django.utils import timezone -from django.core.management import call_command +from django.utils.translation import gettext_lazy as _ + from dynamic_fields.df_not_allowed_models import DF_NOT_ALLOWED_MODELS from horilla.horilla_middlewares import _thread_locals - - from horilla_automations.methods.methods import get_model_class - logger = logging.getLogger(__name__) diff --git a/dynamic_fields/signals.py b/dynamic_fields/signals.py index f21aa8d36..a4e415f7e 100644 --- a/dynamic_fields/signals.py +++ b/dynamic_fields/signals.py @@ -1,9 +1,11 @@ """ dynamic_fields/signals.py """ -from django.dispatch import receiver + from django.core.management import call_command from django.db.models.signals import pre_delete +from django.dispatch import receiver + from dynamic_fields.models import DynamicField diff --git a/dynamic_fields/templates/dynamic_fields/common/form.html b/dynamic_fields/templates/dynamic_fields/common/form.html index 8ed6efdd9..1ff4984f2 100644 --- a/dynamic_fields/templates/dynamic_fields/common/form.html +++ b/dynamic_fields/templates/dynamic_fields/common/form.html @@ -59,7 +59,7 @@
{{ field|add_class:'oh-switch__checkbox' }}
- {% else %} + {% else %}
{{ field|add_class:'form-control' }} {{ field.errors }} diff --git a/dynamic_fields/templates/dynamic_fields/df.html b/dynamic_fields/templates/dynamic_fields/df.html index 9ba91b1c2..23568c16a 100644 --- a/dynamic_fields/templates/dynamic_fields/df.html +++ b/dynamic_fields/templates/dynamic_fields/df.html @@ -15,11 +15,11 @@
{% if form.df_user_has_change_perm %} {% endif %} {% if form.df_user_has_delete_perm %} @@ -54,7 +54,7 @@ window.location.reload() }, 1500); } - + }); } }); @@ -63,4 +63,4 @@ {% endif %}
{% endif %} -
\ No newline at end of file + diff --git a/dynamic_fields/templates/dynamic_fields/form.html b/dynamic_fields/templates/dynamic_fields/form.html index 79d3e0e47..1c921f97f 100644 --- a/dynamic_fields/templates/dynamic_fields/form.html +++ b/dynamic_fields/templates/dynamic_fields/form.html @@ -23,7 +23,7 @@ $("#{{view_id}}Form [name={{field_tuple.0}}]").val({{form.initial|get_item:field_tuple.0|safe}}).change() - {% endfor %} - diff --git a/dynamic_fields/urls.py b/dynamic_fields/urls.py index fe26f7713..d8857de2a 100644 --- a/dynamic_fields/urls.py +++ b/dynamic_fields/urls.py @@ -3,6 +3,7 @@ dynamic_fields/urls.py """ from django.urls import path + from dynamic_fields import views urlpatterns = [ diff --git a/dynamic_fields/views.py b/dynamic_fields/views.py index 6a7cb7f6d..2f13f23e0 100644 --- a/dynamic_fields/views.py +++ b/dynamic_fields/views.py @@ -2,15 +2,16 @@ dynamic_fields/views.py """ +from django.contrib import messages from django.http import HttpResponse from django.utils.decorators import method_decorator from django.utils.translation import gettext_lazy as _ -from django.contrib import messages from django.views.generic import View -from horilla_views.generic.cbv.views import HorillaFormView -from dynamic_fields import models, forms + +from dynamic_fields import forms, models from dynamic_fields.methods import structured from horilla.decorators import login_required, permission_required +from horilla_views.generic.cbv.views import HorillaFormView @method_decorator(login_required, name="dispatch") diff --git a/horilla/horilla_settings.py b/horilla/horilla_settings.py index f29b56217..17265fa73 100644 --- a/horilla/horilla_settings.py +++ b/horilla/horilla_settings.py @@ -130,6 +130,9 @@ if settings.env("GOOGLE_APPLICATION_CREDENTIALS", default=None): settings.GS_BUCKET_NAME = GS_BUCKET_NAME settings.DEFAULT_FILE_STORAGE = DEFAULT_FILE_STORAGE -if (settings.env("GOOGLE_APPLICATION_CREDENTIALS", default=None) or settings.env("AWS_ACCESS_KEY_ID", default=None)) and "storages" in INSTALLED_APPS: +if ( + settings.env("GOOGLE_APPLICATION_CREDENTIALS", default=None) + or settings.env("AWS_ACCESS_KEY_ID", default=None) +) and "storages" in INSTALLED_APPS: settings.MEDIA_URL = f"{settings.env('MEDIA_URL')}/{settings.env('NAMESPACE')}/" settings.MEDIA_ROOT = f"{settings.env('MEDIA_ROOT')}/{settings.env('NAMESPACE')}/" diff --git a/outlook_auth/__init__.py b/outlook_auth/__init__.py index f3e7b063f..7bec86925 100644 --- a/outlook_auth/__init__.py +++ b/outlook_auth/__init__.py @@ -3,8 +3,8 @@ outlook_auth/__init__.py """ from django.conf import settings -from outlook_auth import scheduler as _scheduler +from outlook_auth import scheduler as _scheduler settings.OUTLOOK_SCOPES = ["https://outlook.office.com/SMTP.Send"] diff --git a/outlook_auth/admin.py b/outlook_auth/admin.py index 49004f064..26ee7658d 100644 --- a/outlook_auth/admin.py +++ b/outlook_auth/admin.py @@ -3,8 +3,8 @@ outlook_auth/admin.py """ from django.contrib import admin -from outlook_auth import models +from outlook_auth import models # Register your models here. diff --git a/outlook_auth/apps.py b/outlook_auth/apps.py index 1da7dc6a3..2920b8f82 100644 --- a/outlook_auth/apps.py +++ b/outlook_auth/apps.py @@ -6,7 +6,7 @@ class OutlookAuthConfig(AppConfig): name = "outlook_auth" def ready(self): - from horilla.urls import urlpatterns,path,include + from horilla.urls import include, path, urlpatterns urlpatterns.append( path("outlook/", include("outlook_auth.urls")), diff --git a/outlook_auth/backends.py b/outlook_auth/backends.py index 705bea801..8dc2ee3ff 100644 --- a/outlook_auth/backends.py +++ b/outlook_auth/backends.py @@ -4,8 +4,10 @@ outlook_auth/backeds.py import base64 import logging + from django.core.mail import EmailMessage from django.core.mail.backends.smtp import EmailBackend + from base.models import EmailLog from horilla.horilla_middlewares import _thread_locals from outlook_auth import models diff --git a/outlook_auth/cbv/views.py b/outlook_auth/cbv/views.py index 2f1cd641f..dbb17300a 100644 --- a/outlook_auth/cbv/views.py +++ b/outlook_auth/cbv/views.py @@ -3,14 +3,15 @@ outlook_auth/cbv.py """ -from django.http import HttpResponse from django.contrib import messages +from django.http import HttpResponse from django.urls import reverse_lazy -from django.utils.translation import gettext_lazy as _ from django.utils.decorators import method_decorator -from horilla_views.generic.cbv import views +from django.utils.translation import gettext_lazy as _ + from horilla_views.cbv_methods import login_required, permission_required -from outlook_auth import models, filters, forms +from horilla_views.generic.cbv import views +from outlook_auth import filters, forms, models @method_decorator(login_required, name="dispatch") @@ -69,6 +70,7 @@ class ServerList(views.HorillaListView): """, } + @method_decorator(login_required, name="dispatch") @method_decorator( permission_required(perm="outlook_auth.add_azureapi"), name="dispatch" diff --git a/outlook_auth/filters.py b/outlook_auth/filters.py index 9a18ff3f4..a1498f580 100644 --- a/outlook_auth/filters.py +++ b/outlook_auth/filters.py @@ -3,6 +3,7 @@ outlook_auth/filters.py """ import django_filters + from outlook_auth import models diff --git a/outlook_auth/models.py b/outlook_auth/models.py index 7a8853643..91bf9bbcd 100644 --- a/outlook_auth/models.py +++ b/outlook_auth/models.py @@ -5,12 +5,11 @@ outlook_auth/models.py from django.db import models from django.utils import timezone from django.utils.translation import gettext_lazy as _ -from base.models import Company +from base.models import Company from horilla_views.cbv_methods import render_template from outlook_auth.methods import sec_to_hm - # Create your models here. diff --git a/outlook_auth/scheduler.py b/outlook_auth/scheduler.py index 3dc299f05..53f0bc55e 100644 --- a/outlook_auth/scheduler.py +++ b/outlook_auth/scheduler.py @@ -3,7 +3,9 @@ outlook_auth/scheduler.py """ -import sys, logging +import logging +import sys + from apscheduler.schedulers.background import BackgroundScheduler logger = logging.getLogger(__name__) @@ -13,8 +15,8 @@ def refresh_outlook_auth_token(): """ scheduler method to refresh token """ - from outlook_auth.views import refresh_outlook_token from outlook_auth.models import AzureApi + from outlook_auth.views import refresh_outlook_token apis = AzureApi.objects.filter(token__isnull=False) for api in apis: @@ -38,4 +40,3 @@ if not any( id="refresh_outlook_auth_token", ) scheduler.start() - diff --git a/outlook_auth/templates/outlook/view_records.html b/outlook_auth/templates/outlook/view_records.html index adb83430b..736d4a2f0 100644 --- a/outlook_auth/templates/outlook/view_records.html +++ b/outlook_auth/templates/outlook/view_records.html @@ -18,4 +18,4 @@
-{% endblock settings %} \ No newline at end of file +{% endblock settings %} diff --git a/outlook_auth/urls.py b/outlook_auth/urls.py index 83d8ec447..2f9e616fb 100644 --- a/outlook_auth/urls.py +++ b/outlook_auth/urls.py @@ -3,10 +3,10 @@ outlook_auth/urls.py """ from django.urls import path + from outlook_auth import views from outlook_auth.cbv import views as cbv - urlpatterns = [ path("login/", views.outlook_login, name="outlook_login"), path("refresh//", views.refresh_token, name="refresh_outlook_token"), diff --git a/outlook_auth/views.py b/outlook_auth/views.py index 370381c38..11a44b577 100644 --- a/outlook_auth/views.py +++ b/outlook_auth/views.py @@ -2,17 +2,16 @@ outlook_auth/views.py """ -from requests_oauthlib import OAuth2Session from datetime import datetime -from django.http import HttpResponseRedirect -from django.utils.translation import gettext_lazy as _ + from django.contrib import messages -from django.shortcuts import redirect, render from django.core.cache import cache -from horilla.decorators import ( - login_required, - permission_required, -) +from django.http import HttpResponseRedirect +from django.shortcuts import redirect, render +from django.utils.translation import gettext_lazy as _ +from requests_oauthlib import OAuth2Session + +from horilla.decorators import login_required, permission_required from outlook_auth import models