[UPDT] Pylint updates

This commit is contained in:
Horilla
2025-02-26 10:56:53 +05:30
parent d299172784
commit 9f78911328
23 changed files with 70 additions and 56 deletions

View File

@@ -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)

View File

@@ -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):

View File

@@ -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__)

View File

@@ -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__)

View File

@@ -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__)

View File

@@ -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

View File

@@ -59,7 +59,7 @@
<div class="oh-switch" style="width: 30px">
{{ field|add_class:'oh-switch__checkbox' }}
</div>
{% else %}
{% else %}
<div id="dynamic_field_{{field.name}}">
{{ field|add_class:'form-control' }}
{{ field.errors }}

View File

@@ -15,11 +15,11 @@
<div class="oh-hover-btn-drawer">
{% if form.df_user_has_change_perm %}
<button
hx-get="{% url "edit-verbose-name" widget.attrs.pk %}?df_model_path={{form.df_form_model_path}}"
hx-get="{% url "edit-verbose-name" widget.attrs.pk %}?df_model_path={{form.df_form_model_path}}"
hx-target="[id='dfModalBody{{ form.df_form_model_path }}']"
onclick="$(`[id='dfModal{{ form.df_form_model_path }}']:first`).addClass('oh-modal--show')"
type="button"
class="oh-hover-btn__small"
type="button"
class="oh-hover-btn__small"
onclick=""><ion-icon name="create-outline"></ion-icon></button>
{% endif %}
{% if form.df_user_has_delete_perm %}
@@ -54,7 +54,7 @@
window.location.reload()
}, 1500);
}
});
}
});
@@ -63,4 +63,4 @@
{% endif %}
</div>
{% endif %}
</div>
</div>

View File

@@ -23,7 +23,7 @@
$("#{{view_id}}Form [name={{field_tuple.0}}]").val({{form.initial|get_item:field_tuple.0|safe}}).change()
</script>
<form
<form
hidden
id="modalButton{{field_tuple.0}}Form"
hx-get="/dynamic-path-{{field_tuple.0}}-{{request.session.session_key}}?dynamic_field={{field_tuple.0}}"
@@ -50,7 +50,7 @@
</button>
</form>
<script class="dynamic_{{field_tuple.0}}_scripts">
$("#{{view_id}}Form [name={{field_tuple.0}}]").change(function (e) {
$("#{{view_id}}Form [name={{field_tuple.0}}]").change(function (e) {
values = $(this).val();
if (!values) {
values = ""
@@ -70,12 +70,11 @@
$("#reload-field{{field_tuple.0}}{{view_id}}").find('input[name=dynamic_initial]').val(values)
}
});
$("#reload-field{{field_tuple.0}}{{view_id}}").submit(function (e) {
$("#reload-field{{field_tuple.0}}{{view_id}}").submit(function (e) {
e.preventDefault();
$(this).find("[name=dynamic_initial]").val();
$(this).find("[name=dynamic_initial]").val();
});
</script>
</div>
{% endfor %}
</div>

View File

@@ -3,6 +3,7 @@ dynamic_fields/urls.py
"""
from django.urls import path
from dynamic_fields import views
urlpatterns = [

View File

@@ -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")

View File

@@ -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')}/"

View File

@@ -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"]

View File

@@ -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.

View File

@@ -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")),

View File

@@ -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

View File

@@ -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"

View File

@@ -3,6 +3,7 @@ outlook_auth/filters.py
"""
import django_filters
from outlook_auth import models

View File

@@ -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.

View File

@@ -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()

View File

@@ -18,4 +18,4 @@
<div style="display: none;" data-ids="[]" id="selectedRecords"></div>
<div hx-get="{% url "outlook_server_nav" %}" hx-trigger="load"></div>
<div class="oh-wrapper" hx-get="{% url "outlook_server_list" %}" hx-trigger="load"></div>
{% endblock settings %}
{% endblock settings %}

View File

@@ -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/<int:pk>/", views.refresh_token, name="refresh_outlook_token"),

View File

@@ -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