Pylint updates

This commit is contained in:
Horilla
2024-06-13 11:22:59 +05:30
parent b9df7023be
commit e428204b8b
37 changed files with 156 additions and 148 deletions

View File

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

View File

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

View File

@@ -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(
'<input type="hidden" name="csrfmiddlewaretoken" value="{}">',

View File

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

View File

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

View File

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

View File

@@ -29,4 +29,4 @@
{% endfor %}
</ul>
<input type="submit" hidden>
</form>
</form>

View File

@@ -6,4 +6,4 @@
<h2>
Footer
</h2>
</div>
</div>

View File

@@ -44,11 +44,11 @@
<span class="oh-titlebar__tag oh-titlebar__tag--custom"
>{% trans 'Filters' %}:</span
>
{% 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 %}
<span class="oh-titlebar__tag filter-field" >
{% trans translation_field %} :
{% trans translation_field %} :
{% for value in values %}
${fieldLabel("{% trans value %}", "{{field}}")}
{% endfor %}
@@ -66,8 +66,8 @@
{% if filter_dict %}
<span class="oh-titlebar__tag oh-titlebar__tag--custom" title="{% trans 'Clear All' %}" role="button" onclick="clearAllFilter($(this));"
><ion-icon class="close-icon" name="close-outline"></ion-icon></span
>
{% endif %}
>
{% endif %}
`);
nav.html(tags);

View File

@@ -37,7 +37,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' }} {% endif %} {{ field.errors }}
</div>
@@ -58,4 +58,4 @@
</div>
</div>
</div>
</div>
</div>

View File

@@ -12,8 +12,8 @@
style="cursor: pointer;">
{% trans "Select All" %}{{select_all_path}}
</div>
<div
id="unselect_{{view_id}}"
<div
id="unselect_{{view_id}}"
class="oh-checkpoint-badge text-secondary d-none"
style="cursor: pointer;"
onclick="
@@ -34,8 +34,8 @@
0
</span> {% trans "Selected" %}
</div>
<div
id="export_{{view_id}}"
<div
id="export_{{view_id}}"
class="oh-checkpoint-badge text-info d-none"
style="cursor: pointer;"
onclick="
@@ -66,7 +66,7 @@
<div class="oh-accordion-meta">
<div class="oh-accordion-meta__item">
<div class="oh-accordion-meta__header"
data-field="{{saved_filters.field}}"
data-field="{{saved_filters.field}}"
data-path="{{request.path}}"
data-group="{{forloop.counter}}"
data-open=false
@@ -122,7 +122,7 @@
{% endif %}
{% for cell in columns %}
<div class="oh-sticky-table__th"
>{{cell.0}}</div>
{% endfor %}{% if options or option_method%}
<div class="oh-sticky-table__th" >
@@ -171,7 +171,7 @@
</div>
</div>
{% endif %}
{% for cell in columns %}
{% for cell in columns %}
{% with attribute=cell.1 index=forloop.counter %} {% if not cell.2 %}
<div
class="{% if index == 1 %} oh-sticky-table__sd {% else %} oh-sticky-table__td{% endif %}"
@@ -234,7 +234,7 @@
</div>
<div class="oh-pagination">
<span class="oh-pagination__page">
{% trans "Page" %} {{ group.list.number }}
{% trans "Page" %} {{ group.list.number }}
{% trans "of" %} {{ group.list.paginator.num_pages }}.
</span>
<nav class="oh-pagination__nav">
@@ -370,7 +370,7 @@
ids = JSON.parse(
$("#selectedInstances").attr("data-ids") || "[]"
);
ids = Array.from(new Set(ids));
ids = Array.from(new Set(ids));
let index = ids.indexOf(id);
if (!ids.includes(id)) {
ids.push(id);
@@ -382,13 +382,13 @@
$("#selectedInstances").attr("data-ids", JSON.stringify(ids));
}
);
</script>
{% endif %}
{% endif %}
<script>
$(".oh-accordion-meta__header").click(function (e) {
$(".oh-accordion-meta__header").click(function (e) {
var open = $(this).attr("data-open");
open = JSON.parse(open)
$(this).attr("data-open", !open);
@@ -412,4 +412,4 @@
$("#{{view_id|safe}}").find(`{{active_target|safe}}`).click();
{% endif %}
</script>
</div>
</div>

View File

@@ -1,3 +1,3 @@
<button>
Hello
</button>
</button>

View File

@@ -15,7 +15,7 @@
</button>
{% if show_filter_tags %}
{% include "generic/filter_tags.html" %}
{% endif %}
{% endif %}
<div class="oh-layout--grid-3">
{% for instance in queryset %}
<div class="oh-kanban-card {{card_status_class|format:instance|safe}}" {{card_attrs|format:instance|safe}}>

View File

@@ -26,7 +26,7 @@
Reload Field
</button>
<script>
$("#{{view_id}} [name={{field_tuple.0}}]").change(function (e) {
$("#{{view_id}} [name={{field_tuple.0}}]").change(function (e) {
if (this.value=="dynamic_create") {
$("#modalButton{{field_tuple.0}}").click()
$(this).val("").change();
@@ -34,4 +34,3 @@
});
</script>
{% endfor %}

View File

@@ -16,8 +16,8 @@
style="cursor: pointer;">
{% trans "Select All" %}{{select_all_path}}
</div>
<div
id="unselect_{{view_id}}"
<div
id="unselect_{{view_id}}"
class="oh-checkpoint-badge text-secondary d-none"
style="cursor: pointer;"
onclick="
@@ -38,8 +38,8 @@
0
</span> {% trans "Selected" %}
</div>
<div
id="export_{{view_id}}"
<div
id="export_{{view_id}}"
class="oh-checkpoint-badge text-info d-none"
style="cursor: pointer;"
onclick="
@@ -63,7 +63,7 @@
</div>
{% endif %}
<div class="oh-table_sticky--wrapper">
<div class="oh-sticky-dropdown--header" style="z-index:13;">
<div class="oh-dropdown" x-data="{open: false}">
@@ -116,11 +116,11 @@
</div>
</div>
{% endif %} {% for cell in columns %}
<div
<div
class="oh-sticky-table__th"
style="z-index: 11;width:100px;">
<div
<div
{% for sort_map in sortby_mapping %}
{% if sort_map.0 == cell.0 %}
hx-get="{{search_url}}?{{saved_filters.urlencode}}&{{sortby_key}}={{sort_map.1}}&filter_applied=on"
@@ -136,7 +136,7 @@
"
{% endif %}
{% endfor %}
style="width: 200px;"
>
{{cell.0}}
@@ -190,7 +190,7 @@
/>
</div>
</div>
{% endif %} {% for cell in columns %}
{% endif %} {% for cell in columns %}
{% with attribute=cell.1 index=forloop.counter %} {% if not cell.2 %}
<div
class="{% if index == 1 %} oh-sticky-table__sd {% else %} oh-sticky-table__td{% endif %}"
@@ -338,11 +338,11 @@
<script>
selectSelected("#{{view_id|safe}}")
</script>
{% endif %}
{% endif %}
{% endif %}
</div>
<script>
$("ul[data-search-url] a").click(function (e) {
$("ul[data-search-url] a").click(function (e) {
e.preventDefault();
const url = $(this).attr("hx-get")
const $urlObj = $('<a>', { href: url });

View File

@@ -97,7 +97,7 @@
{% include filter_body_template %}
<input type="radio" name="filter_applied" checked hidden>
<div class="oh-dropdown__filter-footer">
<button
<button
type="submit"
id="applyFilter"
onclick="filterFormSubmit('filterForm')"
@@ -108,7 +108,7 @@
</div>
</div>
{% else %}
<button
<button
hidden
type="submit"
id="applyFilter"
@@ -164,7 +164,7 @@
<li class="oh-dropdown__item">
<a class="oh-dropdown__link" {{action.attrs|safe}}>{{action.action}}</a>
</li>
{% endfor %}
{% endfor %}
</ul>
</div>
</div>
@@ -174,7 +174,7 @@
<input type="hidden" id="sortInput">
</form>
{% if create_attrs %}
<a
<a
onclick="event.preventDefault();event.stopPropagation()"
class="oh-btn oh-btn--secondary ml-2"
{{create_attrs|safe}}
@@ -191,15 +191,15 @@
</div>
<script>
$(".oh-btn--view").click(function (e) {
$(".oh-btn--view").click(function (e) {
e.preventDefault();
$(".oh-btn--view-active").removeClass("oh-btn--view-active");
$(".oh-btn--view-active").removeClass("oh-btn--view-active");
$(this).addClass("oh-btn--view-active");
});
if (!$(".oh-btn--view-active").length) {
// $("a.oh-btn--view:first").trigger("click")
}
$(".oh-accordion-header").click(function (e) {
$(".oh-accordion-header").click(function (e) {
e.preventDefault();
$(this).parent().toggleClass("oh-accordion--show");
});
@@ -220,4 +220,4 @@
$("#filterForm select").parent().find("span").remove()
$("#filterForm select").select2()
});
</script>
</script>

View File

@@ -21,24 +21,24 @@
>
</div>
<div
<div
hx-get="{{nav_url}}?{{request.GET.urlencode}}"
hx-trigger="load"
>
<div
class="mt-5 oh-wrapper animated-background"
<div
class="mt-5 oh-wrapper animated-background"
style="height:80px;"
>
</div>
</div>
<div
class="oh-wrapper"
hx-get="{{view_url}}?{{request.GET.urlencode}}"
hx-trigger="load"
<div
class="oh-wrapper"
hx-get="{{view_url}}?{{request.GET.urlencode}}"
hx-trigger="load"
id="{{view_container_id}}"
>
<div
<div
class="mt-4 animated-background"
style="height:600px;"
>

View File

@@ -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 @@
</div>
<script>
$("li.oh-tabs__tab").click(function (e) {
$("li.oh-tabs__tab").click(function (e) {
var target = `li[data-target="${$(this).attr("data-target")}"]`
e.preventDefault();
$.ajax({
@@ -90,11 +90,11 @@
"target":target,
},
success: function (response) {
}
});
});
{% if active_target %}
$("div.oh-tabs").find(`{{active_target|safe}}`).click();
{% endif %}
</script>
</script>

View File

@@ -35,4 +35,4 @@
<div class="oh-wrapper" hx-get="{% url "htv" %}?{{request.GET.urlencode}}" hx-trigger="load" id="listContainer">
<div class="animated-background"></div>
</div>
{% endblock content %}
{% endblock content %}

View File

@@ -3,11 +3,11 @@
</dic>
<script>
$("#{{dynamic_id}} [name={{field.name}}]").change(function (e) {
$("#{{dynamic_id}} [name={{field.name}}]").change(function (e) {
if (this.value=="dynamic_create") {
$("#modalButton{{field.name}}").click()
$(this).val("").change();
}
});
</script>

View File

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

View File

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

View File

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